28

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?

Martin
  • 7,516

2 Answers2

29

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:

  • 1
    I see. However, in case of servers, the best practice is probably to use auto which will force the interface up regardless whether the cable is connected etc? – Martin Mar 27 '15 at 16:29
  • 1
    Depens. I had a case where i have to set to allow-hotplug because i wanted to ensure that my firewall would negotiate link AFTER the core switch totally booted and applied it's confiurations. In general cases, auto should be enough. –  Mar 27 '15 at 16:31
  • 4
    I would also point out that, in most cases, cloud/EC2/VPS/VMs should use auto! I've lost networking with a nohup service networking restart before with allow-hotplug. – Will Jan 13 '16 at 20:39
  • 1
    Good 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 information –  Feb 10 '17 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". / https://www.linuxquestions.org/questions/linux-kernel-70/detect-wired-connection-with-udev-606568/#post2989660 / https://unix.stackexchange.com/a/520633/29483 – sourcejedi May 23 '19 at 14:18
  • So if you insert a lan cable to the port allow-hotplug will see it and blink. auto will maybe not? – Timo May 19 '21 at 15:37
9

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.

polanks
  • 13
  • 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 Feb 26 '17 at 12:10