1

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?

1
  • 1
    You could adapt my 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.
    – waltinator
    Jul 20 at 13:38

2 Answers 2

1

quoting from man:

the ifup and ifdown commands may be used to configure (or, respec- tively, deconfigure) network interfaces based on interface definitions in the files /etc/sysconfig/network and /etc/sysconfig/network-scripts/ifcfg-<configuration>

while

Ifconfig is used to configure the kernel-resident network interfaces. It is used at boot time to set up interfaces as necessary. After that, it is usually only needed when debugging or when system tuning is needed.

ifconfig is part of the net-tools (networking utilities) https://net-tools.sourceforge.io/

i think it's kind of an obsolete and deprecated tool replaced by iproute2 https://wiki.linuxfoundation.org/networking/iproute2

0

From https://access.redhat.com/solutions/27166

What is the difference between 'ifconfig up eth0' and 'ifup eth0'?

Resolution:

An "ifconfig" command and "ifup" or "ifdown" command can activate network interfaces. "ifconfig" directly controls network interfaces, however "ifup" or "ifdown" executes "/etc/sysconfig/network-scripts/ifup-" or "ifdown-" scripts. The scripts use an ip command.

"ifconfig" and "ip" commands use ioctl() to activate or deactivate network interfaces. "ifconfig" flags network interfaces 'IFF_UP | IFF_RUNNING', however "ip" flags that 'IFF_UP'.

An "ifconfig up eth0" activates eth0 but does not setup IP addresses, however an "ifup eth0" setup IP addresses or other options based by an ifcfg-eth0, because the "ifup" uses an "ifup-eth*" script.

The ifup command will also configure any static routes that are configured in the network-scripts directory. The ifconfig command will not.

You must log in to answer this question.

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