分类: LINUX
2011-11-18 09:28:07
以前CentOS 5.x版本的时候,在/etc/modprobe.conf里面可以定义网卡的顺序,通过:
1 |
alias eth0 e1000e |
这种方法来定义。
但是在CentOS6中,已经不存在/etc/modprobe.conf文件了,在/etc/modprobe.d下也不存在对网卡进行配置的配置文件:
1
2
3
4 |
[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文件中,其内容为:
01
02
03
04
05
06
07
08
09
10
11 |
# 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修改:
1
2
3
4
5
6
7
8 |
# 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" |
重新启动后就可以看到熟悉的eth0了。