Chinaunix首页 | 论坛 | 博客
  • 博客访问: 355525
  • 博文数量: 71
  • 博客积分: 1656
  • 博客等级: 上尉
  • 技术积分: 931
  • 用 户 组: 普通用户
  • 注册时间: 2008-03-17 10:42
文章分类

全部博文(71)

文章存档

2012年(6)

2011年(9)

2010年(4)

2009年(9)

2008年(43)

我的朋友

分类: LINUX

2011-11-18 09:28:07

在虚拟机下安装的CentOS6.0,用克隆的方法,一下搞了好几个CentOS6.0的虚拟机,进入系统之后却发现网卡的序号不再是eth0,而是eth1.

以前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了。

阅读(3319) | 评论(0) | 转发(0) |
给主人留下些什么吧!~~