intel pro 1000(e1000)网卡”设备名称“自动更换之谜(续)
本文可自由转载,但请遵循“署名-非商业用途-保持一致”的创作共用协议。 永久链接:JoeCen's 小猫窝-----------------------------
今天下午查了一下资料,虽然没有找到导致“网卡设备名”更改的原因,但是找到了解决的方法:
1、将mac地址与设备名绑定。
服务器有3个网卡,而我们只需要一个网卡工作即可。intel pro/1000光纤网卡在2.4内核中是eth2,在2.6内核中是eth0.那么我们可以在/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 221.229.xxx.xxx
netmask 255.255.255.0
network 221.229.xxx.xxx
broadcast 221.229.xxx.xxx
gateway 221.229.xxx.xxx
pre-up /usr/local/bin/check-mac-address.sh eth0 00:07:E9:01:05:11 auto eth2 iface eth2 inet static
auto eth2
address 221.229.xxx.xxx
netmask 255.255.255.0
network 221.229.xxx.xxx
broadcast 221.229.xxx.xxx
gateway 221.229.xxx.xxx
pre-up /usr/local/bin/check-mac-address.sh eth2 00:07:E9:01:05:11
-------------------------------------------------------------------------
起作用的一句是"pre-up"。
其中/usr/local/bin/check-mac-address.sh可以在/usr/share/doc/ifupdown/examples里面找到。其功能是对比列出的设备名的mac的地址,相同的则"exit 0" ,不同则"exit 1"。
这样的话,如果mac地址与interfaces文件中列出的不一样,该网络设备(eth0、eth2)就不会up,只有mac地址一致的网络设备才会up。
2、使用nameif命令
该命令可以根据mac地址手工更改网络设备的名称
-------------------------------------------------------------------------
用法:nameif [-c configfile] [-s] {interface macaddress}
Eg: nameif eth0 00:07:E9:01:05:01
-------------------------------------------------------------------------
将mac地址是“00:07:E9:01:05:01”的网卡的名称更改为“eth0”(如果eth0还没有up)。
对于下载服务器来讲网卡是eth0还是eth2没有什么关系,只要能连接上就可以了,不过如果想将特定的网络设备名称关联到特定的网卡上的话,可以结合上面两种方法,在判断mac地址是否匹配后进行nameif替换即可。
资料:http://lists.debian.org/debian-devel/2004/04/msg00851.html