With the following configuration on Devuan Chimaera Linux:
/etc/network/interfaces
auto wlan0
iface wlan0 inet dhcp
pre-up /sbin/wpa_supplicant -B -Dwext -i wlan0 -c /etc/wpa_supplicant/wpa_supplicant.conf
post-down /usr/bin/killall -q wpa_supplicant
/etc/wpa_supplicant/wpa_supplicant.conf
network={
ssid="MySSID"
psk="redacted"
}
ctrl_interface=/run/wpa_supplicant
update_config=1
dhclient only runs when the interface first comes up.
If I use ifconfig wlan0 down
, the IP address is retained while down and ifconfig wlan0 up
brings the interface back up without running dhclient.
Unfortunately I have a custom /etc/dhcp/dhclient-exit-hooks.d/wlan0-routes which adds custom routes, calculated from the default route provided by dhclient.
When I bring wlan0 down, the custom routes are lost, as expected.
When I bring wlan0 up, dhclient does not run and so the custom routes are not re-added.
Update:
There seems to be a difference in the behaviour of ifconfig wlan0 down
(which caused this) and ifdown wlan0
.
root@demo:~# ifconfig wlan0 down
root@demo:~# ip addr show wlan0
9: wlan0: <BROADCAST,MULTICAST> mtu 1500 qdisc noqueue state DOWN group default qlen 1000
link/ether 00:0e:8e:4c:f6:a3 brd ff:ff:ff:ff:ff:ff
inet 192.168.98.196/24 brd 192.168.98.255 scope global dynamic wlan0
valid_lft 7130sec preferred_lft 7130sec
root@demo5:~# ifconfig wlan0 up
...
root@demo5:~# ifdown wlan0
root@demo5:~# ip addr show wlan0
9: wlan0: <BROADCAST,MULTICAST> mtu 1500 qdisc noqueue state DOWN group default qlen 1000
link/ether 00:0e:8e:4c:f6:a3 brd ff:ff:ff:ff:ff:ff
When I use ifdown wlan0
instead of ifconfig wlan0 down
dhclient
is called when I bring the interface up, and everything works as it ought.
What is the difference between ifconfig wlan0 down
and ifdown wlan0
?
net-o-matic
script. I've written a bash script to help with this:https://github.com/waltinator/net-o-matic
It watches the connection, and when the connection drops, does a user-specified thing to try to reconnect.