通过修改/etc/udev/rules.d/70-persistent-net.rules,可以通过mac地址设置一致的接口命名。
我正在使用Ubuntu 14.04。
修改每个pci插槽的70-persistent-net.rules不起作用--在我将4个端口NIC插入最上面的pci插槽的情况下:
$ lspci -D \ grep -i醚
0000:04:00.0 Ethernet controller: Intel Corporation 82576 Gigabit Network Connection (rev 01)
0000:04:00.1 Ethernet controller: Intel Corporation 82576 Gigabit Network Connection (rev 01)
0000:05:00.0 Ethernet controller: Intel Corporation 82576 Gigabit Network Connection (rev 01)
0000:05:00.1 Ethernet controller: Intel Corporation 82576 Gigabit Network Connection (rev 01)
0000:0b:00.0 Ethernet controller: Intel Corporation 82574L Gigabit Network Connection
0000:0c:00.0 Ethernet controller: Intel Corporation 82574L Gigabit Network Connection这是我使用的文件:/etc/udev/rules.d/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:0x10d3 (e1000e)
SUBSYSTEM=="net", ACTION=="add", DRIVERS=="?*", ATTR{address}=="aa:bb:cc:dd:ee:ff", ATTR{dev_id}=="0x0", ATTR{type}=="1", KERNEL=="eth*", NAME="eth1"
# PCI device 0x8086:0x10d3 (e1000e)
SUBSYSTEM=="net", ACTION=="add", DRIVERS=="?*", ATTR{address}=="00:aa:bb:cc:dd:ee", ATTR{dev_id}=="0x0", ATTR{type}=="1", KERNEL=="eth*", NAME="eth0"
SUBSYSTEM=="net", ACTION=="add", KERNELS="0000:04:00.0", NAME="eth2"
SUBSYSTEM=="net", ACTION=="add", KERNELS="0000:04:00.1", NAME="eth3"
SUBSYSTEM=="net", ACTION=="add", KERNELS="0000:05:00.0", NAME="eth4"
SUBSYSTEM=="net", ACTION=="add", KERNELS="0000:05:00.1", NAME="eth5"现在,如果我在同一个插槽中插入两个端口NIC:
0000:02:00.0 Ethernet controller: Intel Corporation 82580 Gigabit Fiber Network Connection (rev 01)
0000:02:00.1 Ethernet controller: Intel Corporation 82580 Gigabit Fiber Network Connection (rev 01)
0000:06:00.0 Ethernet controller: Intel Corporation 82574L Gigabit Network Connection
0000:07:00.0 Ethernet controller: Intel Corporation 82574L Gigabit Network Connection您可以看到PCI插槽号发生了变化。
发布于 2014-07-09 09:07:50
您应该在/etc/udev/rules.d/70-persistent-net.rules上有一个文件,其中包含一个类似于以下内容的行:
SUBSYSTEM=="net", ACTION=="add", DRIVERS=="?*", ATTR{address}=="04:01:07:ab:6e:01", ATTR{dev_id}=="0x0", ATTR{type}=="1", KERNEL=="eth*", NAME="eth0"备份此文件(rules.d之外)并将原始文件编辑为:-
SUBSYSTEM=="net", ACTION=="add", KERNELS=="0000:00:03.0", NAME="eth0"其中KERNELS值可以从lspci -D的第一列中收集。
0000:00:03.0 Ethernet controller: Red Hat, Inc Virtio network device上面的PCI地址分解为Domain:Bus:Slot.Function,所以上面的设备安装在插槽3上。
注意:我无法访问编写此文件时使用的VM控制台(我是由SSH连接的),所以我无法检查它,因为如果出错,我将被锁在控制台之外。底线是--小心地做这件事,因为你可能会把自己锁在远程系统之外;在本地系统上你会很好。
https://unix.stackexchange.com/questions/141444
复制相似问题