after cloning a VMWare image I had noticed that my CentOS Linux server renamed eth0 as eth1, eth1 as eth2 and so on. This is due to wrong or duplicate mac address. To fix this problem login to your CentOS Linux server using console and type the following commands:
solution:
1、
[root@localhost rules.d]# ls
40-hplip.rules 69-vmware-vmmouse.rules 90-hal.rules
56-hpmud_support.rules 70-cups-libusb.rules 91-drm-modeset.rules
60-fprint-autosuspend.rules 70-persistent-cd.rules 98-kexec.rules
60-pcmcia.rules 70-persistent-net.rules 99-fuse.rules
60-raw.rules 90-alsa.rules 99-vmware-scsi-udev.rules
[root@localhost rules.d]# vi 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 0x1022:0x2000 (pcnet32) (custom name provided by external tool)
# PCI device 0x1022:0x2000 (vmxnet) (custom name provided by external tool)
SUBSYSTEM=="net", ACTION=="add", DRIVERS=="?*", ATTR{address}=="00:0c:29:8c:cc:4f", ATTR{type}=="1", KERNEL=="eth*", NAME="eth0"
================================================================================================
将上面的从
# PCI device 0x1022:0x2000 (pcnet32) (custom name provided by external tool)
开始的内容,包含下面所有的
# PCI device 0x1022:0x2000 (vmxnet) (custom name provided by external tool)
SUBSYSTEM=="net", ACTION=="add", DRIVERS=="?*", ATTR{address}=="00:0c:29:8c:cc:4f", ATTR{type}=="1", KERNEL=="eth*", NAME="eth0"
内容删除
保存退出。
2、
[root@localhost rules.d]# ifconfig
eth0 Link encap:Ethernet HWaddr 00:0C:29:8C:CC:4F
inet addr:192.168.10.20 Bcast:192.168.10.255 Mask:255.255.255.0
inet6 addr: fe80::20c:29ff:fe8c:cc4f/64 Scope:Link
UP BROADCAST RUNNING MULTICAST MTU:1500 Metric:1
RX packets:481 errors:0 dropped:0 overruns:0 frame:0
TX packets:192 errors:0 dropped:0 overruns:0 carrier:0
collisions:0 txqueuelen:1000
RX bytes:37364 (36.4 KiB) TX bytes:27055 (26.4 KiB)
Interrupt:19 Base address:0x2024
[root@localhost ~]# vi /etc/sysconfig/network-scripts/ifcfg-eth0
DEVICE="eth0"
# HWADDR="00:0C:29:C6:16:5D"
HWADDR="00:0C:29:8C:CC:4F"
注意将两处蓝色的地址保存成一致的,然后reboot你的系统就可以将eth1修改成你想设置的名称了
==============================================================
以上内容也适用于修改网卡名称的需求!