Because BASH WIN

Well, this is not a real connection manager, but a bunch of notes and scripts. Eventually I managed to use just wpa_supplicant and a little script to check that the network is online (more to come)

Why?

Because Network Manager SUCKS A LOT, pick my ASS every time I do something by hand, it's a fucking bloatware, it's bugged, it's fucking SLOW and I HATE IT

Because SYSTEMD IS SHIT

Because PULSEAUDIO IS SHIT

Because AVAHI IS SHIT

Because resolveconf is A PILE OF SHIT

Because SYSTEMD IS SHIT, AGAIN

Because Connection Manager is a great command line tool but have some bugs

Because the network manager provided by Enlightenment is lovely but have some bugs

Because SYSTEMD IS SHIT

Because WHY have a fucking bloatware when I can connect to any wifi network with just a bunch of commands from a shell? WHY?!?

rageglitch.gif

What I use NOW

Use of wpa fucking supplicant

You need to set /etc/wpa_supplicant/wpa_supplicant.conf as follow.

EXAMPLES

ctrl_interface=/var/run/wpa_supplicant
update_config=1

# any normal AP with password, wpa (wep unchecked)
network={
        ssid="FRITZ!Box 7490"
        psk="jesusfuckingchrist"
}

network={
        ssid="OpenWrt"
        psk="systemdshit"
}

