CentOS-6.4-x86_64系统
在VirtualBox中克隆系统时如果勾选了Reinitialize the MAC address of all network cards 的话,克隆的系统会产生新的MAC地址,但是网卡名子会是以前的,这样会出现问题,这时需要修改网卡名。
1、编辑配置文件:vim /etc/sysconfig/network-scripts/ifcfg-eth0
DEVICE=eth0 -- 将网卡名改为eth0
#HWADDR=08:00:27:42:7A:AA -- 如果开启一个网卡的话,这个可以注释掉,如果开启两个网卡的话需要写MAC地址
TYPE=Ethernet
#UUID=6d029e26-c0d6-4d2c-8f15-6c7dc013d364
ONBOOT=yes
NM_CONTROLLED=yes
BOOTPROTO=static
IPADDR=10.10.54.97 --修改IP地址
GATEWAY=10.10.54.254
NETMASK=255.255.255.0
---- 修改必要的参数
2、修改网卡文件: vim /etc/udev/rules.d/70-persistent-net.rules
SUBSYSTEM=="net", ACTION=="add", DRIVERS=="?*", ATTR{address}=="08:00:27:6d:58:09", ATTR{type}=="1", KERNEL=="eth*", NAME="eth0" --注释掉
# PCI device 0x8086:0x100e (e1000)
SUBSYSTEM=="net", ACTION=="add", DRIVERS=="?*", ATTR{address}=="08:00:27:2f:9a:8a", ATTR{type}=="1", KERNEL=="eth*", NAME="eth1" --注释掉
# PCI device 0x8086:0x100e (e1000)
SUBSYSTEM=="net", ACTION=="add", DRIVERS=="?*", ATTR{address}=="08:00:27:9c:10:d4", ATTR{type}=="1", KERNEL=="eth*", NAME="eth2" --将eth2改为eth0
# PCI device 0x8086:0x100e (e1000)
SUBSYSTEM=="net", ACTION=="add", DRIVERS=="?*", ATTR{address}=="08:00:27:e9:30:b3", ATTR{type}=="1", KERNEL=="eth*", NAME="eth3" -- 将eth3改为eth1
修改完后的结果:
#SUBSYSTEM=="net", ACTION=="add", DRIVERS=="?*", ATTR{address}=="08:00:27:6d:58:09", ATTR{type}=="1", KERNEL=="eth*", NAME="eth0"
# PCI device 0x8086:0x100e (e1000)
#SUBSYSTEM=="net", ACTION=="add", DRIVERS=="?*", ATTR{address}=="08:00:27:2f:9a:8a", ATTR{type}=="1", KERNEL=="eth*", NAME="eth1"
# PCI device 0x8086:0x100e (e1000)
SUBSYSTEM=="net", ACTION=="add", DRIVERS=="?*", ATTR{address}=="08:00:27:9c:10:d4", ATTR{type}=="1", KERNEL=="eth*", NAME="eth0"
# PCI device 0x8086:0x100e (e1000)
SUBSYSTEM=="net", ACTION=="add", DRIVERS=="?*", ATTR{address}=="08:00:27:e9:30:b3", ATTR{type}=="1", KERNEL=="eth*", NAME="eth1"
如果开启两个网卡的话,我们需要将这个文件中的MAC地址记录下来,写进/etc/sysconfig/network-scripts/ifcfg-eth0/1 中
重启网络服务
另一种解决方法:直接将/etc/udev/rules.d/70-persistent-net.rules删除掉,重启电脑后会产生一个新的这个文件。