[TriLUG] Wireless Roaming in Ubuntu

Timothy A. Chagnon tchagnon at futeki.net
Mon Jul 18 21:07:15 EDT 2005


Like Jeff said, setting the essid to any will work for auto-connecting
to an open AP.  The command to find out which APs are around is:
sudo iwlist [interface] scanning

I've got the scenario where I want my laptop to auto-pick an ESSID and
WEP key based on where I am (work or home).  The /etc/network/interfaces
file has the mapping mechanism that allows you to use a script to pick
your options.  It's described (cryptically, imho) in the interfaces(5)
man page.  Basically you write a script that takes an interface name as
the first argument and prints out another interface to jump to.  My
mapping-script just looks for my home or work AP's ESSID in the iwlist
scanning output then prints the interface name to jump to, very simple.
Here's my generalized config for those who are interested (eth1 is my
wireless card):

# /etc/network/interfaces
auto lo eth1
iface lo inet loopback

mapping eth1
    # script prints out an interface below to jump to
    script /usr/local/bin/mapping-script

iface eth1-work inet dhcp
    wireless-essid WorkID
    wireless-key abcdef0123

iface eth1-home inet dhcp
    wireless-essid HomeID
    wireless-key 0123456789

iface eth1-auto inet dhcp
    wireless-essid any
# EOF

#!/bin/bash
# /usr/local/bin/mapping-script

iface="$1"
if [ -z "$iface" ] ; then
    echo "Usage: $0 IFACE"
    exit 1
fi

iwlist eth1 scanning|grep ESSID:\"HomeID\" >/dev/null 2>&1
if [ $? -eq 0 ]; then
    echo $iface-home
    exit
fi

iwlist eth1 scanning|grep ESSID:\"WorkID\" >/dev/null 2>&1
if [ $? -eq 0 ]; then
    echo $iface-work
    exit
fi

# if we're not at home or work look for an open AP
iwlist eth1 scanning|grep key:off >/dev/null 2>&1
if [ $? -eq 0 ]; then
    echo $iface-auto
    exit
fi
#EOF

Good luck,
Tim

On Mon, 2005-07-18 at 19:27 +0000, Randall Barlow wrote:
> How do I get Ubuntu to figure out which wireless AP I am in range of and
> automatically connect to that one without having to go into the
> properties window and manually change the profile?  I seem to recall
> some kind of list of AP's that iwconfig looks through upon booting, but
> I can't seem to find info about it right now.  Thanks!





More information about the TriLUG mailing list