我有以下内容/etc/udev/rules.d/70-persistent-net.rules
SUBSYSTEM=="net", ACTION=="add", DRIVERS=="?*", ATTR{address}=="d0:50:99:50:43:17", KERNEL=="eth*", NAME="eth0"
SUBSYSTEM=="net", ACTION=="add", DRIVERS=="?*", ATTR{address}=="d0:50:99:50:43:18", KERNEL=="eth*", NAME="eth1"
SUBSYSTEM=="net", ACTION=="add", DRIVERS=="?*", ATTR{address}=="68:05:ca:1a:ce:9d", ATTR{dev_id}=="0x0", ATTR{type}=="1", KERNEL=="eth*", NAME="eth2"
但是,一启动,你udev
就恨我。为什么?
dmesg
片段:
[ 13.328778] e1000e 0000:01:00.0 eth0: registered PHC clock
[ 13.328781] e1000e 0000:01:00.0 eth0: (PCI Express:2.5GT/s:Width x1) 68:05:ca:1a:ce:9d
[ 13.328783] e1000e 0000:01:00.0 eth0: Intel(R) PRO/1000 Network Connection
[ 13.970303] igb 0000:07:00.0: Intel(R) Gigabit Ethernet Network Connection
[ 13.970305] igb 0000:07:00.0: eth1: (PCIe:2.5Gb/s:Width x1) d0:50:99:50:43:17
[ 13.970434] igb 0000:07:00.0: eth1: PBA No: 001300-000
[ 14.013474] igb 0000:08:00.0: Intel(R) Gigabit Ethernet Network Connection
[ 14.013476] igb 0000:08:00.0: eth2: (PCIe:2.5Gb/s:Width x1) d0:50:99:50:43:18
[ 14.013603] igb 0000:08:00.0: eth2: PBA No: 001300-000
[ 16.274874] systemd-udevd[155]: renamed network interface eth2 to p121p1
[ 16.847244] systemd-udevd[160]: renamed network interface eth1 to p119p1
[ 19.425858] systemd-udevd[607]: renamed network interface eth0 to eth2
为什么第三个有效,而前两个无效?
答案1
实际上,我最终通过 PCI 地址 ID 让它工作了。您必须做两件事:
放入/编辑此内容
etc/default/grub
:GRUB_CMDLINE_LINUX_DEFAULT="net.ifnames=1 biosdevname=0
然后做一个
sudo update-grub
将您想要的名称放入 中
/etc/udev/rules.d/70-persistent-net.rules
,如下所示:SUBSYSTEM=="net", ACTION=="add", DRIVERS=="?*", KERNELS=="0000:03:00.0", ATTR{dev_id}=="0x0", ATTR{type}=="1", KERNEL=="eth*", NAME="eth0"
0000:03:00.0
您的输出中的 PCI 地址在哪里dmesg
?
笔记:无需禁用 IPV6,我忘了那里有这个标志。我们只是不使用它,所以为了安全起见我们禁用它。
答案2
将此附加到 /etc/default/grub:
GRUB_CMDLINE_LINUX_DEFAULT="net.ifnames=0 biosdevname=0"
更新引导程序:
sudo update-grub
重启!
reboot
在 ubuntu 15.10 上测试