VM克隆后找不到eth0的问题解决

Posted Simple is Awesome

tags:

篇首语:本文由小常识网(cha138.com)小编为大家整理,主要介绍了VM克隆后找不到eth0的问题解决相关的知识,希望对你有一定的参考价值。

问题描述

使用VM WorkStation新建虚拟机A,查看IP信息,显示结果:

[[email protected] ~]# ifconfig -a
eth0      Link encap:Ethernet  HWaddr 00:0C:29:C7:E3:4C  
          inet addr:192.168.188.131  Bcast:192.168.188.255  Mask:255.255.255.0
          inet6 addr: fe80::20c:29ff:fec7:e34c/64 Scope:Link
          UP BROADCAST RUNNING MULTICAST  MTU:1500  Metric:1
          RX packets:120 errors:0 dropped:0 overruns:0 frame:0
          TX packets:80 errors:0 dropped:0 overruns:0 carrier:0
          collisions:0 txqueuelen:1000 
          RX bytes:11502 (11.2 KiB)  TX bytes:10035 (9.7 KiB)

lo        Link encap:Local Loopback  
          inet addr:127.0.0.1  Mask:255.0.0.0
          inet6 addr: ::1/128 Scope:Host
          UP LOOPBACK RUNNING  MTU:16436  Metric:1
          RX packets:0 errors:0 dropped:0 overruns:0 frame:0
          TX packets:0 errors:0 dropped:0 overruns:0 carrier:0
          collisions:0 txqueuelen:0 
          RX bytes:0 (0.0 b)  TX bytes:0 (0.0 b)

此时,我们查看一下网卡信息:

[[email protected] ~]# ll /etc/sysconfig/network-scripts/ifcfg-*
-rw-r--r--. 1 root root 137 Jan  9 16:55 /etc/sysconfig/network-scripts/ifcfg-eth0
-rw-r--r--. 1 root root 254 Oct 10  2013 /etc/sysconfig/network-scripts/ifcfg-lo
[[email protected] ~]#

显然,查看IP信息时显示的网卡信息与实际的网卡信息时一致的,都是eth0。

接下来从虚拟机A克隆一台新的虚拟机B,查看其IP信息,显示结果:

[[email protected]_x64_Logstash ~]# ifconfig -a 
eth1      Link encap:Ethernet  HWaddr 00:0C:29:29:85:84  
          BROADCAST MULTICAST  MTU:1500  Metric:1
          RX packets:0 errors:0 dropped:0 overruns:0 frame:0
          TX packets:0 errors:0 dropped:0 overruns:0 carrier:0
          collisions:0 txqueuelen:1000 
          RX bytes:0 (0.0 b)  TX bytes:0 (0.0 b)

lo        Link encap:Local Loopback  
          inet addr:127.0.0.1  Mask:255.0.0.0
          inet6 addr: ::1/128 Scope:Host
          UP LOOPBACK RUNNING  MTU:16436  Metric:1
          RX packets:0 errors:0 dropped:0 overruns:0 frame:0
          TX packets:0 errors:0 dropped:0 overruns:0 carrier:0
          collisions:0 txqueuelen:0 
          RX bytes:0 (0.0 b)  TX bytes:0 (0.0 b)

[[email protected]_x64_Logstash ~]# 

再查看一下虚拟机B的网卡信息:

[[email protected] ~]# ll /etc/sysconfig/network-scripts/ifcfg-*
-rw-r--r--. 1 root root 137 Jan  9 16:55 /etc/sysconfig/network-scripts/ifcfg-eth0
-rw-r--r--. 1 root root 254 Oct 10  2013 /etc/sysconfig/network-scripts/ifcfg-lo
[[email protected] ~]#

那么问题来了,明明网卡名称是eth0,为什么在查看IP信息时显示的是eth1呢?而且还没有配置好正确的IP地址。
接着,我们再来看一下/etc/sysconfig/network-scripts/ifcfg-eth0中的配置信息:

[[email protected] ~]# vim /etc/sysconfig/network-scripts/ifcfg-eth0
DEVICE=eth0
HWADDR=00:0C:29:29:85:84
TYPE=Ethernet
UUID=eced92fe-8185-4081-a672-ac80e1d9fb95
ONBOOT=yes
NM_CONTROLLED=yes
BOOTPROTO=dhcp

发现什么了吗?执行命令ifconfig -a显示的eth1的MAC地址与/etc/sysconfig/network-scripts/ifcfg-eth0中配置的MAC地址也不一样!

解决方案

第一步:编辑MAC地址,将/etc/sysconfig/network-scripts/ifcfg-eth0中配置的MAC地址修改为ifconfig -a显示的MAC地址。

[[email protected] ~]# vim /etc/sysconfig/network-scripts/ifcfg-eth0
DEVICE=eth0
HWADDR=00:0C:29:6E:2B:3C
TYPE=Ethernet
UUID=eced92fe-8185-4081-a672-ac80e1d9fb95
ONBOOT=yes
NM_CONTROLLED=yes
BOOTPROTO=dhcp

第二步:修改网卡信息

[[email protected] ~]# vim /etc/udev/rules.d/70-persistent-net.rules

  1 # This file was automatically generated by the /lib/udev/write_net_rules
  2 # program, run by the persistent-net-generator.rules rules file.
  3 #
  4 # You can modify it, as long as you keep each rule on a single
  5 # line, and change only the value of the NAME= key.
  6 
  7 # PCI device 0x8086:0x100f (e1000)
  8 #SUBSYSTEM=="net", ACTION=="add", DRIVERS=="?*", ATTR{address}=="00:0c:29:6e:2b:3c", ATTR{type}=="1", KERNEL=="eth*", NAME="eth0"
  9 
 10 # PCI device 0x8086:0x100f (e1000)
 11 SUBSYSTEM=="net", ACTION=="add", DRIVERS=="?*", ATTR{address}=="00:0C:29:29:85:84", ATTR{type}=="1", KERNEL=="eth*", NAME="eth0"
 12 
 13 # PCI device 0x8086:0x100f (e1000)
 14 #SUBSYSTEM=="net", ACTION=="add", DRIVERS=="?*", ATTR{address}=="00:0c:29:c7:e3:4c", ATTR{type}=="1", KERNEL=="eth*", NAME="eth1"

注释掉其最后一行名称为eth1的信息,同时将其中名称为eth0的网卡ATTR地址修改为ifconfig -a显示的MAC地址,重启。

【参考】
http://blog.csdn.net/cyuyan112233/article/details/6585680 vmware 下找不到ifcfg-eth0的问题

以上是关于VM克隆后找不到eth0的问题解决的主要内容,如果未能解决你的问题,请参考以下文章

VMware 克隆Linux后找不到eth0

VMware虚拟机克隆Linux系统后找不到eth0网卡

vm克隆虚拟机网络配置

虚拟机复制出现的网卡问题

mac上的xampp-vm在堆栈管理器中安装后找不到'/opt/lampp'目录

关于用VMware克隆linux系统后,无法联网找不到eth0网卡的问题