+ -
当前位置:首页 → 问答吧 → RHEL6 虚拟机克隆网络问题解决方法

RHEL6 虚拟机克隆网络问题解决方法

时间:2011-01-05

来源:互联网

  1. 环境:Virtualbox+RHEL 6 x64
  2. 用VirtualBox的vboxmanager克隆的虚拟机,操作系统RHEL6,启动后发现网卡不能用了。重启网络服务,报以下错误:
  3. Bringing up interface eth0: Device eth0 does not seem to be present, delaying initialization.   [FAILED]

  4. 在RHEL5里也发生类似事情,因为复制虚拟机MAC会重新生成,但是操作系统的MAC却写在ifcfg-ethx里,造成了不一致,所以不能启动网络接口,在RHEL5里可以使用kudzu或者注释网卡配置文件的MAC字段来解决这个问题。但是在RHEL6里,kudzu已经被hal服务取代了。虽然lspci能够正常认到网卡,但是却无法使用/etc/init.d/network restart来启动服务。尝试注释ifcfg-eth0的MAC字段,还是报错。查看了下udev的规则,发现了问题的所在。

  5. [root@Oracle ~]# cat /etc/udev/rules.d/70-persistent-net.rules
  6. # This file was automatically generated by the /lib/udev/write_net_rules
  7. # program, run by the persistent-net-generator.rules rules file.
  8. #
  9. # You can modify it, as long as you keep each rule on a single
  10. # line, and change only the value of the NAME= key.

  11. # net device () (custom name provided by external tool)
  12. SUBSYSTEM=="net", ACTION=="add", DRIVERS=="?*", ATTR{address}=="08:00:27:16:31:11", ATTR{type}=="1", KERNEL=="eth*", NAME="eth0"

  13. # net device ()
  14. SUBSYSTEM=="net", ACTION=="add", DRIVERS=="?*", ATTR{address}=="08:00:27:32:66:63", ATTR{type}=="1", KERNEL=="eth*", NAME="eth1"
  15. [root@Oracle ~]#

  16. 原来UDEV这里把克隆前的MAC当成了当前虚拟机的eth0 MAC,而重新生成的08:00:27:32:66:63是eth1的MAC。

  17. 解决这个问题,只要删除旧的UDEV配置,修改为:
  18. [root@Oracle ~]# cat /etc/udev/rules.d/70-persistent-net.rules
  19. # This file was automatically generated by the /lib/udev/write_net_rules
  20. # program, run by the persistent-net-generator.rules rules file.
  21. #
  22. # You can modify it, as long as you keep each rule on a single
  23. # line, and change only the value of the NAME= key.

  24. # net device () (custom name provided by external tool)
  25. SUBSYSTEM=="net", ACTION=="add", DRIVERS=="?*", ATTR{address}=="08:00:27:32:66:63", ATTR{type}=="1", KERNEL=="eth*", NAME="eth0"

  26. 重启network服务,一切OK
  27. [root@Oracle ~]# /etc/init.d/network restart
  28. Shutting down interface eth0:                              [  OK  ]
  29. Shutting down loopback interface:                          [  OK  ]
  30. Bringing up loopback interface:                            [  OK  ]
  31. Bringing up interface eth0:                                [  OK  ]
  32. [root@Oracle ~]# ifconfig eth0
  33. eth0      Link encap:Ethernet  HWaddr 08:00:27:32:66:63  
  34.           inet addr:172.16.100.3  Bcast:172.16.100.255  Mask:255.255.255.0
  35.           inet6 addr: fe80::a00:27ff:fe32:6663/64 Scope:Link
  36.           UP BROADCAST RUNNING MULTICAST  MTU:1500  Metric:1
  37.           RX packets:206 errors:0 dropped:0 overruns:0 frame:0
  38.           TX packets:203 errors:0 dropped:0 overruns:0 carrier:0
  39.           collisions:0 txqueuelen:1000
  40.           RX bytes:21157 (20.6 KiB)  TX bytes:24515 (23.9 KiB)
复制代码
Virtualbox有这个问题,VMWARE克隆虚拟机应该也是有这个问题的。

作者: milujite   发布时间: 2011-01-05

学习了一招,谢谢楼主分享

作者: chenyx:   发布时间: 2011-01-05