当前时区为 UTC + 8 小时



发表新帖 回复这个主题  [ 10 篇帖子 ] 
作者 内容
1 楼 
 文章标题 : ubuntu server 是怎么生成网卡名称的???
帖子发表于 : 2016-03-03 11:40 

注册: 2016-01-26 16:57
帖子: 11
送出感谢: 1
接收感谢: 0 次
我在一块双网卡机器上安装ubuntu server,发现每次安装后网卡的名字都不一样,我的设备是需要产品化的,网卡名不一样带来很多问题。

网卡名称eth* 到p*p1 等等不一定是从0开始,非常莫名奇妙。

很多人说是从/etc/udev/rules.d/70-persistent-net.rules 里修改,后查ubuntu官方资料也这么说。但是我的系统装完之后,根本就没有这个文件。而且

此文件应该是自动生成的。据查是通过/lib/udev/write_net_rules 生成,我手动运行此脚本报错:missing $INTERFACE

请问大家这是什么鬼问题??


页首
 用户资料  
 
2 楼 
 文章标题 : Re: ubuntu server 是怎么生成网卡名称的???
帖子发表于 : 2016-03-03 11:46 
头像

注册: 2011-03-20 13:12
帖子: 4522
地址: 山东省寿光县
系统: Debian
送出感谢: 105
接收感谢: 997
beingjoey 写道:
网卡名称eth* 到p*p1 等等不一定是从0开始,非常莫名奇妙。

说明 Ubuntu 版本?从 15.04 开始换用 systemd,网卡命名规则改变
参考
https://www.freedesktop.org/wiki/Software/systemd/PredictableNetworkInterfaceNames/
https://major.io/2015/08/21/understanding-systemds-predictable-network-device-names/

beingjoey 写道:
但是我的系统装完之后,根本就没有这个文件。

没有就自己创建一个,但可以不叫 70-persistent-net.rules。
如创建 /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"

参考 https://wiki.archlinux.org/index.php/Network_configuration#Change_device_name


_________________
Debian 中文论坛 - forums.debiancn.org
欢迎所有 Debian GNU/Linux 用户


最后由 vickycq 编辑于 2016-05-30 16:31,总共编辑了 3 次


_________________
评价: 3.7% beingjoey
 
页首
 用户资料  
 
3 楼 
 文章标题 : Re: ubuntu server 是怎么生成网卡名称的???
帖子发表于 : 2016-03-03 11:51 

注册: 2016-01-26 16:57
帖子: 11
送出感谢: 1
接收感谢: 0 次
Ubuntu 14.04.3 LTS


页首
 用户资料  
 
4 楼 
 文章标题 : Re: ubuntu server 是怎么生成网卡名称的???
帖子发表于 : 2016-03-03 14:39 

注册: 2009-08-04 16:33
帖子: 16893
送出感谢: 21
接收感谢: 1827
引用:
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
把結果直接 選取/複製/貼上來


页首
 用户资料  
 
5 楼 
 文章标题 : Re: ubuntu server 是怎么生成网卡名称的???
帖子发表于 : 2016-03-03 17:37 

注册: 2016-01-26 16:57
帖子: 11
送出感谢: 1
接收感谢: 0 次
poloshiao 写道:
把下面指令 複製 貼進終端機 執行
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
把結果直接 選取/複製/貼上來


/etc/udev/rules.d/ 中只有README
==========================================================================================================
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)


页首
 用户资料  
 
6 楼 
 文章标题 : Re: ubuntu server 是怎么生成网卡名称的???
帖子发表于 : 2016-03-03 17:41 

注册: 2016-01-26 16:57
帖子: 11
送出感谢: 1
接收感谢: 0 次
vickycq 写道:
没有就自己创建一个,但可以不叫 70-persistent-net.rules。
如创建 /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"

参考 https://wiki.archlinux.org/index.php/Network_configuration#Change_device_name


这个方法我用了,可以生效。但是出了一个问题。我是通过硬盘复制来安装每一天设备的,所以这个配置中ATTR{address}在另一台机器就不匹配了。那这样我需要每次修改这个值,还是很不方便。
参考中的文章,有提到这个问题,但是我没太看懂,尝试也没成功。


页首
 用户资料  
 
7 楼 
 文章标题 : Re: ubuntu server 是怎么生成网卡名称的???
