According to Debian Network setup document allow-hotplug <interface_name> stanza in /etc/network/interfaces file starts an interface when the kernel detects a hotplug event from the interface. What is this hotplug event?
2 Answers
allow-hotplug <interface>, is used the same way auto is by most people. However, the hotplug event is something that involves kernel/udev detection against the hardware, that could be a cable being connected to the port, or a USB-to-Ethernet dongle that will be up and running whenever you plug on USB, or either a PCMCIA wireless card being connected to the slot.
My personal opinion: I also think that allow-hotplug could have more documented examples to make this thing easier to understand. As pointed out by other U&L members and Debian lists, those two options create the "chicken and egg problem" when there are no cables connected or when an event is created:
References:
- Good detailed explanation of /etc/network/interfaces syntax?;
- Re: Netcfg and allow-hotplug vs auto;
- Howto Set Up Multiple Network Schemes on a Linux Laptop PCMCIA, Cardbus, USB ;
- Debian networking. Basic sintax of /etc/networ/interfaces;
-
1I see. However, in case of servers, the best practice is probably to use
autowhich will force the interface up regardless whether the cable is connected etc?Martin– Martin2015-03-27 16:29:19 +00:00Commented Mar 27, 2015 at 16:29 -
1Depens. I had a case where i have to set to
allow-hotplugbecause i wanted to ensure that my firewall would negotiate link AFTER the core switch totally booted and applied it's confiurations. In general cases,autoshould be enough.user34720– user347202015-03-27 16:31:34 +00:00Commented Mar 27, 2015 at 16:31 -
4I would also point out that, in most cases, cloud/EC2/VPS/VMs should use
auto! I've lost networking with anohup service networking restartbefore withallow-hotplug.Will– Will2016-01-13 20:39:41 +00:00Commented Jan 13, 2016 at 20:39 -
1Good catch. I found some of the same issues you and the other answer by Sprinterfreak pointed out at Debian Lists. Edited my answer with this valuable informationuser34720– user347202017-02-10 13:07:38 +00:00Commented Feb 10, 2017 at 13:07
-
Incorrect. "If I power up a system with a built-in ethernet interface, but with no ethernet cable plugged into it, does plugging in an ethernet cable also generate a hotplug event that is noticed by allow-hotplug? Unfortunately no". / linuxquestions.org/questions/linux-kernel-70/… / unix.stackexchange.com/a/520633/29483sourcejedi– sourcejedi2019-05-23 14:18:52 +00:00Commented May 23, 2019 at 14:18
There is a general important thing to remember:
If you configured a plugable device as auto, it will prevent the entire system from booting if it doesn't exist at the moment!
Whether an allow-hotplug configured device IS NOT set to up after services networking restart automatically. That's totally confusing. In both cases I've lost entire systems.
If you have to restart neworking being connected to a hotplug-device you MUST manually ensure to ifup <interface> after restart like this
services networking restart; ifup wlan0
at once. Otherwise you are screwed.
-
4"...device as
auto, it will prevent the entire system from booting if it doesn't exist at the moment", I just tried this on virtual machine and it booted alright (without network of course, since I disabled in VM software all network adapters), care to explain more?Kyslik– Kyslik2017-02-26 12:10:42 +00:00Commented Feb 26, 2017 at 12:10