复制的虚拟机 ,找不到网卡eth0了,可能会有其他网卡生效,设置eth0生效

配置好的Vmware vmdk,在其他电脑上用使用,会出现一个问题--找不到网卡eth0了,

  原因是Vmware保存的硬件配置文件*.vmx里记录了网卡的MAC地址,而linux也会记录MAC地址,这样在克隆虚拟机的时 候,Vmware会为Ubuntu分配一个新的eth0网卡,但是由于被之前的eth0占用,所以它会变成eth1。再因为eth0是默认的网卡,显然这 个网卡不存在,所以就提示"No such device eth0"..

  linux保存MAC地址的配置文件为"/etc/udev/rules.d/70-persistent-net.rules",

  方法1:直接删除配置文件

  (1)直接删除配置文件,重启之后就会找到新的网卡了。

  sudo rm /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.


# PCI device 0x8086:0x100f (e1000)
SUBSYSTEM=="net", ACTION=="add", DRIVERS=="?*", ATTR{address}=="00:0c:29:06:05:9c", ATTR{type}=="1", KERNEL=="eth*", NAME="eth0"

 (2)查看/etc/sysconfig/network-scripts/ifcfig-eth0,发现内容为空.按以下格式进行编辑,保存即可

  

DEVICE="eth0"
BOOTPROTO=none
IPV6INIT="yes"
NM_CONTROLLED="yes"
ONBOOT="yes"
TYPE="Ethernet"
UUID="417c1f34-c45b-4a4f-b605-c9d33a6d915d"
IPADDR=192.168.137.103
PREFIX=24
GATEWAY=192.168.137.2
DNS1=192.168.137.2
DEFROUTE=yes
IPV4_FAILURE_FATAL=yes
IPV6_AUTOCONF=yes
IPV6_DEFROUTE=yes
IPV6_FAILURE_FATAL=no
NAME="System eth0"
HWADDR=00:0c:29:06:05:9c
IPV6_PEERDNS=yes
IPV6_PEERROUTES=yes
LAST_CONNECT=1468827041

  此处的MAC即为修改/etc/udev/rules.d/70-persistent-net.rules 中的MAC

  

你可能感兴趣的:(linux)