首页
学习
活动
专区
圈层
工具
发布
社区首页 >问答首页 >使用pci插槽的一致网络接口名ubuntu

使用pci插槽的一致网络接口名ubuntu
EN

Unix & Linux用户
提问于 2014-07-09 01:27:01
回答 1查看 6.6K关注 0票数 1

通过修改/etc/udev/rules.d/70-persistent-net.rules,可以通过mac地址设置一致的接口命名。

  • 您能根据PCI插槽号建立一致的接口命名吗?(我试过,但失败了)
  • 还有其他方法来定义一致的接口命名而不是MAC地址吗?

我正在使用Ubuntu 14.04。

修改每个pci插槽的70-persistent-net.rules不起作用--在我将4个端口NIC插入最上面的pci插槽的情况下:

$ lspci -D \ grep -i醚

代码语言:javascript
复制
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

代码语言:javascript
复制
# 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:

代码语言:javascript
复制
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插槽号发生了变化。

EN

回答 1

Unix & Linux用户

发布于 2014-07-09 09:07:50

您应该在/etc/udev/rules.d/70-persistent-net.rules上有一个文件,其中包含一个类似于以下内容的行:

代码语言:javascript
复制
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之外)并将原始文件编辑为:-

代码语言:javascript
复制
SUBSYSTEM=="net", ACTION=="add", KERNELS=="0000:00:03.0", NAME="eth0"

其中KERNELS值可以从lspci -D的第一列中收集。

代码语言:javascript
复制
0000:00:03.0 Ethernet controller: Red Hat, Inc Virtio network device

上面的PCI地址分解为Domain:Bus:Slot.Function,所以上面的设备安装在插槽3上。

注意:我无法访问编写此文件时使用的VM控制台(我是由SSH连接的),所以我无法检查它,因为如果出错,我将被锁在控制台之外。底线是--小心地做这件事,因为你可能会把自己锁在远程系统之外;在本地系统上你会很好。

票数 1
EN
页面原文内容由Unix & Linux提供。腾讯云小微IT领域专用引擎提供翻译支持
原文链接:

https://unix.stackexchange.com/questions/141444

复制
相关文章

相似问题

领券
问题归档专栏文章快讯文章归档关键词归档开发者手册归档开发者手册 Section 归档