转:linux系统的vm克隆后启动找不到网卡的问题

现象:
一台克隆生成的centos,启动后使用ifconfig查看网络信息,发现只有lo而没有任何可用网卡.

使用ifup eth0后报vmware device eth0 does not seem to be present delaying initialization
大概意识是找不到eth0这个网络设备

使用
ls /sys/class/net
查看物理网卡信息返回结果如下:
eth1 lo


原因:

很多Linux distribution使用udev动态管理设备文件,并根据设备的信息对其进行持久化命名。例如在 

Debian etch中,udev会在系统引导的过程中识别网卡,将mac地址和网卡名称对应起来记录在udev的规则  脚本中。而VMware会自动生 成虚拟机的mac地址。这样,由于基本系统的虚拟机已经记录了该虚拟机的网  卡mac地址对应于网卡eth0,在克隆出的虚拟机中由于mac地址发生改 变,udev会自动将该mac对应于网  卡eth1。以此类推,udev会记录所有已经识别的mac与网卡名的关系,所以每次克隆网卡名称会自动加1,  而其 实kernel仅仅只识别到一张网卡,跟网卡名相关的网络配置也未发生任何变化。 

解决方法:

编辑如下文件
/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 0x15ad:0x07b0 (vmxnet3) (custom name provided by external tool)
SUBSYSTEM=="net", ACTION=="add", DRIVERS=="?*", ATTR{address}=="00:50:56:bc:00:45", ATTR{type}=="1", KERNEL=="eth*", NAME="eth0"

# PCI device 0x15ad:0x07b0 (vmxnet3)
SUBSYSTEM=="net", ACTION=="add", DRIVERS=="?*", ATTR{address}=="00:50:56:bc:00:46", ATTR{type}=="1", KERNEL=="eth*", NAME="eth1"


注释掉eth0的那个段落,然后将eth1的修改为eth0

修改网卡配置文件
/etc/sysconfig/network-scripts/ifcfg-eth0

把mac地址修改为eth1的地址
HWADDR字段

重启后生效
源地址:http://220071.blog.51cto.com/210071/1094077
  • 0
    点赞
  • 0
    收藏
    觉得还不错? 一键收藏
  • 0
    评论
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值