I’ve just discovered waproamd, a tool to adjust the configuration of a wireless nic to the access point it is associated with.
waproamd is a roaming daemon for wireless IEEE 802.11 NICs supporting the Linux wireless extensions. It is intended to configure the WEP keys according to the networks found.
It works just as well without WEP, though. Below is a description for my setup without WEP.
The configuration of waproamd is in three tiers: waproamd, access points and interfaces.
Waproamd configuration is only one file: /etc/default/waproamd.
INTERFACES="ath0" HOTPLUG_INTERFACES="" ARGS="-M"
I my case the interface “ath0” is a cardbus card, so I add the “-M” option, just in case the card isn’t inserted when waproamd is started. It will monitor the card and react when it appears.
Then I have a script for each access point I use. They live in /etc/waproamd/scripts and their names are either the MAC address of the access point, or a name of the form essid:essid where the last “essid” is replaced with the name of the access point. The name might not be unique, though, so the MAC address option is probably the better way.
The access point scripts will have to be executable to work. They will be called with just one argument, either “start” og “stop”, and with a few environment variables: $ESSID and $IFACE for the detected ESSID and the network interface in question.
My scripts are all the same:
#!/bin/sh case "$1" in start) ifup $IFACE=$IFACE-$ESSID ;; stop) ifdown $IFACE ;; esac
In this way I can have a separate network interface configuration in /etc/network/interfaces for each (nic, essid) pair. If one day several access points on my list have the same ESSID, I’ll have to hardwire the name into the script, but until now it hasn’t been necessary.
In /etc/network/interfaces I have several stanzas for each nic, one for each access point. Many use DHCP, and just say
iface ath0-ESSID inet dhcp
where ESSID is replaced with the actual access point name, but a few combinations set up static IP addresses and other options.