CentOS 6.4 克隆出来的虚拟机网卡无法使用问题解决

今天我们在VMWare下安装Linux系统, 之后又克隆了2套系统, 在克隆出来的系统内我们发现网卡如何都起不来
$ service network restart
Shutting down loopback interface:                                     [  OK  ]
Bringing up loopback interface:                                          [  OK  ]
Bringing up interface eth0:     Device eth0 dose not seem to be
present, delaying initialization                                            [FAILED]
 
造成这个问题的原因是 我们是通过 create a full clone 实现的复制虚拟系统的工作
 
在原本的虚拟机里的/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 0x8086:0x100f (e1000)
SUBSYSTEM=="net", ACTION=="add", DRIVERS=="?*", ATTR{address}=="00:0c:29:43:4a:e8", ATTR{type}=="1", KERNEL=="eth*", NAME="eth0"

我们在看一下克隆出来的虚拟机里 /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 0x8086:0x100f (e1000)
SUBSYSTEM=="net", ACTION=="add", DRIVERS=="?*", ATTR{address}=="00:0c:29:43:4a:e8", ATTR{type}=="1", KERNEL=="eth*", NAME="eth0"
# PCI device 0x8086:0x100f (e1000)
SUBSYSTEM=="net", ACTION=="add", DRIVERS=="?*", ATTR{address}=="00:0c:29:93:d8:5c", ATTR{type}=="1", KERNEL=="eth*", NAME="eth1"
 
正是由于上面那2行红字, 克隆出来的设备号是一致的, 系统默认的eth mac是克隆出来的eth0, 而新生成的eth mac 则被标示为eth1
 
解决办法1:
我们直接修改/etc/sysconfig/network-scripts/ifcfg-eth0 修改下面红色部分
1 将DEVICE 改为 eth1
2 将IPADD 改为新的IP地址
3 之后重启network服务
 
$ vi /etc/sysconfig/network-scripts/ifcfg-eth0
DEVICE=eth1
TYPE=Ethernet
ONBOOT=yes
BOOTPROTO=static
IPADDR=192.168.253.130
NETMASK=255.255.255.0
GATEWAY=192.168.253.1
 
$ service network restart
Shutting down interface eth0:                                          [  OK  ]
shutting down loopback interface:                                    [  OK  ]
Bringing up loopback interface:                                        [  OK  ]
Bringing up interface eth0:                                              [  OK  ]
 
解决办法2:
我们直接修改 /etc/udev/rules.d/70-persistent-net.rules 删除下面红色部分, 修改下面蓝色部分
1 删除设备名字为 eth0的那2行
2 将新生成的MAC地址的设备名字改为eth0
3 保存退出后需要重启服务器
 
# 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 0x8086:0x100f (e1000)
SUBSYSTEM=="net", ACTION=="add", DRIVERS=="?*", ATTR{address}=="00:0c:29:43:4a:e8", ATTR{type}=="1", KERNEL=="eth*", NAME="eth0"
# PCI device 0x8086:0x100f (e1000)
SUBSYSTEM=="net", ACTION=="add", DRIVERS=="?*", ATTR{address}=="00:0c:29:93:d8:5c", ATTR{type}=="1", KERNEL=="eth*", NAME="eth0"
$ reboot
posted on 2013-09-13 11:12  FOG  阅读(288)  评论(0编辑  收藏  举报