Wireless auto configuration with guessnet on Linux

Sunday, May 17, 2015 · 1 minute · 193 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 :

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 "<em>homessid</em>"
	wpa-psk "<em>homepassword</em>"
	test wireless essid <em>HOMESSID</em>

iface work inet dhcp
	wpa-ssid "<em>workssid</em>"
	wpa-psk "<em>workpassword</em>"
	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