52

I posted a question previously on how to set up a static IP address on the rpi and eventually figured out, along with some others, that the answer was to change wpa-roam to wpa-conf when pointing to /etc/wpa_supplicant/wpa_supplicant.conf, but why does this work?

i.e. when I have this in my /etc/network/interfaces file:

auto lo
iface lo inet loopback

auto wlan0
iface wlan0 inet static
    address 192.168.0.3
    netmask 255.255.255.0
    gateway 192.168.0.1
    broadcast 192.168.0.255
    network 192.168.0.0
wpa-roam /etc/wpa_supplicant/wpa_supplicant.conf

Assuming that /etc/wpa_supplicant/wpa_supplicant.conf has been properly configured, this method doesn't work.

This is the relevant output from iwconfig:

wlan0     unassociated  Nickname:"<WIFI@REALTEK>"
          Mode:Managed  Frequency=2.437 GHz  Access Point: Not-Associated   
          Sensitivity:0/0  
          Retry:off   RTS thr:off   Fragment thr:off
          Power Management:off
          Link Quality:0  Signal level:0  Noise level:0
          Rx invalid nwid:0  Rx invalid crypt:0  Rx invalid frag:0
          Tx excessive retries:0  Invalid misc:0   Missed beacon:0

As well as from ifconfig:

wlan0     Link encap:Ethernet  HWaddr ec:1a:59:64:3a:36  
          UP BROADCAST MULTICAST  MTU:1500  Metric:1
          RX packets:847 errors:0 dropped:1029 overruns:0 frame:0
          TX packets:759 errors:0 dropped:0 overruns:0 carrier:0
          collisions:0 txqueuelen:1000 
          RX bytes:677394 (661.5 KiB)  TX bytes:133345 (130.2 KiB)

But everything magically starts working once you change wpa-roam to wpa-conf and run sudo /etc/init.d/networking restart. When would you use wpa-roam, and when would you use wpa-conf?

2 Answers 2

31

wpa-roaming is a method with which you can browse and connect to wireless networks.

The result of the following setup is that if an ethernet cable is not attached, wlan0 takes precedence and connects you to your desired wireless network or to an available open wireless network or a predetermined wireless network. If you connect an ethernet cable, the cabled network connection immediately shuts down WiFi access and eth0 then connects you to the cabled network. By unplugging the network cable the wireless connection will instantly be available again.

Source : http://manual.aptosid.com/en/inet-setup-en.htm

I assume that, wpa-conf is the static configuration which not needed for roaming through network interfaces. I couldn't find any relevant and detailed document for this.

By the way I have same issue with my WiFi configuration. My WiFi does not work when wired ethernet unplugged. So i changed wpa-roam to wpa-conf as like you, it worked.

7
  • 1
    I suspect that if you want to use wpa-roam, you need to set wlan0 to manual rather than dhcp or static. That's just a theory though.
    – Lawrence
    Commented Aug 27, 2013 at 8:16
  • 5
    Yes that is correct. Roam means that you allow the wireless interface to try and connect to other access points "roaming" - but if you only have 1 set that means it will try to "reconnect" to it if something goes wrong. With wpa-conf it wont reconnect on drop.
    – Piotr Kula
    Commented Aug 27, 2013 at 8:34
  • @Lawrence, indeed. More than a theory though: it is reported when your run sudo /etc/init.d/networking restart Commented Jan 2, 2015 at 13:52
  • @jschulenklopper Ah. didn't even realise that. I don't use /etc/init.d/networking restart at all haha.
    – Lawrence
    Commented Jan 9, 2015 at 2:42
  • 3
    Another difference to note is that for wpa-roam ifplugd disconnects wlan0 when eth0 is plugged in. It's configurable behaviour, and might be RaspberryPI specific.
    – domen
    Commented Sep 24, 2015 at 20:15
6

One can also find a full explanation of the two modes of operation (Managed and Roaming) for wpa_supplicant in it's locally installed documentation file - which can be viewed (an [older?] online version is here):

zless /usr/share/doc/wpa_supplicant/README.modes.gz

It explains that whilst the Managed mode just allows for connection to single configured WiFi network, the Roaming mode allows for connection to multiple WiFi networks with potentially different network configurations which may be controlled by adding the special option id_str which is then matched against corresponding entries in the network config file - specified in the /etc/network/interfaces file. e.g:

allow-hotplug eth1
iface eth1 inet manual
    wpa-driver wext
    wpa-roam /etc/wpa_supplicant/wpa_roam.conf

# id_str="uni"
iface uni inet dhcp

# id_str="home_static"
iface home_static inet static
        address 192.168.0.20
        netmask 255.255.255.0
        network 192.168.0.0
        broadcast 192.168.0.255
        gateway 192.168.0.1

Where the corresponding WiFi networks are specified in the wpa-roam file. e.g /etc/wpa_supplicant/wpa_roam.conf:

network={
        ssid="foo"
        key_mgmt=NONE
        # this id_str will notify /sbin/wpa_action to 'ifup uni'
        id_str="uni"
}

network={
        ssid="bar"
        psk=123456789...
        # this id_str will notify /sbin/wpa_action to 'ifup home_static'
        id_str="home_static"
}

So the "uni" network will use DHCP whilst the "home_static" network will use the static IP address 192.168.0.20. Though one doesn't have to use the id_str option and the device will just use the defaults (see the doc file).

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Not the answer you're looking for? Browse other questions tagged or ask your own question.