wpa_supplicant doesn't get new IP when re-associate?

The name of the pictureThe name of the pictureThe name of the pictureClash Royale CLAN TAG#URR8PPP





.everyoneloves__top-leaderboard:empty,.everyoneloves__mid-leaderboard:empty margin-bottom:0;







up vote
0
down vote

favorite












First of all, sorry for my English. 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"







share|improve this question



























    up vote
    0
    down vote

    favorite












    First of all, sorry for my English. 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"







    share|improve this question























      up vote
      0
      down vote

      favorite









      up vote
      0
      down vote

      favorite











      First of all, sorry for my English. 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"







      share|improve this question













      First of all, sorry for my English. 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"









      share|improve this question












      share|improve this question




      share|improve this question








      edited Jul 19 at 13:55









      Anderson

      987




      987









      asked Jul 19 at 9:01









      Floufen

      62




      62




















          2 Answers
          2






          active

          oldest

          votes

















          up vote
          0
          down vote













          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/.






          share|improve this answer





















          • 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 at 12:44

















          up vote
          0
          down vote













          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.







          share|improve this answer























          • 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 at 13:17










          • I edit the answer with corrections to your interfaces file, which I had forgot.
            – Rui F Ribeiro
            Jul 19 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 at 13:32










          • In the interfaces file, it has to be manual. The DHCP must be handled by wpa_config
            – Rui F Ribeiro
            Jul 19 at 13:50










          • If I set it to manual I got : wlan0: association with <mac_address> timed out
            – Floufen
            Jul 19 at 14:34










          Your Answer







          StackExchange.ready(function()
          var channelOptions =
          tags: "".split(" "),
          id: "106"
          ;
          initTagRenderer("".split(" "), "".split(" "), channelOptions);

          StackExchange.using("externalEditor", function()
          // Have to fire editor after snippets, if snippets enabled
          if (StackExchange.settings.snippets.snippetsEnabled)
          StackExchange.using("snippets", function()
          createEditor();
          );

          else
          createEditor();

          );

          function createEditor()
          StackExchange.prepareEditor(
          heartbeatType: 'answer',
          convertImagesToLinks: false,
          noModals: false,
          showLowRepImageUploadWarning: true,
          reputationToPostImages: null,
          bindNavPrevention: true,
          postfix: "",
          onDemand: true,
          discardSelector: ".discard-answer"
          ,immediatelyShowMarkdownHelp:true
          );



          );








           

          draft saved


          draft discarded


















          StackExchange.ready(
          function ()
          StackExchange.openid.initPostLogin('.new-post-login', 'https%3a%2f%2funix.stackexchange.com%2fquestions%2f457159%2fwpa-supplicant-doesnt-get-new-ip-when-re-associate%23new-answer', 'question_page');

          );

          Post as a guest






























          2 Answers
          2






          active

          oldest

          votes








          2 Answers
          2






          active

          oldest

          votes









          active

          oldest

          votes






          active

          oldest

          votes








          up vote
          0
          down vote













          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/.






          share|improve this answer





















          • 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 at 12:44














          up vote
          0
          down vote













          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/.






          share|improve this answer





















          • 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 at 12:44












          up vote
          0
          down vote










          up vote
          0
          down vote









          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/.






          share|improve this answer













          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/.







          share|improve this answer













          share|improve this answer



          share|improve this answer











          answered Jul 19 at 12:32









          dirkt

          13.8k2930




          13.8k2930











          • 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 at 12:44
















          • 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 at 12:44















          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 at 12:44




          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 at 12:44












          up vote
          0
          down vote













          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.







          share|improve this answer























          • 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 at 13:17










          • I edit the answer with corrections to your interfaces file, which I had forgot.
            – Rui F Ribeiro
            Jul 19 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 at 13:32










          • In the interfaces file, it has to be manual. The DHCP must be handled by wpa_config
            – Rui F Ribeiro
            Jul 19 at 13:50










          • If I set it to manual I got : wlan0: association with <mac_address> timed out
            – Floufen
            Jul 19 at 14:34














          up vote
          0
          down vote













          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.







          share|improve this answer























          • 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 at 13:17










          • I edit the answer with corrections to your interfaces file, which I had forgot.
            – Rui F Ribeiro
            Jul 19 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 at 13:32










          • In the interfaces file, it has to be manual. The DHCP must be handled by wpa_config
            – Rui F Ribeiro
            Jul 19 at 13:50










          • If I set it to manual I got : wlan0: association with <mac_address> timed out
            – Floufen
            Jul 19 at 14:34












          up vote
          0
          down vote










          up vote
          0
          down vote









          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.







          share|improve this answer















          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.








          share|improve this answer















          share|improve this answer



          share|improve this answer








          edited Jul 19 at 17:15


























          answered Jul 19 at 13:04









          Rui F Ribeiro

          33.7k1168113




          33.7k1168113











          • 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 at 13:17










          • I edit the answer with corrections to your interfaces file, which I had forgot.
            – Rui F Ribeiro
            Jul 19 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 at 13:32










          • In the interfaces file, it has to be manual. The DHCP must be handled by wpa_config
            – Rui F Ribeiro
            Jul 19 at 13:50










          • If I set it to manual I got : wlan0: association with <mac_address> timed out
            – Floufen
            Jul 19 at 14:34
















          • 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 at 13:17










          • I edit the answer with corrections to your interfaces file, which I had forgot.
            – Rui F Ribeiro
            Jul 19 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 at 13:32










          • In the interfaces file, it has to be manual. The DHCP must be handled by wpa_config
            – Rui F Ribeiro
            Jul 19 at 13:50










          • If I set it to manual I got : wlan0: association with <mac_address> timed out
            – Floufen
            Jul 19 at 14:34















          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 at 13:17




          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 at 13:17












          I edit the answer with corrections to your interfaces file, which I had forgot.
          – Rui F Ribeiro
          Jul 19 at 13:18





          I edit the answer with corrections to your interfaces file, which I had forgot.
          – Rui F Ribeiro
          Jul 19 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 at 13:32




          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 at 13:32












          In the interfaces file, it has to be manual. The DHCP must be handled by wpa_config
          – Rui F Ribeiro
          Jul 19 at 13:50




          In the interfaces file, it has to be manual. The DHCP must be handled by wpa_config
          – Rui F Ribeiro
          Jul 19 at 13:50












          If I set it to manual I got : wlan0: association with <mac_address> timed out
          – Floufen
          Jul 19 at 14:34




          If I set it to manual I got : wlan0: association with <mac_address> timed out
          – Floufen
          Jul 19 at 14:34












           

          draft saved


          draft discarded


























           


          draft saved


          draft discarded














          StackExchange.ready(
          function ()
          StackExchange.openid.initPostLogin('.new-post-login', 'https%3a%2f%2funix.stackexchange.com%2fquestions%2f457159%2fwpa-supplicant-doesnt-get-new-ip-when-re-associate%23new-answer', 'question_page');

          );

          Post as a guest













































































          Popular posts from this blog

          How to check contact read email or not when send email to Individual?

          Bahrain

          Postfix configuration issue with fips on centos 7; mailgun relay