我有一台 ubuntu 服务器 (meerkat),由于它出现故障,我不得不更换 NIC。因此,我移除了出现故障的 NIC,并用插入服务器两个 PCI 插槽的两个 NIC 替换了它。
一切正常,只是其中一个网卡名称是 eth1-eth3。请参见下面的 ifconfig -a 结果:
eth1 Link encap:Ethernet HWaddr xx:xx:xx:xx:50:a5
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)
Interrupt:16
eth2 Link encap:Ethernet HWaddr xx:xx:xx:xx:50:a4
inet addr:xxx.xxx.xxx.98 Bcast:xxx.xxx.xxx.255 Mask:255.255.255.0
inet6 addr: fe80::204:23ff:fec8:50a4/64 Scope:Link
UP BROADCAST RUNNING MULTICAST MTU:1500 Metric:1
RX packets:18746 errors:0 dropped:0 overruns:0 frame:0
TX packets:25886 errors:0 dropped:0 overruns:0 carrier:0
collisions:0 txqueuelen:1000
RX bytes:3423836 (3.4 MB) TX bytes:3148479 (3.1 MB)
eth3 Link encap:Ethernet HWaddr xx:xx:xx:xx:xx:51
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)
Interrupt:24 Base address:0xe800
eth1-eth3 Link encap:Ethernet HWaddr xx:xx:xx:xx:xx:63
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)
Interrupt:28 Base address:0xec00
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:16436 Metric:1
RX packets:116 errors:0 dropped:0 overruns:0 frame:0
TX packets:116 errors:0 dropped:0 overruns:0 carrier:0
collisions:0 txqueuelen:0
RX bytes:8124 (8.1 KB) TX bytes:8124 (8.1 KB)
我通过 70-persistent-net.rules 搜索如何更改 NIC 名称,但得到的结果是:
# PCI device 0x1186:0x1300 (8139too)
SUBSYSTEM=="net", ACTION=="add", DRIVERS=="?*", ATTR{address}=="xx:xx:xx:xx:xx:56", ATTR{type}=="1", KERNEL=="eth*", NAME="eth0"
# PCI device 0x8086:0x1076 (e1000)
SUBSYSTEM=="net", ACTION=="add", DRIVERS=="?*", ATTR{address}=="xx:xx:xx:xx:xx:a4", ATTR{type}=="1", KERNEL=="eth*", NAME="eth2"
# PCI device 0x11ab:0x4361 (sky2)
SUBSYSTEM=="net", ACTION=="add", DRIVERS=="?*", ATTR{address}=="xx:xx:xx:xx:xx:a5", ATTR{type}=="1", KERNEL=="eth*", NAME="eth1"
# PCI device 0x1106:0x3106 (via-rhine)
SUBSYSTEM=="net", ACTION=="add", DRIVERS=="?*", ATTR{address}=="xx:xx:xx:xx:xx:63", ATTR{dev_id}=="0x0", ATTR{type}=="1", KERNEL=="eth*", NAME="eth3"
# PCI device 0x1106:0x3106 (via-rhine)
SUBSYSTEM=="net", ACTION=="add", DRIVERS=="?*", ATTR{address}=="xx:xx:xx:xx:xx:51", ATTR{dev_id}=="0x0", ATTR{type}=="1", KERNEL=="eth*", NAME="eth3"
我如何将 eth1-eth3 更改为 eth4?为什么 Linux 将我的新网卡标记为 eth1-eth3?
答案1
在 70-persistent-net.rules 中将第二个 eth3 接口的参数更改NAME
为 eth4,然后重新启动网络。
答案2
看一下ifrename
。我记得它非常容易使用。
$ aptitude show ifrename
Description : Rename network interfaces based on various static criteria
Ifrename allow the user to decide what name a network interface will have.
Ifrename can use a variety of selectors to specify how interface names match
the network interfaces on the system, the most common selector is the interface
MAC address.
Site : http://www.hpl.hp.com/personal/Jean_Tourrilhes/Linux/Tools.html
它使用一个配置文件来告诉 udev 如何命名接口。