TransWikia.com

How do I make `ifup wlan0` return immediately if no dhcp lease can be obtained?

Ask Ubuntu Asked on December 10, 2021

I have a small wireless embedded system based on Ubuntu 16.04. If the wireless interface is improperly configured or the access point is down, ifup wlan0 will never finish because dhclient doesn’t daemonize itself until after it obtains a lease. This is a problem because ifdown wlan0 hangs due to the lock ifup is still holding:

ifdown: waiting for lock on /run/network/ifstate.wlan0

How do I solve this?

  • Option 1: pkill -f 'ifup .*wlan0'; ifdown wlan0

This is crude, but if I have to do this, I will. I’d rather have a better solution.

  • Option 2: dhclient supports a -nw, nowait, option that tells it to daemonize immediately, but ifup doesn’t use it and it seems that the dhclient command is hard-coded in ifup via a source file named inet.defn:

.

$ apt-get source ifupdown
$ grep -n 'dhclient -1' ifupdown-*/inet.defn | head -1
97:    /sbin/dhclient -1 -v -pf /run/dhclient.%iface%.pid -lf /var/lib/dhcp/dhclient.%iface%.leases -I -df /var/lib/dhcp/dhclient6.%iface%.leases %iface% 
  • Option 3: is there a way to make the dhcp be controlled by the status from wpa_supplicant? So, dhclient wouldn’t run until wpa_supplicant completes the association to the access point.

Extra information:

/etc/network/interfaces:

auto lo
iface lo inet loopback

# ifplugd configuration
mapping hotplug
script grep
map eth0
map wlan0

auto eth0
iface eth0 inet dhcp

auto wlan0
iface wlan0 inet dhcp
  wpa-driver wext
  wpa-conf /etc/wpa_supplicant.conf

/etc/wpa_supplicant.conf:

ctrl_interface=DIR=/var/run/wpa_supplicant

network={
   ssid="AccessPoint"
   scan_ssid=1
   proto=WPA RSN
   key_mgmt=WPA-PSK
   pairwise=CCMP TKIP
   group=CCMP TKIP
   psk="passphrase"
   priority=10
}
network={
   key_mgmt=NONE
   priority=0
   disabled=1
}

One Answer

I had the same problem for a while, and doing a simple :

$ systemctl enable netctl.service
$ systemctl start netctl.service

Fixed everything on my ubuntu 17.04.

Hope it helps.

Answered by Taz8du29 on December 10, 2021

Add your own answers!

Ask a Question

Get help from others!

© 2024 TransWikia.com. All rights reserved. Sites we Love: PCI Database, UKBizDB, Menu Kuliner, Sharing RPP