我在一块双网卡机器上安装ubuntu server,发现每次安装后网卡的名字都不一样,我的设备是需要产品化的,网卡名不一样带来很多问题。
网卡名称eth* 到p*p1 等等不一定是从0开始,非常莫名奇妙。
很多人说是从/etc/udev/rules.d/70-persistent-net.rules 里修改,后查ubuntu官方资料也这么说。但是我的系统装完之后,根本就没有这个文件。而且
此文件应该是自动生成的。据查是通过/lib/udev/write_net_rules 生成,我手动运行此脚本报错:missing $INTERFACE
请问大家这是什么鬼问题??
ubuntu server 是怎么生成网卡名称的???
- vickycq
- 帖子: 4507
- 注册时间: 2011-03-20 13:12
- 系统: Debian
- 来自: 山东省寿光县
- 联系:
Re: ubuntu server 是怎么生成网卡名称的???
说明 Ubuntu 版本?从 15.04 开始换用 systemd,网卡命名规则改变beingjoey 写了:网卡名称eth* 到p*p1 等等不一定是从0开始,非常莫名奇妙。
参考
https://www.freedesktop.org/wiki/Softwa ... faceNames/
https://major.io/2015/08/21/understandi ... ice-names/
没有就自己创建一个,但可以不叫 70-persistent-net.rules。beingjoey 写了: 但是我的系统装完之后,根本就没有这个文件。
如创建 /etc/udev/rules.d/75-network.rules
代码: 全选
SUBSYSTEM=="net", ACTION=="add", ATTR{address}=="aa:bb:cc:dd:ee:ff", NAME="net1"
SUBSYSTEM=="net", ACTION=="add", ATTR{address}=="ff:ee:dd:cc:bb:aa", NAME="net0"
上次由 vickycq 在 2016-05-30 16:31,总共编辑 3 次。
Debian 中文论坛 - forums.debiancn.org
欢迎所有 Debian GNU/Linux 用户
欢迎所有 Debian GNU/Linux 用户
-
- 论坛版主
- 帖子: 18279
- 注册时间: 2009-08-04 16:33
Re: ubuntu server 是怎么生成网卡名称的???
Ubuntu 14.04.3 LTS
1. 已確認的 Bug发现每次安装后网卡的名字都不一样
https://bugs.launchpad.net/ubuntu/+sour ... ug/1284043
udev renaming the same hardware network i/f to different name, breaks networking and firewall
2. 如果還是有疑惑
把下面指令 複製 貼進終端機 執行
2-1. sudo cat /etc/udev/rules.d/70-persistent-net.rules
2-2. sudo lspci -knn
2-3. sudo lshw -numeric -class network
2-4. sudo cat /etc/network/interfaces
2-5. sudo ifconfig -a
2-6. sudo cat /etc/udev/rules.d/80-net-name-slot.rules
把結果直接 選取/複製/貼上來
-
- 帖子: 11
- 注册时间: 2016-01-26 16:57
Re: ubuntu server 是怎么生成网卡名称的???
/etc/udev/rules.d/ 中只有READMEpoloshiao 写了: 把下面指令 複製 貼進終端機 執行
2-1. sudo cat /etc/udev/rules.d/70-persistent-net.rules
2-2. sudo lspci -knn
2-3. sudo lshw -numeric -class network
2-4. sudo cat /etc/network/interfaces
2-5. sudo ifconfig -a
2-6. sudo cat /etc/udev/rules.d/80-net-name-slot.rules
把結果直接 選取/複製/貼上來
==========================================================================================================
sudo lspci -knn
00:00.0 Host bridge [0600]: Intel Corporation 3rd Gen Core processor DRAM Controller [8086:0154] (rev 09)
Subsystem: Intel Corporation 3rd Gen Core processor DRAM Controller [8086:0154]
Kernel driver in use: ivb_uncore
00:02.0 VGA compatible controller [0300]: Intel Corporation 3rd Gen Core processor Graphics Controller [8086:0166] (rev 09)
Subsystem: Intel Corporation Device [8086:2010]
Kernel driver in use: i915
00:14.0 USB controller [0c03]: Intel Corporation 7 Series/C210 Series Chipset Family USB xHCI Host Controller [8086:1e31] (rev 04)
Subsystem: Intel Corporation 7 Series/C210 Series Chipset Family USB xHCI Host Controller [8086:1e31]
Kernel driver in use: xhci_hcd
00:16.0 Communication controller [0780]: Intel Corporation 7 Series/C210 Series Chipset Family MEI Controller #1 [8086:1e3a] (rev 04)
Subsystem: Intel Corporation 7 Series/C210 Series Chipset Family MEI Controller #1 [8086:1e3a]
Kernel driver in use: mei_me
00:1a.0 USB controller [0c03]: Intel Corporation 7 Series/C210 Series Chipset Family USB Enhanced Host Controller #2 [8086:1e2d] (rev 04)
Subsystem: Intel Corporation 7 Series/C210 Series Chipset Family USB Enhanced Host Controller #2 [8086:1e2d]
Kernel driver in use: ehci-pci
00:1b.0 Audio device [0403]: Intel Corporation 7 Series/C210 Series Chipset Family High Definition Audio Controller [8086:1e20] (rev 04)
Subsystem: Intel Corporation 7 Series/C210 Series Chipset Family High Definition Audio Controller [8086:1e20]
Kernel driver in use: snd_hda_intel
00:1c.0 PCI bridge [0604]: Intel Corporation 7 Series/C210 Series Chipset Family PCI Express Root Port 1 [8086:1e10] (rev c4)
Kernel driver in use: pcieport
00:1c.1 PCI bridge [0604]: Intel Corporation 7 Series/C210 Series Chipset Family PCI Express Root Port 2 [8086:1e12] (rev c4)
Kernel driver in use: pcieport
00:1c.2 PCI bridge [0604]: Intel Corporation 7 Series/C210 Series Chipset Family PCI Express Root Port 3 [8086:1e14] (rev c4)
Kernel driver in use: pcieport
00:1c.3 PCI bridge [0604]: Intel Corporation 7 Series/C210 Series Chipset Family PCI Express Root Port 4 [8086:1e16] (rev c4)
Kernel driver in use: pcieport
00:1d.0 USB controller [0c03]: Intel Corporation 7 Series/C210 Series Chipset Family USB Enhanced Host Controller #1 [8086:1e26] (rev 04)
Subsystem: Intel Corporation 7 Series/C210 Series Chipset Family USB Enhanced Host Controller #1 [8086:1e26]
Kernel driver in use: ehci-pci
00:1f.0 ISA bridge [0601]: Intel Corporation HM77 Express Chipset LPC Controller [8086:1e57] (rev 04)
Subsystem: Intel Corporation HM77 Express Chipset LPC Controller [8086:1e57]
Kernel driver in use: lpc_ich
00:1f.2 IDE interface [0101]: Intel Corporation 7 Series Chipset Family 4-port SATA Controller [IDE mode] [8086:1e01] (rev 04)
Subsystem: Intel Corporation 7 Series Chipset Family 4-port SATA Controller [IDE mode] [8086:1e01]
Kernel driver in use: ata_piix
00:1f.3 SMBus [0c05]: Intel Corporation 7 Series/C210 Series Chipset Family SMBus Controller [8086:1e22] (rev 04)
Subsystem: Intel Corporation 7 Series/C210 Series Chipset Family SMBus Controller [8086:1e22]
00:1f.5 IDE interface [0101]: Intel Corporation 7 Series Chipset Family 2-port SATA Controller [IDE mode] [8086:1e09] (rev 04)
Subsystem: Intel Corporation 7 Series Chipset Family 2-port SATA Controller [IDE mode] [8086:1e09]
Kernel driver in use: ata_piix
02:00.0 Non-VGA unclassified device [0000]: Techwell Inc. Device [1797:6864] (rev 01)
03:00.0 Ethernet controller [0200]: Realtek Semiconductor Co., Ltd. RTL8111/8168/8411 PCI Express Gigabit Ethernet Controller [10ec:8168] (rev 06)
Subsystem: Realtek Semiconductor Co., Ltd. Device [10ec:0123]
Kernel driver in use: r8169
04:00.0 Ethernet controller [0200]: Realtek Semiconductor Co., Ltd. RTL8111/8168/8411 PCI Express Gigabit Ethernet Controller [10ec:8168] (rev 06)
Subsystem: Realtek Semiconductor Co., Ltd. Device [10ec:0123]
Kernel driver in use: r8169
==========================================================================================================
sudo lshw -numeric -class net
*-network DISABLED
description: Ethernet interface
product: RTL8111/8168/8411 PCI Express Gigabit Ethernet Controller [10EC:8168]
vendor: Realtek Semiconductor Co., Ltd. [10EC]
physical id: 0
bus info: pci@0000:03:00.0
logical name: p2p1
version: 06
serial: 00:e0:4c:62:9a:df
size: 10Mbit/s
capacity: 1Gbit/s
width: 64 bits
clock: 33MHz
capabilities: pm msi pciexpress msix vpd bus_master cap_list ethernet physical tp mii 10bt 10bt-fd 100bt 100bt-fd 1000bt 1000bt-fd autonegotiation
configuration: autonegotiation=on broadcast=yes driver=r8169 driverversion=2.3LK-NAPI duplex=half latency=0 link=no multicast=yes port=MII speed=10Mbit/s
resources: irq:25 ioport:e000(size=256) memory:f0104000-f0104fff memory:f0100000-f0103fff
*-network
description: Ethernet interface
product: RTL8111/8168/8411 PCI Express Gigabit Ethernet Controller [10EC:8168]
vendor: Realtek Semiconductor Co., Ltd. [10EC]
physical id: 0
bus info: pci@0000:04:00.0
logical name: p3p1
version: 06
serial: 00:e0:4c:62:9a:e0
size: 1Gbit/s
capacity: 1Gbit/s
width: 64 bits
clock: 33MHz
capabilities: pm msi pciexpress msix vpd bus_master cap_list ethernet physical tp mii 10bt 10bt-fd 100bt 100bt-fd 1000bt 1000bt-fd autonegotiation
configuration: autonegotiation=on broadcast=yes driver=r8169 driverversion=2.3LK-NAPI duplex=full firmware=rtl8168e-3_0.0.4 03/27/12 ip=192.168.1.129 latency=0 link=yes multicast=yes port=MII speed=1Gbit/s
resources: irq:26 ioport:d000(size=256) memory:f0004000-f0004fff memory:f0000000-f0003fff
==========================================================================================================
cat /etc/network/interfaces
# This file describes the network interfaces available on your system
# and how to activate them. For more information, see interfaces(5).
# The loopback network interface
auto lo
iface lo inet loopback
# The primary network interface
auto eth0
iface eth0 inet static
address 192.168.100.201
netmask 255.255.255.0
gateway 192.168.100.1
auto eth1
iface eth1 inet static
address 192.168.1.129
netmask 255.255.255.0
gateway 192.168.1.1
这里的interfaces是我写死的,我希望这个硬件出厂时的ip是固定的。就是因为这个需求,我才要希望每个设备初试的网卡名是一样的。
========================================================================================================
ifconfig -a
lo Link encap:Local Loopback
inet addr:127.0.0.1 Mask:255.0.0.0
inet6 addr: ::1/128 Scope:Host
UP LOOPBACK RUNNING MTU:65536 Metric:1
RX packets:20 errors:0 dropped:0 overruns:0 frame:0
TX packets:20 errors:0 dropped:0 overruns:0 carrier:0
collisions:0 txqueuelen:0
RX bytes:1528 (1.5 KB) TX bytes:1528 (1.5 KB)
p2p1 Link encap:Ethernet HWaddr 00:e0:4c:62:9a:df
BROADCAST MULTICAST MTU:1500 Metric:1
RX packets:0 errors:0 dropped:0 overruns:0 frame:0
TX packets:0 errors:0 dropped:0 overruns:0 carrier:0
collisions:0 txqueuelen:1000
RX bytes:0 (0.0 B) TX bytes:0 (0.0 B)
p3p1 Link encap:Ethernet HWaddr 00:e0:4c:62:9a:e0
inet addr:192.168.1.129 Bcast:192.168.1.255 Mask:255.255.255.0
inet6 addr: fe80::2e0:4cff:fe62:9ae0/64 Scope:Link
UP BROADCAST RUNNING MULTICAST MTU:1500 Metric:1
RX packets:2966 errors:0 dropped:6 overruns:0 frame:0
TX packets:240 errors:0 dropped:0 overruns:0 carrier:0
collisions:0 txqueuelen:1000
RX bytes:239898 (239.8 KB) TX bytes:44811 (44.8 KB)
-
- 帖子: 11
- 注册时间: 2016-01-26 16:57
Re: ubuntu server 是怎么生成网卡名称的???
这个方法我用了,可以生效。但是出了一个问题。我是通过硬盘复制来安装每一天设备的,所以这个配置中ATTR{address}在另一台机器就不匹配了。那这样我需要每次修改这个值,还是很不方便。vickycq 写了: 没有就自己创建一个,但可以不叫 70-persistent-net.rules。
如创建 /etc/udev/rules.d/75-network.rules参考 https://wiki.archlinux.org/index.php/Ne ... evice_name代码: 全选
SUBSYSTEM=="net", ACTION=="add", ATTR{address}=="aa:bb:cc:dd:ee:ff", NAME="net1" SUBSYSTEM=="net", ACTION=="add", ATTR{address}=="ff:ee:dd:cc:bb:aa", NAME="net0"
参考中的文章,有提到这个问题,但是我没太看懂,尝试也没成功。
-
- 论坛版主
- 帖子: 18279
- 注册时间: 2009-08-04 16:33
Re: ubuntu server 是怎么生成网卡名称的???
sudo lspci -knn
03:00.0 Ethernet controller [0200]: Realtek Semiconductor Co., Ltd. RTL8111/8168/8411 PCI Express Gigabit Ethernet Controller [10ec:8168] (rev 06)
Subsystem: Realtek Semiconductor Co., Ltd. Device [10ec:0123]
Kernel driver in use: r8169
04:00.0 Ethernet controller [0200]: Realtek Semiconductor Co., Ltd. RTL8111/8168/8411 PCI Express Gigabit Ethernet Controller [10ec:8168] (rev 06)
Subsystem: Realtek Semiconductor Co., Ltd. Device [10ec:0123]
Kernel driver in use: r8169
1. search.php?keywords=RTL8111+r8169&terms ... C%E5%B0%8Bsudo lshw -numeric -class net
*-network
product: RTL8111/8168/8411 PCI Express Gigabit Ethernet Controller [10EC:8168]
serial: 00:e0:4c:62:9a:e0
configuration: autonegotiation=on broadcast=yes driver=r8169 driverversion=2.3LK-NAPI duplex=full firmware=rtl8168e-3_0.0.4 03/27/12 ip=192.168.1.129 latency=0 link=yes multicast=yes port=MII speed=1Gbit/s
r8169 不是合適驅動
2. search.php?keywords=RTL8111+r8169&terms ... C%E5%B0%8Bsudo lshw -numeric -class net
*-network DISABLED
product: RTL8111/8168/8411 PCI Express Gigabit Ethernet Controller [10EC:8168]
serial: 00:e0:4c:62:9a:df
configuration: autonegotiation=on broadcast=yes driver=r8169 driverversion=2.3LK-NAPI duplex=half latency=0 link=no multicast=yes port=MII speed=10Mbit/s
r8169 不是合適驅動
2-1. 沒有合適 firmware 所以沒有被啟動
3. 你是不是安裝過 biosdevname 套件 或 systemd 類似其它套件 ?/etc/udev/rules.d/ 中只有README
http://packages.ubuntu.com/search?suite ... chon=names
3-1. 如果是Ubuntu 14.04.3 LTS
什麼原因 你要安裝 biosdevname 套件 ?
-
- 帖子: 11
- 注册时间: 2016-01-26 16:57
Re: ubuntu server 是怎么生成网卡名称的???
从ubuntu下载系统包后,刻录光盘安装的,安装过程中就提示(在配置网络时)两个网卡分别是p2p1,p3p1(但是一样的硬件可能是eth0,eth1;或是p1p1,p2p1;几种情况都有)。
我没有安装过任何其它软件,一上来就是这样。
驱动的问题我等会试下。
我没有安装过任何其它软件,一上来就是这样。
驱动的问题我等会试下。
-
- 论坛版主
- 帖子: 18279
- 注册时间: 2009-08-04 16:33
Re: ubuntu server 是怎么生成网卡名称的???
等你驅動 Ok 以後驱动的问题我等会试下。
把
/etc/udev/rules.d/70-persistent-net.rules
/etc/udev/rules.d/75-network.rules
內容
全部清空
重新開機
再看看情況
歡迎再貼文
- vickycq
- 帖子: 4507
- 注册时间: 2011-03-20 13:12
- 系统: Debian
- 来自: 山东省寿光县
- 联系:
Re: ubuntu server 是怎么生成网卡名称的???
直接使用软件源的 r8168-dkms 即可beingjoey 写了:RTL8111/8168/8411
驱动的问题我等会试下。
也可尝试添加内核参数 net.ifnames=1 biosdevname=0
编辑 /etc/default/grub 在 GRUB_CMDLINE_LINUX_DEFAULT 中添加参数 例:
GRUB_CMDLINE_LINUX_DEFAULT="ro splash vt.handoff=7 net.ifnames=1 biosdevname=0"
然后执行 sudo update-grub
udev 还有很多匹配模式,也可用驱动匹配。如现在的 r8169,安装 r8168-dkms 后的 r8168beingjoey 写了:参考中的文章,有提到这个问题,但是我没太看懂,尝试也没成功。
参考
https://www.freedesktop.org/software/sy ... /udev.html
http://www.reactivated.net/writing_udev_rules.html
https://bugs.launchpad.net/ubuntu/+sour ... ug/1284043
Debian 中文论坛 - forums.debiancn.org
欢迎所有 Debian GNU/Linux 用户
欢迎所有 Debian GNU/Linux 用户