Assume we have access to the wifi at work and at home. How can I configure my laptop to automatically connect to the right network without using a graphical network manager ? Welcome guessnet !
Install the guessnet package :
sudo apt-get install guessnet
Edit your /etc/network/interface :
auto wlan0 mapping wlan0 script /usr/sbin/guessnet-ifupdown map home work map timeout: 9 map init-time: 9 map verbose: true map debug: false iface home inet dhcp wpa-ssid "homessid" wpa-psk "homepassword" test wireless essid HOMESSID iface work inet dhcp wpa-ssid "workssid" wpa-psk "workpassword" test wireless essid WORKESSID
(variables to adapt to your configuration in italic)
We define the ‘home’ and ‘work’ networks as usual with the iface command. The 2 differences are :
- we use the virtual interface “work” and “home” instead of the real interface “wlan0”.
- we add a test line that checks the ssid : this is used by guessnet to guess the right network
The mapping block uses an external script (here guessnet) with prudent parameters
- the ‘map home work’ tells guessnet to only check this 2 networks
- the init-time wait a little before configuring, to let the drive enough time
That’s it !