2012年(101)
分类: Oracle
2012-06-12 20:59:32
1.当在SUSE中新添加一块网卡时,系统会自动按规则命名为eth1,eth2,eth3等,但是,如果删除了eth2,和eth3网卡,再添加新的网卡,设备名称会是eth5,这与我们的期望不太一样,是什么样的原因引起的呢?
在SUSE 10及以后的版本,系统管理网卡引入了一个新的配置文件,该文件为:
/etc/udev/rules.d/30-net_persistent_names.rules
打开文件会看到以下内容:
# This rules are autogenerated from /lib/udev/rename_netiface.
# But you can modify them, but make sure that you don't use an interface name
# twice. Also add such interface name rules only in this rules file. Otherwise
# rename_netiface will create wrong rules for new interfaces.
# It is safe to delete a rule, as long as you did not disable automatic rule
# generation. Only if all interfaces get a rule the renaming will work
# flawlessly. See also /etc/udev/rules.d/31-net_create_names.rules.
#
# Read /usr/share/doc/packages/sysconfig/README.Persistent_Interface_Names for
# further information.
#
# Use only a-z, A-Z and 0-9 for interface names!
#
SUBSYSTEM=="net", ACTION=="add", SYSFS{address}=="00:50:56:b1:00:16", IMPORT="/lib/udev/rename_netiface %k eth0"
SUBSYSTEM=="net", ACTION=="add", SYSFS{address}=="00:50:56:b1:00:24", IMPORT="/lib/udev/rename_netiface %k eth1"
其中最后2行就是我们的网卡设备名称了,当新网卡添加后,系统会修改该文件,在后面添加类似一行新的设备及名称,如下:
SUBSYSTEM=="net", ACTION=="add", SYSFS{address}=="00:50:56:b1:00:16", IMPORT="/lib/udev/rename_netiface %k eth0"
SUBSYSTEM=="net", ACTION=="add", SYSFS{address}=="00:50:56:b1:00:24", IMPORT="/lib/udev/rename_netiface %k eth1"
SUBSYSTEM=="net", ACTION=="add", SYSFS{address}=="00:50:56:b1:00:35", IMPORT="/lib/udev/rename_netiface %k eth2"
但是当我们移除网卡时,这个文件不会被更改,因此新添加的设备会按命名规则一直的增加,就会造成上面所描述的现象。
解决办法:
相当简单,删除该文件中的网卡设备即可,例如我们移除了eth1,在文件中把eth1删除,然后把eth2命名为eth1,这样在添加新的网卡时,会自动标记为eth2, 如此即可圆满解决该问题。
此类问题多发生在vmware虚拟主机的网卡添加上。