• 欢迎访问极客公园网站,WordPress信息,WordPress教程,推荐使用最新版火狐浏览器和Chrome浏览器访问本网站,欢迎加入极客公园 QQ群
  • Git主题现已支持滚动公告栏功能,兼容其他浏览器,看到的就是咯,在后台最新消息那里用li标签添加即可。
  • 最新版Git主题已支持说说碎语功能,可像添加文章一样直接添加说说,新建说说页面即可,最后重新保存固定连接,演示地址
  • 百度口碑求点赞啊啊啊啊啊啊啊啊啊啊啊啊啊啊啊啊啊啊啊啊啊啊啊啊啊啊http://koubei.baidu.com/s/gitcafe.net
  • 如果您觉得本站非常有看点,那么赶紧使用Ctrl+D 收藏极客公园吧

(总结)RHEL6/CentOS6/Scientific Linux 6虚拟机克隆导致的网卡问题解决方法

未分类 博客教主 14年前 (2011-05-18) 6461次浏览 6个评论

刚才在VM虚拟机里测试Scientific Linux 6(RHEL6的重编译版,相当于CentOS 6),看看是否可用于生产环境。因为镜像是在家里的电脑安装的,复制过来启动系统发现网卡启动失败,提示:

Bringing up interface eth0: Device eth0 does not seem to be present, delaying initialization.   [FAILED]

Google了一下,发现是网卡mac地址写入硬件问题导致。

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

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

[root@Oracle ~]# cat /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.

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

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

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

解决这个问题,只要删除旧的UDEV配置,修改为:
[root@Oracle ~]# cat /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.

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

重启network服务有时可以有时不行,重启系统就一切OK!试过多次!
[root@Oracle ~]# /etc/init.d/network restart
Shutting down interface eth0: [ OK ]
Shutting down loopback interface: [ OK ]
Bringing up loopback interface: [ OK ]
Bringing up interface eth0: [ OK ]
[root@Oracle ~]# ifconfig eth0
eth0 Link encap:Ethernet HWaddr 08:00:27:32:66:63
inet addr:172.16.100.3 Bcast:172.16.100.255 Mask:255.255.255.0
inet6 addr: fe80::a00:27ff:fe32:6663/64 Scope:Link
UP BROADCAST RUNNING MULTICAST MTU:1500 Metric:1
RX packets:206 errors:0 dropped:0 overruns:0 frame:0
TX packets:203 errors:0 dropped:0 overruns:0 carrier:0
collisions:0 txqueuelen:1000
RX bytes:21157 (20.6 KiB) TX bytes:24515 (23.9 KiB)

参考:http://bbs.chinaunix.net/viewthread.php?tid=1918368

我的测试环境是VMware Workstation 7.1 + SL 6 x64
最简单的解决办法是直接删除70-persistent-net.rules配置文件

rm -fr /etc/udev/rules.d/70-persistent-net.rules
reboot

重启系统就ok了,系统会自动生成一个新的。


极客公园 , 版权所有丨如未注明 , 均为原创丨本网站采用BY-NC-SA协议进行授权
转载请注明原文链接:(总结)RHEL6/CentOS6/Scientific Linux 6虚拟机克隆导致的网卡问题解决方法
喜欢 (0)

您必须 登录 才能发表评论!

(6)个小伙伴在吐槽
  1. 请问 rhel6 如何用centos 的源 或fedora 。 我安装软件时 ,不太方便。
    嘉谟之行2011-05-19 00:18
    • 安装ELPL的源在图形界面下修改下把bate也选上就可以安装很多软件了.
      pultuo2011-05-20 17:20
      • 这个还要图形界面修改?直接vim /etc/yum.repos.d/epel-testing.repo 把里面enabled=0改成enabled=1就可以了~~
    • 很简单,可以看我总结得这篇:http://www.macd11.com/4052.html RHEL/CentOS/SL Linux 6.x使用EPEL 6的yum软件源
  2. 但是/etc/sysconfig/network-script/ifcfg-eth* 里面的MAC也不一样啊,手工修改?
    lucky_me2013-02-23 20:18
  3. 光重启似乎不总是work,还需要修改mac地址,http://gitsea.com/?p=53#more-53
    frankwong2013-05-30 09:31