我有一台带有大量 NIC 的服务器,它们最终都以“rename19”这样的奇怪名称结束。我知道可以通过修改 /etc/udev/rules.d/70-persistent-net.rules 文件来更改接口名称。第一个表明有问题的线索是该文件不存在,尽管它应该自动创建。所以我决定根据 Linux From Scratch 的建议编写自己的文件:
ACTION=="add", SUBSYSTEM=="net", BUS=="pci", KERNELS=="0000:06:00.0", NAME="eth0"
ACTION=="add", SUBSYSTEM=="net", BUS=="pci", KERNELS=="0000:06:00.1", NAME="eth1"
ACTION=="add", SUBSYSTEM=="net", BUS=="pci", KERNELS=="0000:06:00.2", NAME="eth2"
ACTION=="add", SUBSYSTEM=="net", BUS=="pci", KERNELS=="0000:06:00.3", NAME="eth3"
ACTION=="add", SUBSYSTEM=="net", BUS=="pci", KERNELS=="0000:0c:00.0", NAME="mezz0"
ACTION=="add", SUBSYSTEM=="net", BUS=="pci", KERNELS=="0000:0c:00.1", NAME="mezz1"
ACTION=="add", SUBSYSTEM=="net", BUS=="pci", KERNELS=="0000:1b:00.0", NAME="slot1a"
ACTION=="add", SUBSYSTEM=="net", BUS=="pci", KERNELS=="0000:1b:00.1", NAME="slot1b"
ACTION=="add", SUBSYSTEM=="net", BUS=="pci", KERNELS=="0000:20:00.0", NAME="slot2a"
ACTION=="add", SUBSYSTEM=="net", BUS=="pci", KERNELS=="0000:20:00.1", NAME="slot2b"
ACTION=="add", SUBSYSTEM=="net", BUS=="pci", KERNELS=="0000:11:00.0", NAME="slot3a"
ACTION=="add", SUBSYSTEM=="net", BUS=="pci", KERNELS=="0000:11:00.1", NAME="slot3b"
ACTION=="add", SUBSYSTEM=="net", BUS=="pci", KERNELS=="0000:8b:00.0", NAME="slot4a"
ACTION=="add", SUBSYSTEM=="net", BUS=="pci", KERNELS=="0000:8b:00.1", NAME="slot4b"
ACTION=="add", SUBSYSTEM=="net", BUS=="pci", KERNELS=="0000:90:00.0", NAME="slot5a"
ACTION=="add", SUBSYSTEM=="net", BUS=="pci", KERNELS=="0000:90:00.1", NAME="slot5b"
ACTION=="add", SUBSYSTEM=="net", BUS=="pci", KERNELS=="0000:95:00.0", NAME="slot6a"
ACTION=="add", SUBSYSTEM=="net", BUS=="pci", KERNELS=="0000:95:00.1", NAME="slot6b"
(我匹配 PCI ID 而不是 MAC 地址,因为我有多台相同的机器想要将此配置应用到它们。)
重启后,什么都没有改变。好像这些规则根本就没有被读取。dmesg 中也没有发生太多事情:
$ dmesg | grep udev
[ 3.196629] systemd-udevd[323]: starting version 204
[ 6.719140] systemd-udevd[550]: starting version 204
[ 38.695050] init: udev-fallback-graphics main process (1658) terminated with status 1
答案1
显然,udev 或内核行为在 13.04 左右发生了变化,现在需要不同的规则:
ACTION=="add", SUBSYSTEM=="net", KERNELS=="0000:06:00.0", NAME="eth0"
我使用以下方法调试了
udevadm info -a all -p /sys/class/net/em2