I love titles with plenty of buzz-words :)

After a bit of google-ing I finally found the right combination of tools that fit my needs. Luckily they are all packaged for debian and well documented. Auto-configure your network is an old topic. There are plenty of articles and howtos. Moreover the gnome NetworkManager already solves many problems alone. But since I don’t use NetworkManager I tried to find a solution that works well with wicd.

The “right” combination for me so far is to use guessnet and ifplugd to handle my wired connection and use Wicd for the wireless network. In theory, you can go for a fully automated solution using guessnet and wpa_supplicant, but I find much better to hide all the complexity of wpa_supplicant and just use a simple - and unobtrusive - UI to handle my wireless.

First thing is to convince Wicd to leave alone my wired connection. This is pretty easy since Wicd wont touch your wired interface if it finds an entry in /etc/network/interfaces for it. Moreover to selecting always switch to a wired connection when available will make Wicd to leave alone you routing tables even if there is a wireless connection available that is marked as automatically connect to this network.

Second you need to install guessnet and ifplugd

aptititude install guessnet ifplugd

I’ve noticed that the default settings for ifplugd work pretty well except for the -q option that sometimes lives my interface configured even if I’ve been disconnected for quite a while. Using ifplugd default, I re-obtain an address every time the cable is plugged-in, maybe causing a small delay in some occasion, but I prefer waiting that de-configuring the interface by hand.

Guessnet needs a tiny bit of work. The debian package has already nice defaults that you can copy directly in your /etc/network/interfaces.

# Use guessnet
mapping eth0
        script guessnet-ifupdown
        map default: dhcp
        map timeout: 3
        map verbose: true

iface interface inet manual
        test missing-cable
        pre-up echo No link present.
        pre-up false

# By default, perform DHCP
iface dhcp inet dhcp

These will make sure you avoid long timeouts and you leave the interface configured even if no cable is connected.

Now you have to add one entry per network that you want to configure:

iface home inet dhcp
        test1-peer address 192.168.0.30 mac 88:43:e1:xx:xx:xx

For example to use dhcp on your home network (and of course run any if-up / if-down script as you like). Or :

iface work inet static
        address  192.168.0.1
        netmask 255.255.255.224
        gateway  192.168.0.234
        dns-search buuu.org
        dns-nameservers  192.168.0.30
        test peer address 192.168.0.1 mac 00:1e:xx:xx:xx

to set a static address at work. Guessnet is nice and well integrated with ifupdown. Very flexible and documented. I had however the impression that from time to time the documentation I found on the net was not in sync with the latest release…

I’ve also noticed that a component of guessnet is not in the package anymore. Guessnet-scan is a small program that will output a stanza to be used with ifupdown based on values sniffed on the wire. This is a kinda of extreme / hackish way to get connected but i reckon a nice tool to have. Hopefully it will make it back in the package sometimes soon…

ps: first post on debian planet !