标签:虚拟机 eth0 网卡配置文件 openstack镜像
1,近日,拿到同事通过克隆做的一个镜像,上传到云平台,开机后加载网卡,发现eth0获取不到IP,重启network服务
service network restart Shutting downloopback insterface: [ OK ] Bringing uploopback insterface: [ OK ] Bringing upinterface eth0: Device eth0 does notseem to be present,delaying initialization. [FAILED]
2,经过多方查找,是因为克隆时把之前的虚拟机MAC地址信息拷贝到镜像中的网络配置信息中了,存在于eth0网卡中,并且和udev的网卡配置文件eth0字段的MAC关联,从而导致现在用镜像创建云主机开机,udev自动生成一个新的MAC地址后,发现eth0已经存在克隆的MAC信息,所以将新生成的MAC命名为eth1了,由于该eth0的MAC信息为克隆过来的,udev生成的MAC没有同步到eth0网卡的配置里,所以系统认为eth0的MAC信息不正确,因此会启动失败。
解决办法:
(1)将eth0网卡配置信息中MAC改为udev新生成的MAC地址,并且删掉udev网卡信息配置文件中eth0字段,将eth1改成eth0,保存后重启系统。
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″
vim /etc/sysconfig/network-scripts/ifcfg-eth0 /etc/sysconfig/network-scripts/ifcfg-eth0 HWADDR=08:00:27:16:31:11 #修改为eth1的HWADDR=08:00:27:32:66:63
vim /etc/udev/rules.d/70-persistent-net.rules SUBSYSTEM==”net”, ACTION==”add”, DRIVERS==”?*”,ATTR{address}==”08:00:27:32:66:63″, ATTR{type}==”1″, KERNEL==”eth*”,NAME=”eth0″ #将eth0那一行删除,然后把eth1改为eth0
(2)直接删除/etc/udev/rules.d/70-persistent-net.rules文件(删除该文件不会影响系统崩溃,系统重启后会自动生成),然后删除/etc/sysconfig/network-scripts/ifcfg-eth0中HWADDR和UUID两行,关机重启。
本文出自 “青春记忆” 博客,请务必保留此出处http://mltyrone.blog.51cto.com/6204409/1828872
openstack镜像-关于通过clone虚拟机制作的镜像开机后网卡eth0启动失败的问题
标签:虚拟机 eth0 网卡配置文件 openstack镜像
原文地址:http://mltyrone.blog.51cto.com/6204409/1828872