/etc/network/interfaces - 自动和允许热插拔之间的区别

Jęd*_*icz 11 networking debian interface network-interface

我运行的是 Debian 9.13。我试图检查auto eth1allow-hotplug eth1之间有什么区别/etc/network/interfaces。我有eth1通过连接的网络接口USB。我尝试重新启动、运行systemctl restart networking和插入/拔出,似乎allow-hotplug和之间的主要区别auto在于,如果接口标记为auto,则命令在未连接systemctl restart networking时失败。eth1这得出的结论allow-hotplug实际上在所有情况下都是更可取的,除了我知道接口不会消失的情况(瞧,内置接口)。

这是对的吗?还有其他区别吗?

Aru*_*ius 12

我将用一个非常重要的注释来修改答案。如果您使用特殊接口,例如bonding(trunk)或网桥,请避免添加allow-hotplug到/etc/networking文件中的配置,请始终使用auto.

auto让它们启动,但allow-hotplug可以在操作系统运行时(初始配置后)开始搞乱,例如删除静态 IP 配置、重置接口、设置 ip 自动配置,从而导致自分配 IP,如 169.254.240.1/16。

allow-hotplug对于操作系统来说基本上意味着:该接口是动态的,根据各种条件变化对其进行管理。

auto基本上是告诉操作系统:在启动时或接口链接事件期间使用提供的配置连接此接口。

  • 我的意思是 auto 按照配置文件中的定义在启动时启动,而 allowed-hotplug 开始由其他管理器管理接口,这可以覆盖文件中规定的配置。这对于启动时使用 DHCP 的情况没有影响,但在使用静态配置的情况下会造成一些混乱。因此,如果您使用 USB 以太网或 wifi,**allow-hotplug** 就是其中之一,但如果您使用 4 个绑定为 bond0 的接口,则必须使用 **auto**,就像我的情况一样,Debian 9、10 和 11 会立即搞乱一切重新启动后。 (2认同)

GAD*_*D3R 8

汽车

标记的接口auto将在启动时设置。

允许热插拔

接口将等待 udev 和内核检测到它们,然后将其设置为 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
Run Code Online (Sandbox Code Playgroud)