Davinci
Posts: 10
Joined: Sun Jul 22, 2012 11:02 am

Multiple wifi networks

Fri Aug 10, 2012 4:11 pm

I used the automatic setup script for the RTL8188CUS, this works great. However I have two networks in my home with different SSIDs.

This works, but I have to switch networks manually.

Code: Select all

auto lo

iface lo inet loopback
iface eth0 inet dhcp
#static
#address 192.168.1.42
#netmask 255.255.255.0
#gateway 192.168.1.254

allow-hotplug wlan0

auto wlan0

iface wlan0 inet dhcp
wpa-ssid "network1"
wpa-psk "psk1"

#iface wlan0 inet dhcp
#       wpa-ssid "network2"
#       wpa-psk "psk2"
I want something that can automatically switch networks. I tried wpa_supplicant.

Code: Select all

auto lo

iface lo inet loopback
iface eth0 inet dhcp
#static
#address 192.168.1.42
#netmask 255.255.255.0
#gateway 192.168.1.254

allow-hotplug wlan0
iface wlan0 inet manual
 wpa-roam /etc/wpa_supplicant/wpa_supplicant.conf

iface network1 inet dhcp
iface network2 inet dhcp
With /etc/wpa_supplicant/wpa_supplicant.conf

Code: Select all


network={
        ssid="network1"
        scan_ssid=1
        psk="psk1"
        id_str="network1"
        priority=5
        }

network={
        ssid="network2"
        scan_ssid=1
        psk="psk2"
        id_str="network2"
        priority=5
        }
But this didn't seem to work..I found the code above in some topics but I could not find a clear tutorial unfortunately. What am I doing wrong?

pjc123
Posts: 911
Joined: Thu Mar 29, 2012 3:37 pm

Re: Multiple wifi networks

Fri Aug 10, 2012 7:27 pm

As I recall, the following line is mandatory at the top of the /etc/wpa_supplicant/wpa_supplicant.conf file, before the first braket "{". This is where the global settings go:

ctrl_interface=DIR=/var/run/wpa_supplicant GROUP=netdev

If that does not work, let me know. It took me quite a bit of reading and experimenting (with a little cursing thrown in), but I was able to get automatic router selection working and I can post my config files. The wpa_supplicant.conf file is very picky about the parameters that need to be set depending on what you are trying to do, as well as the syntax. If you look at /var/log/syslog, that can be very helpful, especially if you have syntax errors in the config files. It shows you what is happening as the linux reads through the config files. As a side note, the documentation is located in /usr/share/doc/wpa_supplicant; there are examples and detailed explanations of the various parameters. I have the same chipset in my wifi dongle, by the way.
My Raspberry Pi Project Page:
http://www.flaminghellmet.com/launch/

Davinci
Posts: 10
Joined: Sun Jul 22, 2012 11:02 am

Re: Multiple wifi networks

Sat Aug 11, 2012 7:47 pm

Thank you for your response! Good too hear that I am not the only one struggling with this.

Your solution worked for the first accespoint but not for the second. As I couldn't find any differences between the configurations of the accespoints I changed the password. The password on the second one seemed to be the problem. It was apparently a too strong password which was either too long or it had difficulties with some symbols in it...

pjc123
Posts: 911
Joined: Thu Mar 29, 2012 3:37 pm

Re: Multiple wifi networks

Mon Aug 13, 2012 11:23 am

Glad to hear you have it working !
My Raspberry Pi Project Page:
http://www.flaminghellmet.com/launch/

edrabbit
Posts: 4
Joined: Sat Sep 22, 2012 6:39 am

Re: Multiple wifi networks

Sat Sep 22, 2012 5:42 pm

FWIW, here's the notes from my experience getting this working.

Raspberry PI: Add Multiple WiFi Access Points

Hope this helps someone else struggling to get this going. I had to piece together info from multiple sources to get it working.

dlivingstone
Posts: 16
Joined: Mon Dec 30, 2013 10:19 pm

Re: Multiple wifi networks

Mon Dec 30, 2013 10:31 pm

OK, so a year later, another poor soul wanders by having problems with this... trying to get wpa_supplicant to connect successfully to ONE network before I try and get it to work with multiple networks.

as with the OP, I have no problem with wifi setting the ssid and psk in the /etc/network/interfaces file. I have:

Code: Select all

auto lo
iface lo inet loopback
iface eth0 inet dhcp

allow-hotplug wlan0
auto wlan0
iface wlan0 inet dhcp
        wpa-ssid "mySSID"
        wpa-psk abc123abc123...
#wpa-roam /etc/wpa_supplicant/wpa_supplicant.conf
#pre-up wpa_supplicant -Dwext -i wlan0 -c /etc/wpa_supplicant/wpa_supplicant.conf -Bw -dd
iface default inet dhcp
I've tried variations, replacing the wpa-ssid and wpa-psk in the interfaces file with either wpa-roam or pre-up wpa_supplicant - neither with success. I left the commented out lines in the above code incase someone can spot an obvious mistake. Gone through a few variations of wpa_supplicant.conf files, e.g.

Code: Select all

ctrl_interface=DIR=/var/run/wpa_supplicant GROUP=netdev
#update_config=1

network={
        ssid="mySSID"
        scan_ssid=1
        #psk="myPSK"
        psk=abc123abc123...
        id_str="home"
        priority=5
}
To get wireless working in the first place I also had to install drivers as per here: http://www.raspberrypi.org/phpBB3/viewt ... p?p=462982 - wondering if I'd need to override the driver selection in wpa_supplicant.conf too?

dlivingstone
Posts: 16
Joined: Mon Dec 30, 2013 10:19 pm

Re: Multiple wifi networks

Wed Jan 01, 2014 1:08 pm

Ok, still not attempted with multiple networks, but got wifi working using wpa-conf instead of wpa-roam - not sure if this will work against more than one possible wifi network, but will try that out later.

Page 69 of Eben's Raspberry Pi user guide (the first edition) had the recipe that worked for me. Why does wpa-conf work and wpa-roam not? Not sure, but thoroughly confused by the range of options and variations in scripts posted online that work for other folk :D

Return to “Beginners”

Who is online

Users browsing this forum: Head Scratcher and 39 guests