Wireless auto configuration with guessnet on Linux

Sunday, May 17, 2015 · 1 minute · 207 words

The wireless tour eiffel

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 :

1sudo apt-get install guessnet

Edit your /etc/network/interface :

 1auto wlan0
 2mapping wlan0
 3	script /usr/sbin/guessnet-ifupdown
 4	map home work
 5	map timeout: 9
 6	map init-time: 9
 7	map verbose: true
 8	map debug: false	
 9
10iface home inet dhcp
11	wpa-ssid "<em>homessid</em>"
12	wpa-psk "<em>homepassword</em>"
13	test wireless essid <em>HOMESSID</em>
14
15iface work inet dhcp
16	wpa-ssid "<em>workssid</em>"
17	wpa-psk "<em>workpassword</em>"
18	test wireless essid <em>WORKESSID</em>

(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 !

Howto Linux Ubuntu