本帖最后由 nettman 于 2014-1-19 01:13 编辑
在虚拟机下安装的CentOS6.0,用克隆的方法,一下搞了好几个CentOS6.0的虚拟机,进入系统之后却发现网卡的序号不再是eth0,而是eth1。
运行ifconfig -a的效果如下:
以前CentOS 5.x版本的时候,在/etc/modprobe.conf里面可以定义网卡的顺序,通过:
复制代码 这种方法来定义。
但是在CentOS6中,已经不存在/etc/modprobe.conf文件了,在/etc/modprobe.d下也不存在对网卡进行配置的配置文件:- [root@localhost modprobe.d]# pwd
- /etc/modprobe.d
- [root@localhost modprobe.d]# grep eth0 *
- [root@localhost modprobe.d]#
复制代码
经过分析发现,CentOS 6.0开始通过udev来管理网卡,具体网卡序号的配置文件在:/etc/udev/rules.d/70-persistent-net.rules文件中,其内容为:- # This file was automatically generated by the /lib/udev/write_net_rules
- # program, run by the persistent-net-generator.rules rules file.
- #
- # You can modify it, as long as you keep each rule on a single
- # line, and change only the value of the NAME= key.
-
- # PCI device 0x15ad:0x07b0 (vmxnet3) (custom name provided by external tool)
- SUBSYSTEM=="net", ACTION=="add", DRIVERS=="?*", ATTR{address}=="00:50:56:93:00:00", ATTR{type}=="1", KERNEL=="eth*", NAME="eth0"
-
- # PCI device 0x15ad:0x07b0 (vmxnet3)
- SUBSYSTEM=="net", ACTION=="add", DRIVERS=="?*", ATTR{address}=="00:50:56:93:00:0e", ATTR{type}=="1", KERNEL=="eth*", NAME="eth1"
复制代码
从上面可以看出,原来的eth0网卡是安装CentOS6那台虚拟机的网卡配置(关键是MAC地址),克隆后虚拟网卡的MAC修改了,所以系统自动生成相应的配置文件,网卡序号为eth1,所以在系统中只能看到eth1。
将/etc/udev/rules.d/70-persistent-net.rules修改:- # This file was automatically generated by the /lib/udev/write_net_rules
- # program, run by the persistent-net-generator.rules rules file.
- #
- # You can modify it, as long as you keep each rule on a single
- # line, and change only the value of the NAME= key.
-
- # PCI device 0x15ad:0x07b0 (vmxnet3)
- SUBSYSTEM=="net", ACTION=="add", DRIVERS=="?*", ATTR{address}=="00:50:56:93:00:0e", ATTR{type}=="1", KERNEL=="eth*", NAME="eth0"
复制代码
|