Author Topic: Multiple Wireless Ap's  (Read 3366 times)

Shdwdrgn

  • Jr. Member
  • **
  • Posts: 92
    • View Profile
    • http://
Multiple Wireless Ap's
« on: October 14, 2005, 05:38:57 pm »
Is it possible under GPE 3.5.3 to configure more than one access point?  Ideally I would like to enter the specific ssid's and WEP keys for my home and work AP's, plus allow conectivity to any open AP's which are broadcasting themselves.  

Wireless.opts would conect to the first block that matched the discovered AP, but I haven't found a similar method of doing this under GPE.  I see that wireless.opts is still present in GPE, so if there is no method for multiple conections already present, can someone tell me if the code to use wireless.opts is at least complete and functional?

Shdwdrgn

  • Jr. Member
  • **
  • Posts: 92
    • View Profile
    • http://
Multiple Wireless Ap's
« Reply #1 on: October 18, 2005, 05:55:50 pm »
I wanted to update this with my results in case anyone else wants to do something similar.  This is not complete yet, but it is somewhat functional with known AP's.  I currently have to reboot when I change AP's because iwconfig is not automatically releasing the previously-found connection, but I hope to fix that in time.  Also be aware that you will of course not be able to use the GUI to configure your wireless network connection after making these changes.

OK on to the good stuff.  The first file to modify is /etc/network/interface.  You will need to comment out or remove the section that defines wlan0.  Replace it with code similar to this:
Code: [Select]
mapping wlan0
        script /etc/network/findwifi.sh
        map home,*,*,00:11:22:33:44:55      home
        map work,*,*,AA:BB:CC:DD:EE:FF work
        map any,*,*,*                           any

iface home inet dhcp
        wireless_mode managed
        wireless_essid home_ssid
        wireless_key off
        wireless_channel 11
iface work inet dhcp
        wireless_mode managed
        wireless_essid work
        wireless_key open key 0000-0000-0000-0000-0000-0000-00 [1] key [1]
        wireless_channel 6
iface any inet dhcp
        wireless_essid any
        wireless_mode managed
Note that on the 'map' lines you will want to put in the MAC address of your AP's.  You can find this from the command line with iwconfig.  If you do not have a connection to your AP, type in "iwconfig wlan0 essid your_ssid_here".  Once you have a current connection to your AP, type "iwconfig wlan0", and look for the line with the text "Access Point:".  The text after this is your MAC address.

The next step is to create the script findwifi.sh.  This should be placed in /etc/network/.
Code: [Select]
#!/bin/sh

iface="$1"
ifconfig $iface up

cat /etc/network/interfaces | grep "map " | while read x INFO NAME
do

SSID=`echo $INFO | cut -d, -f1`
if [ "$SSID" = "*" ]; then SSID=any; fi
MAC=`echo $INFO | cut -d, -f4`

iwconfig $iface essid $SSID 2>/dev/null
sleep 1
NEWMAC=`iwconfig wlan0 2>/dev/null | grep "Access Point" | sed -n -e 's/.*Point: /\1/p'`
if [ $NEWMAC = $MAC ]; then
        echo $NAME
        exit 0
fi

done
Remember to chmod 755 then file after you create it.  This script tries out each SSID identified in the interfaces file, in order, and returns the name of the first match.  If you want to manually run this file, include the interface name on the command line like such: ./findwifi.sh wlan0

I still need to get the script to drop the old ssid so it can cleanly search for a new AP whenever you insert your wifi card.  Also I want to use "iwfind wlan0 scanning" to attempt to locate an open wifi if one of the primary defined AP's are not detected.  And finally, I would like to find a way to re-run this script any time the connection is lost so that wireless connectivity can be seamlessly maintained when roaming. (If anyone has suggestions on detecting when wifi is lost, let me know?)

Shdwdrgn

  • Jr. Member
  • **
  • Posts: 92
    • View Profile
    • http://
Multiple Wireless Ap's
« Reply #2 on: October 20, 2005, 12:37:41 am »
Looks like I found my problem with not dropping the old SSID when roaming.  I had been making some changes in /etc/pcmcia/network and added code to support udhcpc.  So udhcpc ended up getting called a second time, and when I removed the wifi card, that second instance was locking out changes in wlan0.  Seems to be working fine for me now, so on an unmodified install there should be no problems.

Note it does not rescan when the wifi signal is lost, but the script above will correctly search for configured AP's every time the wireless card is inserted, without having to reboot.