:: [DNG] ifupdown laptop wired/wifi tr…
Página superior
Eliminar este mensaje
Responder a este mensaje
Autor: Mason Loring Bliss
Fecha:  
A: DNG
Asunto: [DNG] ifupdown laptop wired/wifi trick
I've been managing network connections on my laptop by hand, and I was just
thinking that I'd like it to bring up its NICs automatically if it's
plugged in, but I didn't want to use ifplugd for various reasons, and
anyway, I like ifupdown and I want to stick with it.

I found Debian bug #120382 and it suggested using mii-tool in pre-up, and
that was just the right thing to do. The suggestion in the bug wasn't quite
the right syntax, but the right syntax was pretty obvious given the general
idea:

---------------------------------------------------------------------------
auto eth0
iface eth0 inet dhcp
    pre-up /sbin/mii-tool eth0 | /bin/grep -qv "no link"


auto wlan0
iface wlan0 inet dhcp
    pre-up /sbin/mii-tool eth0 | /bin/grep -q "no link"
    wpa-conf /etc/wpa_supplicant/wpa_supplicant.conf
---------------------------------------------------------------------------


The effect of this is that if I'm plugged into a wired network, eth0 fires
up dhclient. If I'm not, wpa_supplicant does its thing.

Interesting reading:

    /usr/share/doc/ifupdown/examples/network-interfaces


There are a bunch of fun things you can do with ifupdown without invoking
the complexity of Network Manager documented there, but this mii-tool trick
isn't mentioned.

For folks on laptops, something worth learning is how to use
wpa_supplicant.conf to try a range of networks automatically. You can then
progressively try, for example, your home network, a work network, a coffee
shop network, and then look for open networks:

    /usr/share/doc/wpasupplicant/README.Debian.gz
    /usr/share/doc/wpasupplicant/examples/wpa_supplicant.conf


...and all only if the wired network isn't plugged in, if you use the
mii-tool trick.

Example /etc/wpa_supplicant/wpa_supplicant.conf:

---------------------------------------------------------------------------
network={
        ssid="My Home"
        psk="super secret"
    priority=20
}


network={
        ssid="Coffee Shop"
        psk="also super secret"
    priority=15
}
# But you're better off buying Fair Trade and drinking it at home.


# Work:
network={
        ssid="MegaCorpWifi"
        key_mgmt=WPA-EAP
        eap=TTLS
        identity="user@???"
        anonymous_identity="anonymous@???"
        password="foobar"
        ca_cert="blob://exampleblob"
        priority=10
}


# Try open networks if none of the above are answering.
network={
        key_mgmt=NONE
}
---------------------------------------------------------------------------


I'm mostly writing this so people realize that they aren't forced to use
some convoluted tool to flexibly manage networking. You can cover a wide
range of situations with good old ifupdown.

-- 
Mason Loring Bliss          mason@???          Ewige Blumenkraft!
awake ? sleep : random() & 2 ? dream : sleep; -- Hamlet, Act III, Scene I