Ubuntu 换网卡后,接口名字可能会改变,原来的eth1可能变成eth6,等等。
可以修改 /etc/udev/rules.d/70-persistent-net.rules
# PCI device 0x8086:/sys/devices/pci0000:00/0000:00:01.0/0000:01:00.0/0000:02:02.0/0000:03:00.1 (igb)
SUBSYSTEM=="net", ACTION=="add", DRIVERS=="?*", ATTR{address}=="00:1b:21:5d:4b:e1", ATTR{dev_id}=="0x0", ATTR{type}=="1", KERNEL=="eth*", NAME="eth2"
# PCI device 0x8086:/sys/devices/pci0000:00/0000:00:01.0/0000:01:00.0/0000:02:04.0/0000:04:00.1 (igb)
SUBSYSTEM=="net", ACTION=="add", DRIVERS=="?*", ATTR{address}=="00:1b:21:5d:4b:e5", ATTR{dev_id}=="0x0"