前往小程序,Get更优阅读体验!
立即前往
首页
学习
活动
专区
工具
TVP
发布
社区首页 >专栏 >VM克隆后找不到eth0的问题解决

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

作者头像
编程随笔
发布2019-09-11 16:11:29
7000
发布2019-09-11 16:11:29
举报
文章被收录于专栏:后端开发随笔

问题描述

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

代码语言:javascript
复制
[root@centos65x64 ~]# 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)

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

代码语言:javascript
复制
[root@centos65x64 ~]# 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
[root@centos65x64 ~]#

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

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

代码语言:javascript
复制
[root@centos65_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)

[root@centos65_x64_Logstash ~]# 

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

代码语言:javascript
复制
[root@centos65x64 ~]# 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
[root@centos65x64 ~]#

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

代码语言:javascript
复制
[root@centos65x64 ~]# 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地址。

代码语言:javascript
复制
[root@centos65x64 ~]# 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

第二步:修改网卡信息

代码语言:javascript
复制
[root@centos65x64 ~]# 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的问题

本文参与 腾讯云自媒体同步曝光计划,分享自作者个人站点/博客。
原始发表:2018-01-09 ,如有侵权请联系 cloudcommunity@tencent.com 删除

本文分享自 作者个人站点/博客 前往查看

如有侵权,请联系 cloudcommunity@tencent.com 删除。

本文参与 腾讯云自媒体同步曝光计划  ,欢迎热爱写作的你一起参与!

评论
登录后参与评论
0 条评论
热度
最新
推荐阅读
目录
  • 问题描述
  • 解决方案
领券
问题归档专栏文章快讯文章归档关键词归档开发者手册归档开发者手册 Section 归档