# An OPEN AP without pw or security
network={
        ssid="Vodafone-WiFi"
        key_mgmt=NONE

# An OPEN AP with same ESSID of other AP around: here's how to connect specifically to that one! 
# NOTE that bssid is a FUCKING STRING BUT doesn't require the " as any other string option in the config file.
# WHY, WHY THE FUCK IS THAT. 
# THIS DROVE ME NUTS FOR AN ENTIRE WEEK. I HOPE WHO WROTE THE CONFIG FILE PARSER WILL PASS AN ENTIRE WEEK
# WITH HIS BOWELS EXPLODING SHIT EVERYWHERE.
network={
        bssid=e4:8f:34:56:4f:0e
        key_mgmt=NONE

}

To use it, just launch

wpa_supplicant -dd -i wlan0 -c /etc/wpa_supplicant/wpa_supplicant.conf

-dd is for debugging.

CHECK if network is ok and relaunch dhclient accordingly

Sometime the wifi goes down and turn up again. But doing so, sometimes default route is cleared, I don't know why. So wifi turn on again, you are connected to wifi, but network doesn't work, you check, route -n and there's no fucking default gw. So you have to add it by hand (route add default gw etc. etc.) or you have to kill the fucking dhclient and re-launch it by hand.

This sexual harassment led me to write this script that automagically check the network / gw and KILL / relaunch dhclient accordingly.

INTERFACE="wlan0"
SERVICE="wpa_supplicant"
while :
do
wpa=`pidof $SERVICE`

if [ "${wpa:-null}" = null ]; then
    echo "wpa_supplicant is DEAD"
else
    echo "wpa_supplicant is running, pid $wpa "
    gat=$(/sbin/ip route | awk '/default/ { print $3 }')
    if [ "${gat:-null}" = null ]; then
       echo "wpa_supplicant is running, but NO GATEWAY"
       sleep 1 && killall dhclient && sleep 1 && dhclient -v $INTERFACE
    else
       echo "GW is $gat"
    fi
fi
sleep 10
done

I just launch this on a shell and GW is checked every 10 seconds. So I'm pretty sure my fucking network connection will STAY THE FUCK ON

A very nice script to use

Here it is, thanks to Katolaz!

THIS IS THE REAL DEAL.

FUCK'N TASTIC! It does everything you need.

Old / Other things / Scratchpad

Scanning WIFI networks

iw wlan0 scan and a little grep

Let's awk, let's fuck ourselves

$1 ~ /^BSS/ {
    if($2 !~ /Load:/) { #< Escape "BBS Load:" line
        gsub("(\\(.*|:)", "", $2)
        MAC = toupper($2)
        wifi[MAC]["enc"] = "OPEN"
        wifi[MAC]["WPS"] = "no"
        wifi[MAC]["wpa1"] = ""
        wifi[MAC]["wpa2"] = ""
        wifi[MAC]["wep"] = ""
    }
}
$1 == "SSID:" {
    # fix spaces in SSID
    FS=":" #< Changing field separator on ":", it should be
           #  forbidded sign for SSID name
    $0=$0
    sub(" ", "", $2) #< remove first whitespace
    wifi[MAC]["SSID"] = $2
    FS=" "
    $0=$0
}
$1 == "capability:" {
    for(i=2; i<=NF; i++) {
        if($i ~ /0x[0-9]{4}/) {
            gsub("(\\(|\\))", "", $i)
            if (and(strtonum($i), 0x10)) 
                wifi[MAC]["wep"] = "WEP"
        }
    }
}
$1 == "WPA:" {
    wifi[MAC]["wpa1"] = "WPA1"
}
$1 == "RSN:" {
    wifi[MAC]["wpa2"] = "WPA2"
}
$1 == "WPS:" {
    wifi[MAC]["WPS"] = "yes"
}
$1 == "DS" {
    wifi[MAC]["Ch"] = $5
}
$1 == "signal:" {
    match($2, /-([0-9]{2})\.00/, m)
    wifi[MAC]["Sig"] = m[1]
}
$1 == "TSF:" {
    gsub("(\\(|d|,)", "", $4)
    match($5, /([0-9]{2}):([0-9]{2}):/, m)
    day = $4
    hour = m[1]
    min = m[2]
    wifi[MAC]["TSF"] = day"d"hour"h"min"m"
}
END {
    for (w in wifi) {
        if (wifi[w]["wep"]) {
            if (wifi[w]["wpa1"] || wifi[w]["wpa2"])
                wifi[w]["enc"] = wifi[w]["wpa1"]wifi[w]["wpa2"]
            else
                wifi[w]["enc"] = "WEP"
        }
        printf "%s:%s:%s:%s:%s:%s:%s\n", w, wifi[w]["SSID"], wifi[w]["enc"], \
               wifi[w]["WPS"], wifi[w]["Ch"], wifi[w]["Sig"], wifi[w]["TSF"]
    }
}

result seem good to me:

root@rover:/home/asbesto# iw wlan0 scan | awk -f parsa.awk
1C4997B6F02D:Linkem2.4GHz_51F02C:WPA2:yes:11:76:12d23h25m
A491B1787677:FASTWEB-22032E:WPA2:yes:1:82:0d11h45m
121331D6EEA8:WOW FI - FASTWEB:WPA2:no:1:52:27d15h05m
BA9E639DB4E7:Wiremore:WPA2:no:6:27:0d01h35m
628F34774344:Vodafone-Petacci:OPEN:no:12:70:1d07h59m
root@rover:/home/asbesto#

Now, if one of those ESSID/MAC exist in our conf -> connect and fuck you

check in ESSID/MAC db

grep / awk into /etc/network/interface.ESSID ?

todo

Reta

RETA, "to net" in italian invented words

service networking stop
cp /etc/network/interfaces.ESSIDDELCAZZO /etc/network/interfaces
service networking start

SIMPLE AS FUCK

/etc/network/interfaces

generic dickhead WPA setup:

# This file describes the network interfaces available on your system
# and how to activate them. For more information, see interfaces(5).

source /etc/network/interfaces.d/*

# The loopback network interface
auto lo
iface lo inet loopback

auto wlan0
allow-hotplug
iface wlan0 inet dhcp
        wpa-ssid wifi-del-cazzo
        wpa-psk sucaminchia

Generic open network, no pw, SSID only

# This file describes the network interfaces available on your system
# and how to activate them. For more information, see interfaces(5).

source /etc/network/interfaces.d/*

# The loopback network interface
auto lo
iface lo inet loopback

auto wlan0
allow-hotplug
iface wlan0 inet dhcp
 wireless-ap E4:8F:34:56:4F:0E
 wireless-essid Vodafone-WiFi

I choose to connect to a specific AP using the mac address because we have many AP with the same name in this area.

NOTE: I found wireless-ap settings only by GREAT LUCK, reading a TON OF SHIT:

DEBIANshit initscripts pass wireless-shit options directly to iwconfig, SO the option list can (only?) be found by reading https://linux.die.net/man/8/iwconfig

what the actual fuck

Also look the fucking /etc/network/if-pre-up.d/wireless-tools file

docs are scattered everywhere, jesus fucking christ

The following shit is in italian language. I don't care. Your fault.

Parametri WPA senza wpasupplicant.conf
Almeno a partire da Lenny (Debian 5) è possibile configurare wpa_supplicant direttamente dal file /etc/network/interfaces; per fare ciò sarà però necessario modificare un poco la sintassi. Rifacendomi all'esempio sopra riportato (nel caso con DHCP, ma vale la stessa cosa per un indirizzo statico), il file unico di configurazione andrebbe scritto nel modo seguente:

auto wlan0
iface wlan0 inet dhcp
wpa-ssid NOME_RETE_WIRELESS
wpa-psk cc989812bc2cd489f960d8c1b2428d98d3c5555dac62d70ff691762fb4cc418a
evitando appunto la linea "pre-up wpa_supplicant -iwlan0 -c /etc/wpa_supplicant.conf -B" e dunque l'utilizzo del file "etc/wpa_supplicant.conf. Alla fine i due metodi di configurazione sono da considerarsi equivalenti; sarà infine solo la filosofia dell'utente ad indicare quale metodo sia il migliore (c'è chi preferisce configurare un file in meno nel sistema operativo e chi preferisce avere un file di configurazione "dedicato" per ogni funzione del sistema). In ogni caso, come sempre, prima viene la conoscenza delle possibilità e poi si potrà decidere in tutta calma :-).

Info.png        Nota 
È possibile che in alcune guide troverete la linea "wpa-driver wext" a seguire o a precedere le due citate; nonostante quest'opzione sia effettivamente necessaria, se la si tralascia è ciò che viene comunque selezionato per default: tanto vale allora dimenticarcela ;-).

Oltre alle opzioni "wpa-ssid" e "wpa-psk" (e "wpa-driver"), nel file /usr/share/doc/wpasupplicant/README.Debian.gz troverete tutte le altre possibilità che vi riportiamo qui sotto e utilizzabili a seconda dell'esigenza.

Element        Example Value            Description
=======        =============            ===========
wpa-ssid       plaintextstring          sets the ssid of your network

wpa-bssid      00:1a:2b:3c:4d:5e        the bssid of your AP

wpa-psk        0123456789......         your preshared wpa key. Use
                                        wpa_passphrase(8) to generate your psk
                                        from a passphrase and ssid pair

wpa-key-mgmt   NONE, WPA-PSK, WPA-EAP,  list of accepted authenticated key
               IEEE8021X                management protocols

wpa-group      CCMP, TKIP, WEP104,      list of accepted group ciphers for WPA
               WEP40

wpa-pairwise   CCMP, TKIP, NONE         list of accepted pairwise ciphers for
                                        WPA

wpa-auth-alg   OPEN, SHARED, LEAP       list of allowed IEEE 802.11
                                        authentication algorithms

wpa-proto      WPA, RSN                 list of accepted protocols

wpa-identity   myplaintextname          administrator provided username
                                        (EAP authentication)

wpa-password   myplaintextpassword      your password (EAP authentication)

wpa-scan-ssid  0 or 1                   toggles scanning of ssid with specific
                                        Probe Request frames

wpa-ap-scan    0 or 1 or 2              adjusts the scanning logic of
                                        wpa_supplicant


CategoryMuseo

MyConnectionManager (last edited 2020-03-01 11:21:33 by asbesto)