1

I am struggling to setup my wlan so it can re-associate to another hotspot and renew its IP automatically. I have found a similar question but nobody responded.

I am using Debian stretch. The first association works fine but when the WiFi re-associates with another hotspot (for whatever reason (e.g. first hotspot gets shutdown)) the IP stays the same. If I manually run dhclient wlan0 the IP will refresh. But I want it to be automatic.

Here is my /etc/network/interfaces:

allow-hotplug eth0

auto wlan0
allow-hotplug wlan0
iface wlan0 inet dhcp
wpa-conf /etc/wpa_supplicant/wpa_supplicant.conf
iface default inet dhcp

/etc/wpa_supplicant/wpa_supplicant.conf contains:

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

network={
    ssid="FrstHotspot"
    psk="some password"
}

network={
    ssid="SecondHotspot"
    psk="some password"
}

2 Answers 2

2

As for your /etc/network/interfaces, I think it has to be something similar to this to work with your current configuration:

allow-hotplug wlan0
iface wlan0 inet manual
wpa-driver wext
wpa-conf /etc/wpa_supplicant/wpa_supplicant.conf
iface default inet dhcp

You are defining the interface has dhcp, which then enters in conflict with the wpa_supplicant that invokes DHCP. In that way, wpa_supplicant loses the ability to signal when the ssid/network was changed, and so the IP address does not change when changing networks/ssids.

You can also define priorities in the wpa_supplicant.conf on the ssid to use as in:

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

network={  
ssid="FrstHotspot"  
psk="some password" 
priority = 10  
}

network={  
ssid="SecondHotspot"  
psk="some password" 
priority = 20  
}

The higher the priority, that will be the ssid that will be tried first.

Some content of https://www.raspberrypi.org/documentation/configuration/wireless/wireless-cli.md states:

If you have two networks in range, you can add the priority option to choose between them. The network in range, with the highest priority, will be the one that is connected.

7
  • Thank you for you answer. I have already set a higher priority for one hotspot ("FrstHotspot"). The fact is when my device is connected to "FrstHotspot" and then this hotspot shutdown, it will reassociate to "SecondHotspot" but keep the same IP. For now, I have to manually do dhclient wlan0 ( for example to access the device by ssh). I am searching a solution to automatically do a dhclient when the device reassociate to another hotspot
    – Floufen
    Jul 19, 2018 at 13:17
  • I edit the answer with corrections to your interfaces file, which I had forgot. Jul 19, 2018 at 13:18
  • Adding driver information doesn't change the behavior. But removing allow-hotplug wlan0 will keep the interface down at startup. Perhaps I am not explaining well what I want. The question in this thread is exactly what I am experiencing.
    – Floufen
    Jul 19, 2018 at 13:32
  • In the interfaces file, it has to be manual. The DHCP must be handled by wpa_config Jul 19, 2018 at 13:50
  • If I set it to manual I got : wlan0: association with <mac_address> timed out
    – Floufen
    Jul 19, 2018 at 14:34
0

Partial answer: wpa_supplicant by itself only manages authentication on WLAN interfaces. dhclient is run by another layer, either the traditional ifup/ifdown or others like network manager. wpa_supplicant can send a signal to the other layer, but the other layer must be configured for that.

So the first step is to find out what kind of network management you have installed (Debian supports several). Then you need to configure it.

The wpa_supplicant documentation also to have a document on roaming access, this may also contain hints how to correctly setup ifup/ifdown for automatic reconnect. Look in /usr/share/doc/.

1
  • Thank you for your answer @dirkt. How to figure out wich network manager I am using? At first, my debian comes with connman but I disable it to setup the wpa_supplicant only.
    – Floufen
    Jul 19, 2018 at 12:44

You must log in to answer this question.

Not the answer you're looking for? Browse other questions tagged .