您的位置:首页 > 运维架构 > Linux

VMware克隆Linux系统后网卡无法启动

2016-05-26 19:02 666 查看
克隆linux系统后,克隆版无法启动网卡,提示错误:
device eth0 does not seem to be present,delaying initialization
原因分析: Linux使用udev动态管理设备文件。VMware会自动生成虚拟机的mac地址。这样,由于克隆出的Linux已经记录了原Linux的网卡mac地址对应于网卡eth0,在克隆出的Linux中由于mac地址发生改变,udev会自动将该mac对应于网卡eth1,以此类推。而其实kernel仅仅只识别到一张网卡,跟网卡名相关的网络配置也未发生任何变化。
解决方案:
udev将mac与网卡名称的对应关系保存在/etc/udev/rules.d/70-persistent-net.rules中,
记录下新的网卡MAC地址和NAME。
[root@bright ~]# cat /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:5f:88:bd", ATTR{type}=="1", KERNEL=="eth*", NAME="eth0"

# PCI device 0x8086:0x100f (e1000)
SUBSYSTEM=="net", ACTION=="add", DRIVERS=="?*", ATTR{address}=="00:0c:29:b6:87:56", ATTR{type}=="1", KERNEL=="eth*", NAME="eth1"
修改网卡配置文件:
修改DEVICE,HWADDR,IPADDR三行。
[root@bright ~]# vi /etc/sysconfig/network-scripts/ifcfg-eth0 //网卡配置文件
DEVICE=eth1 #修改为新的NAME ,ifconfig查看发现会变成eth1
HWADDR=00:0C:29:b6:87:56 #用新的MAC替换
TYPE=Ethernet
UUID=fa6bcd84-01ab-4b2d-9dd6-8d4a3a1961ac
ONBOOT=yes
NM_CONTROLLED=yes
BOOTPROTO=static
IPADDR=192.168.1.56 #修改IP(如果原虚拟机不同时运行,可以不修改)
NETMASK=255.255.255.0
GATEWAY=192.168.1.1
重启网卡即可:

[root@bright ~]# service network restart
方法二:类似于上文
删除/etc/udev/rules.d/70-persistent-net.rules中含有eth0的行,修改eth1为eth0 。
再修改网卡配置文件的HWADDR行即可。

原文地址http://www.myhack58.com/Article/48/67/2015/60509.htm,稍微感动一下。
内容来自用户分享和网络整理,不保证内容的准确性,如有侵权内容,可联系管理员处理 点击这里给我发消息