Before network-manager
, the well-known way to "automatically ifup
the network interface when a cable is plugged in" was ifplugd
. (Note the original author :-P). ifplugd
is still available in Debian. I do not have any recent experience with it.
Firstly, you would remove the auto eth0
or allow hotplug eth0
line from /etc/network/interfaces
. You would still need your line iface eth0 inet dhcp
. (This line depends on what the name of your network interface is, and also if you want to add ipv6 support, etc).
To configure ifplugd
to bring up the interface, edit /etc/default/ifplugd
to set INTERFACES=
to include the name of your network interface. Alternatively, it suggests you could use the value auto
. I do not know how well auto
works on any recent system :-).
https://manpages.debian.org/buster/ifplugd/ifplugd.conf.5.en.html
This feature was never provided by allow-hotplug
:
Note that the check for the link state has not always been there, and in any case was only done at boot time. It never supported the case where there was no cable connected at boot, and where you plugged in the cable at a later time. -- Message #20
The sources which contradict this are just wrong. If you want this feature, you need to run a daemon which waits for "netlink" events.[*] The Debian ifupdown
package does not include any daemon. allow-hotplug
relies on the udev daemon, which does not read the necessary netlink events.
The udev daemon only reads udev "hotplug" events ("uevent"s). There is no "uevent" when an Ethernet device detects a link status change. You can verify this using udevadm monitor
.
The Linux kernel developers made a deliberate decision not to provide a "uevent" for this. See: Re: Q: netdev: generate kobject uevent on network events.
[*] Pedant: technically ifplugd
works by polling the link status at regular intervals. So it does not necessarily rely on "netlink" events. This distinction is pointed out by netplug
, which does use "netlink" events. netplug
does not have all the same features as ifplugd
.
Best Answer
Solution:
The differences between
auto
andallow-hotplug
are explained well in Good detailed explanation of/etc/network/interfaces
syntax: