10

I am running Debian 9.13. I tried to check what is the difference between auto eth1 and allow-hotplug eth1 in /etc/network/interfaces. I have eth1 networking interface connected via USB. I tried rebooting, running systemctl restart networking and plugging/unplugging and it seems that main difference between allow-hotplug and auto is that if interface is marked as auto, command systemctl restart networking fails when eth1 is not connected. This leads to the conclusion that allow-hotplug is in fact preferable in all cases maybe except situation where I know that interface won't go away (lo, built-in interfaces).

Is it correct? Is there any other difference?

2 Answers2

10

I will amend answer with one more very important note. If you use special interfaces, like bonding (trunk) or network bridge, avoid adding allow-hotplug to their configuration inside /etc/networking file, always use auto.

auto brings them on boot, but allow-hotplug can start messing things around during OS runtime (after initial configuration), like remove static ip configuration, reset interface, setting ip auto-configuration, thus resulting in self assigned ip like 169.254.240.1/16.

allow-hotplug basically means for OS: this interfaces is dynamic, manage it on various condition changes.

auto basically is telling to OS: bing up this interface with provided configuration during boot time or interface link up event.

Arunas Bartisius
  • 773
  • 5
  • 13
  • So what you say is that in "common use case", that is when we talk about let's say "eth0" and "usb0", "usb0" being external USB card, I can safely assume that `allow-hotplug` and `auto` are basically the same and only in more sophisticated setups differences are starting to make a difference (and big one at that)? – Jędrzej Dudkiewicz Aug 11 '21 at 05:46
  • 2
    I mean auto is brought on boot as defined in config file, while allow-hotplug starts to manage interface by other managers, which can override the configuration stated in file. This does not make difference in case of DHCP at boot time, but makes some mess in case of static configuration is used. So if you use usb ethernet or wifi, **allow-hotplug** is the one, but if you use 4 interfaces bonded as bond0 you must use **auto** as in my case Debian 9, 10 and 11 messes things immediately after reboot. – Arunas Bartisius Aug 11 '21 at 20:06
7

auto

Interface marked auto will be set UP at boot time.

allow-hotplug

The Interface will wait udev and the Kernel to detect them then it will be set UP.

man interfaces:

Interfaces marked "allow-hotplug" are brought up when udev detects them. 
This can either be during boot if the interface is already present, or 
at a later time, for example when plugging in a USB network card
GAD3R
  • 63,407
  • 31
  • 131
  • 192