一台 HP 的 centos 6 机器,原来有 onboard 的 Broadcom 网卡在 eth2/eth3,另外还有一张另外加上的 intel 82576 网卡 eth0/eth1。最近更换了那张 intel 卡,另外还再加多了一张同样的 intel 网卡。但是发现 dmesg 老是出现 udev: renamed network interface ethx to renamey 的字眼。通过 /etc/modprobe.d/igb.conf 配置文件也无法指定对应的 intel 卡 到 eth0-eth3 上。
[root@rtploadtest rtp_loadtest]# cat /etc/modprobe.d/igb.conf
# alias eth0 igb
# alias eth1 igb
# alias eth4 igb
# alias eth5 igb
options igb RSS=0,0
[root@rtploadtest rtp_loadtest]# dmesg | grep rename
udev: renamed network interface eth3 to rename5
udev: renamed network interface eth2 to rename4
udev: renamed network interface eth1 to eth5
udev: renamed network interface rename5 to eth1
udev: renamed network interface eth0 to eth4
udev: renamed network interface rename4 to eth0
[root@rtploadtest rtp_loadtest]#
google 一把后才发现和 udev 有关
/etc/udev/rules.d/70-persistent-net.rules 按照卡的 MAC 地址将它映射到对应的 ethx 上。即使其中的一个卡或者MAC已经不见了,udev 还是会将这个映射保留。编辑这个文件就可以得到你需要的效果。
[root@rtploadtest rules.d]# cat 70-persistent-net.rules
# This file was automatically generated by the /lib/udev/write_net_rules
# program, run by the persistent-net-generator.rules rules file.
#
# You can modify it, as long as you keep each rule on a single
# line, and change only the value of the NAME= key.
# PCI device 0x8086:0x10c9 (igb) (custom name provided by external tool)
#SUBSYSTEM=="net", ACTION=="add", DRIVERS=="?*", ATTR{address}=="00:1b:21:cf:ad:fd", ATTR{type}=="1", KERNEL=="eth*", NAME="eth1"
# PCI device 0x14e4:0x164c (bnx2) (custom name provided by external tool)
SUBSYSTEM=="net", ACTION=="add", DRIVERS=="?*", ATTR{address}=="00:23:7d:33:4d:02", ATTR{type}=="1", KERNEL=="eth*", NAME="eth3"
# PCI device 0x8086:0x10c9 (igb) (custom name provided by external tool)
#SUBSYSTEM=="net", ACTION=="add", DRIVERS=="?*", ATTR{address}=="00:1b:21:cf:ad:fc", ATTR{type}=="1", KERNEL=="eth*", NAME="eth0"
# PCI device 0x14e4:0x164c (bnx2) (custom name provided by external tool)
SUBSYSTEM=="net", ACTION=="add", DRIVERS=="?*", ATTR{address}=="00:23:7d:33:4d:12", ATTR{type}=="1", KERNEL=="eth*", NAME="eth2"
# PCI device 0x8086:0x10c9 (igb)
SUBSYSTEM=="net", ACTION=="add", DRIVERS=="?*", ATTR{address}=="00:1b:21:d6:9f:64", ATTR{type}=="1", KERNEL=="eth*", NAME="eth0"
# PCI device 0x8086:0x10c9 (igb)
SUBSYSTEM=="net", ACTION=="add", DRIVERS=="?*", ATTR{address}=="00:1b:21:d6:9e:45", ATTR{type}=="1", KERNEL=="eth*", NAME="eth5"
# PCI device 0x8086:0x10c9 (igb)
SUBSYSTEM=="net", ACTION=="add", DRIVERS=="?*", ATTR{address}=="00:1b:21:d6:9e:44", ATTR{type}=="1", KERNEL=="eth*", NAME="eth4"
# PCI device 0x8086:0x10c9 (igb)
SUBSYSTEM=="net", ACTION=="add", DRIVERS=="?*", ATTR{address}=="00:1b:21:d6:9f:65", ATTR{type}=="1", KERNEL=="eth*", NAME="eth1"
[root@rtploadtest rules.d]#