Debian 中 allow-hotplug 与 auto 的区别

2018-09-18 3097点热度 5人点赞

Debian 中 allow-hotplug 与 auto 的区别冷不丁没注意还真是小坑了一下,所以在此记录


1 、 allow-hotplug 与 auto 的理论区别

auto

在系统启动的时候启动网络接口,无论网络接口有无连接 (插入网线) 。如果该接口配置了 DHCP,则无论有无网线,系统都会去获取 DHCP 。并且如果没有插入网线,则等该接口超时后才会继续 DHCP 。

allow-hotplug

只有当内核从网络接口检测到热插拔事件后才会启动该接口。如果系统开机时该接口没有插入网线,则系统不会启动该接口。系统启动后,如果插入网线,系统会自动启动该接口。

2 、 allow-hotplug 与 auto 的简单说明

auto

配置这个命令,仅仅是用于开机启动时启动网络接口,如果不配置重启自动不会启动网络接口,就直接导致远程登录失败。

allow-hotplug

配置这个命令,是为了保证端口状态及时更新,或者避免由于手动操作导致的重启 network 失败。

3 、 interface 中的具体使用

auto lo
  iface lo inet loopback
allow-hotplug eth0
  iface eth0 inet dhcp
auto eth1
  iface eth1 inet static
    address 192.168.1.100
    netmask 255.255.255.0
    gateway 192.168.1.1

4 、参考链接

https://wiki.archlinux.org/index.php/Network_configuration_(%E7%AE%80%E4%BD%93%E4%B8%AD%E6%96%87)

http://wiki.ubuntu.org.cn/Ubuntu%E6%9C%8D%E5%8A%A1%E5%99%A8%E5%85%A5%E9%97%A8%E6%8C%87%E5%8D%97

StarryVoid

Have a good time