我有一个Ubuntu服务器(mongoose),我不得不更换一个网卡,因为它是失败的。 所以我删除了失败的网卡,并将两个网卡插入到我的服务器上的两个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)
我GOOGLE了如何通过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?
将第二个eth3接口的NAME参数更改为70-persistent-net.rules中的eth4,然后重新启动您的networking。
看看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
它使用一个configuration文件来告诉udev如何命名接口。