VMCentos克隆后致MAC重复故障解决

软件环境:centos 6.4_x86_64bit

故障描述:

Vmware虚拟机软件克隆一个centos后,克隆后的系统mac地址与被克隆系统重复导致克隆的虚拟机网络故障,解决办法如下。

原因分析:

很多Linux distribution使用udev动态管理设备文件,并根据设备的信息对其进行持久化命名。udev会在系统引导的过程中识别网卡,将mac地址和网卡名称对应起来记录在udev的规则脚本中。而VMware会自动生成虚拟机的mac地址。这样,由于基本系统的虚拟机已经记录了该虚拟机的网卡mac地址对应于网卡eth0,在克隆出的虚拟机中由于mac地址发生改变,udev会自动将该mac对应于网卡eth1。以此类推,udev会记录所有已经识别的mac与网卡名的关系,所以每次克隆网卡名称会自动加1,而其实kernel仅仅只识别到一张网卡,跟网卡名相关的网络配置也未发生任何变化。

  原因分析来自一网友

故障解决:

操作前备份:

cp /etc/udev/rules.d/70_persistent-net.rules  /etc/udev/rules.d/70-persistent-net.rules.bak

故障解决前文件内容为:

1[root@yuanC6~]# vi /etc/udev/rules.d/70-persistent-net.rules

# This file wasautomatically generated by the /lib/udev/write_net_rules

# program, runby the persistent-net-generator.rules rules file.

#

# You can modifyit, as long as you keep each rule on a single

# line, andchange only the value of the NAME= key.

# PCI device0x8086:0x100f (e1000)

SUBSYSTEM=="net",ACTION=="add", DRIVERS=="?*",ATTR{address}=="00:0c:29:87:5d:83", ATTR{type}=="1",KERNEL=="eth*", NAME="eth0" ###注释这是错误内容,删除该行。

# PCI device0x8086:0x100f (e1000)

SUBSYSTEM=="net",ACTION=="add", DRIVERS=="?*", ATTR{address}=="00:0c:29:7d:ee:c4",ATTR{type}=="1", KERNEL=="eth*", NAME="eth1"   ###注释把前面的eth1改为0,因为我使用的是eth0所以这里改为0,强调要改为你要使用的网卡号

2:

[root@yuanC6 ~]#vi /etc/sysconfig/network-scripts/ifcfg-eth0

DEVICE=eth0

TYPE=Ethernet

UUID=0c65414f-4fac-4719-863f-8b1ee1a4ccf3

ONBOOT=yes

NM_CONTROLLED=yes

BOOTPROTO=none

HWADDR=00:0c:29:7d:ee:c4###注释修改此处的mac地址要和步一中的红色mac一样。

IPADDR=192.138.1.61

PREFIX=24

GATEWAY=192.138.1.1

DNS1=202.101.224.68

DEFROUTE=yes

IPV4_FAILURE_FATAL=yes

IPV6INIT=no

NAME="Systemeth0"

NETMASK=255.255.255.0

USERCTL=no

3

完成前几步后,重启服务器即可。

故障解决后文件内容为:注意粉红色底纹部分

[root@yuanC6 ~]#cat /etc/udev/rules.d/70-persistent-net.rules

# This file wasautomatically generated by the /lib/udev/write_net_rules

# program, runby the persistent-net-generator.rules rules file.

#

# You can modifyit, as long as you keep each rule on a single

# line, andchange only the value of the NAME= key.


# PCI device0x8086:0x100f (e1000)

SUBSYSTEM=="net",ACTION=="add", DRIVERS=="?*", ATTR{address}=="00:0c:29:7d:ee:c4",ATTR{type}=="1", KERNEL=="eth*", NAME="eth0"  

[root@yuanC6 ~]#cat /etc/sysconfig/network-scripts/ifcfg-eth0

DEVICE=eth0

TYPE=Ethernet

UUID=0c65414f-4fac-4719-863f-8b1ee1a4ccf3

ONBOOT=yes

NM_CONTROLLED=yes

BOOTPROTO=none

HWADDR=00:0c:29:7d:ee:c4

IPADDR=192.138.1.61

PREFIX=24

GATEWAY=192.138.1.1

DNS1=202.101.224.68

DEFROUTE=yes

IPV4_FAILURE_FATAL=yes

IPV6INIT=no

NAME="Systemeth0"

NETMASK=255.255.255.0

USERCTL=no

或参考我老师博客老师的总结:http://oldboy.blog.51cto.com/2561410/1363853