《linux克隆虚拟机后的网卡启动失败问题.docx》由会员分享,可在线阅读,更多相关《linux克隆虚拟机后的网卡启动失败问题.docx(2页珍藏版)》请在金锄头文库上搜索。
1、现象:将在另一台电脑虚拟机上安装的linux系统文件整个拷贝到本机上,使用时发现执行网卡重启命令时出现如下错误:rootlocalhost Desktop# service network restartShutting down loopback interface: OK Bringing up loopback interface: OK Bringing up interface eth0: Error: No suitable device found: no device found for connection System eth0. FAILED而且执行ifconfig显示的
2、是eth1网卡,但/etc/sysconfig/network-script下只有eth0,没有eth1产生这个问题的原因是虚拟机分配给操作系统的虚拟网卡MAC地址是不一样的。第一个系统的网卡MAC地址记录在了/etc/udev/rules.d/70-persistent-net.rules,命名为eth0。新克隆分配的系统的网卡MAC地址也记录在了该文件当中,与之前的系统一样,因此有了冲突。可以查看一下两个机子的这个70-persistent-net.rules文件的内容第一个系统:rootlocalhost rules.d# cat 70-persistent-net.rules # Th
3、is 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 0x1022:0x2000 (pcnet32)SUBSYSTEM=net, ACTI
4、ON=add, DRIVERS=?*, ATTRaddress=00:0c:29:f4:95:e3, ATTRtype=1, KERNEL=eth*, NAME=eth0 克隆后的系统:rootlocalhost rules.d# cat 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,
5、 as long as you keep each rule on a single# line, and change only the value of the NAME= key.# PCI device 0x1022:0x2000 (pcnet32)SUBSYSTEM=net, ACTION=add, DRIVERS=?*, ATTRaddress=00:0c:29:f4:95:e3, ATTRtype=1, KERNEL=eth*, NAME=eth1 我们可以看到这两个系统中的MAC地址一样。问题解决方法:删除克隆后这个系统中的 /etc/udev/rules.d/70-persi
6、stent-net.rules文件,重启后系统会重新生成一个新的虚拟网卡MAC地址,然后把这个文件里NAME=eth1的eth1改成eth0,同时也要修改ATTRaddress里的mac地址和/etc/sysconfig/network-scripts/ifcfg-eth0文件mac地址,并与新的虚拟网卡MAC地址保持一致。如:将原文件的SUBSYSTEM=net, ACTION=add, DRIVERS=?*, ATTRaddress=00:0c:29:f4:95:e3, ATTRtype=1, KERNEL=eth*, NAME=eth1 改为 SUBSYSTEM=net, ACTION=
7、add, DRIVERS=?*, ATTRaddress=00:0c:29:5c:65:b7, ATTRtype=1, KERNEL=eth*, NAME=eth0 修改/etc/sysconfig/network-scripts/ifcfg-eth0文件DEVICE=eth0IPV6INIT=yesNM_CONTROLLED=yesONBOOT=yesTYPE=EthernetUUID=05944003-ae77-4c9d-9e58-3ec2851db71dDEFROUTE=yesIPV4_FAILURE_FATAL=yesIPV6_AUTOCONF=yesIPV6_DEFROUTE=yes
8、IPV6_FAILURE_FATAL=noNAME=System eth0HWADDR=00:0c:29:5c:65:b7然后重启网络服务,发现一切正常了。rootlocalhost Desktop# service network restartShutting down interface eth0: Device state: 3 (disconnected) OK Shutting down loopback interface: OK Bringing up loopback interface: OK Bringing up interface eth0: Active connection state: activatingActive connection path: /org/freedesktop/NetworkManager/ActiveConnection/1state: activatedConnection activated OK