帖子发表于 : 2016-03-03 21:14 

注册: 2009-08-04 16:33
帖子: 16893
送出感谢: 21
接收感谢: 1827
引用:
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

引用:
sudo 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

1. search.php?keywords=RTL8111+r8169&terms=all&author=&sc=1&sf=all&sk=t&sd=d&sr=posts&st=0&ch=300&t=0&submit=%E6%90%9C%E5%B0%8B
r8169 不是合適驅動
引用:
sudo 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

2. search.php?keywords=RTL8111+r8169&terms=all&author=&sc=1&sf=all&sk=t&sd=d&sr=posts&st=0&ch=300&t=0&submit=%E6%90%9C%E5%B0%8B
r8169 不是合適驅動
2-1. 沒有合適 firmware 所以沒有被啟動
引用:
/etc/udev/rules.d/ 中只有README

3. 你是不是安裝過 biosdevname 套件 或 systemd 類似其它套件 ?
http://packages.ubuntu.com/search?suite ... chon=names
引用:
Ubuntu 14.04.3 LTS

3-1. 如果是
什麼原因 你要安裝 biosdevname 套件 ?


页首
 用户资料  
 
8 楼 
 文章标题 : Re: ubuntu server 是怎么生成网卡名称的???
帖子发表于 : 2016-03-04 9:48 

注册: 2016-01-26 16:57
帖子: 11
送出感谢: 1
接收感谢: 0 次
从ubuntu下载系统包后,刻录光盘安装的,安装过程中就提示(在配置网络时)两个网卡分别是p2p1,p3p1(但是一样的硬件可能是eth0,eth1;或是p1p1,p2p1;几种情况都有)。

我没有安装过任何其它软件,一上来就是这样。

驱动的问题我等会试下。


页首
 用户资料  
 
9 楼 
 文章标题 : Re: ubuntu server 是怎么生成网卡名称的???
帖子发表于 : 2016-03-04 12:30 

注册: 2009-08-04 16:33
帖子: 16893
送出感谢: 21
接收感谢: 1827
引用:
驱动的问题我等会试下。

等你驅動 Ok 以後

/etc/udev/rules.d/70-persistent-net.rules
/etc/udev/rules.d/75-network.rules
內容
全部清空
重新開機
再看看情況
歡迎再貼文


页首
 用户资料  
 
10 楼 
 文章标题 : Re: ubuntu server 是怎么生成网卡名称的???
帖子发表于 : 2016-03-04 13:33 
头像

注册: 2011-03-20 13:12
帖子: 4522
地址: 山东省寿光县
系统: Debian
送出感谢: 105
接收感谢: 997
beingjoey 写道:
RTL8111/8168/8411
驱动的问题我等会试下。

直接使用软件源的 r8168-dkms 即可

也可尝试添加内核参数 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

beingjoey 写道:
参考中的文章,有提到这个问题,但是我没太看懂,尝试也没成功。

udev 还有很多匹配模式,也可用驱动匹配。如现在的 r8169,安装 r8168-dkms 后的 r8168

参考
https://www.freedesktop.org/software/systemd/man/udev.html
http://www.reactivated.net/writing_udev_rules.html
https://bugs.launchpad.net/ubuntu/+source/biosdevname/+bug/1284043


_________________
Debian 中文论坛 - forums.debiancn.org
欢迎所有 Debian GNU/Linux 用户


页首
 用户资料  
 
显示帖子 :  排序  
发表新帖 回复这个主题  [ 10 篇帖子 ] 

当前时区为 UTC + 8 小时


在线用户

正在浏览此版面的用户:没有注册用户 和 0 位游客


不能 在这个版面发表主题
不能 在这个版面回复主题
不能 在这个版面编辑帖子
不能 在这个版面删除帖子
不能 在这个版面提交附件

前往 :  
本站点为公益性站点,用于推广开源自由软件,由 DiaHosting VPSBudgetVM VPS 提供服务。
我们认为:软件应可免费取得,软件工具在各种语言环境下皆可使用,且不会有任何功能上的差异;
人们应有定制和修改软件的自由,且方式不受限制,只要他们自认为合适。

Powered by phpBB © 2000, 2002, 2005, 2007 phpBB Group
简体中文语系由 王笑宇 翻译