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:
# cd /etc/udev/rules.d
# cp 70-persistent-net.rules /root/
# rm 70-persistent-net.rules
# reboot
This file was automatically generated by the /lib/udev/write_net_rules program, run by the persistent-net-generator.rules rules file. Simple delete it and reboot the system to recreate the same. This should fix the problem:
# /sbin/ifconfig | grep "^eth"
Sample outputs:
eth0 Link encap:Ethernet HWaddr 00:0C:29:F3:E4:14 eth1 Link encap:Ethernet HWaddr 00:0C:29:F3:E4:1E
You need to remove the MAC address in /etc/sysconfig/networking-scripts/ifcfg-eth*. To find out current MAC address, enter:
# ifconfig -a | grep eth1 | grep HWaddr | awk '{ print $5}'
# ifconfig -a | grep eth2 | grep HWaddr | awk '{ print $5}'
Update your /etc/sysconfig/networking-scripts/ifcfg-eth0 with eth1 HWaddr (MAC address), enter:
# cat /etc/sysconfig/networking-scripts/ifcfg-eth0
Sample outputs:
DEVICE="eth0" BOOTPROTO="dhcp" NM_CONTROLLED="yes" ONBOOT="yes" HWADDR="00:0C:29:69:0C:4A"
Save and close the file. Restart the network service, enter:
# service network restart
You can verify new settings with the following commands:
# /sbin/ifconfig -a
# route -n
More About udev
udev is the device manager for the Linux kernel series 2.6.xx. udev loads all modules asynchronously in a different order. This can result in devices randomly switching names. My guess is my network card switched names or renamed eth0 and eth1 as eth1 and eth2.
- 30 Handy Bash Shell Aliases For Linux / Unix / Mac OS X
- Top 30 Nmap Command Examples For Sys/Network Admins
- 25 PHP Security Best Practices For Sys Admins
- 20 Linux System Monitoring Tools Every SysAdmin Should Know
- 20 Linux Server Hardening Security Tips
- Linux: 20 Iptables Examples For New SysAdmins
- Top 20 OpenSSH Server Best Security Practices
- Top 20 Nginx WebServer Best Security Practices
- 20 Examples: Make Sure Unix / Linux Configuration Files Are Free From Syntax Errors
- 15 Greatest Open Source Terminal Applications Of 2012

- My 10 UNIX Command Line Mistakes
- Top 10 Open Source Web-Based Project Management Software
- Top 5 Email Client For Linux, Mac OS X, and Windows Users
- The Novice Guide To Buying A Linux Laptop



![HowTo: Wake Up Computers Using Linux Command [ Wake-on-LAN ( WOL ) ]](http://s0.cyberciti.org/images/rp/1/30.jpg)








{ 15 comments… read them below or add one }
Nice topic.
I faced this problem before, but I solve when I change old mac address with new MAC I get from VMWare inside “70-persistent-net.rules” file.
affirmative
removing /etc/udev/rules.d/cp 70-persistent-net.rules worked for me
thanks
Thanks for this, resolved my issue after some head scratching, also note this bug here: https://bugzilla.redhat.com/show_bug.cgi?id=493995 which claims this is/was an anaconda bug, and should be resolved in later versions.
Saved me a lot of work. Thanks for the article!
This can be easily fix with this kind of script :
# Annoying bug in vmware guest centos6 # eth0 doesn't exist ifconfig eth0 2>/dev/null >/dev/null if [ $? -ne 0 ] ; then # Rename eth1 with eth0 echo "UDEV Config..." rm /etc/udev/rules.d/70-persistent-net.rules # Change ifcfg-eth0 with hostname address (in /etc/hosts) echo "Changing eth0 address..." mac=`ifconfig eth1 | grep eth1 | awk '{ print $5}'` hostname=`hostname` ip=`grep $hostname /etc/hosts|cut -s -f 1` rm -f /etc/sysconfig/network-scripts/ifcfg-eth1 cfg=`grep -v IPADDR /etc/sysconfig/network-scripts/ifcfg-eth0 |grep -v HWADDR` echo "$cfg" > /etc/sysconfig/network-scripts/ifcfg-eth0 echo "HWADDR=\"$mac\"" >> /etc/sysconfig/network-scripts/ifcfg-eth0 echo "IPADDR=\"$ip\"" >> /etc/sysconfig/network-scripts/ifcfg-eth0 # Apply changes echo "Applying changes..." service network stop service NetworkManager stop ifconfig eth1 down udevadm trigger udevadm control --reload-rules service network start service NetworkManager start fi I had it in a .conf file /etc/init/. I hope it helps...It helps for sure…
Just installed ur script in a template and called by /etc/rc.d/rc.local !
works perfectly when deploying a new VM. Your script is really helpfull thanks a lot ! great stuff… :-)
BTW Nixcraft when you say “My guess is my network card switched names or renamed eth0 and eth1 as eth1 and eth2.”
Wrong guess, it’s because of VmWare reassigning new mac address to your clone… then udev create a new rule so eth0 always end as eth1 in your clone.
Martin Allert go it right about deleting mac address reference in template. It’s the way to workaround and fix this problem.
I still don’t understand why Redhat still bind mac address to ethernet card … can’t work at all in a virtual environment as hypervisor deciding about hardware stuff!
And nowadays 70% more Linux servers are virtual… go figure !
My problem is:
When I clone a new VM from a template, I get a eth1 despite the fact firstboot is presenting a eth0 for initial configuration.
The solution is:
Delete the HWADDR or MAC adresse from /etc/sysconfig/network-scripts/ifcfg-eth0 in the template. After a reboot, firstboot comes up and correctly configures a eth0.
good information.
Sweet! Thank you, it actually worked (with the sudo).
# cd /etc/udev/rules.d
# cp 70-persistent-net.rules /root/
# rm 70-persistent-net.rules
# reboot
I have the same problem, I have done all the steps form the top to reboot,
but to check when used grep command i could not see other eth ports or MAC address, I think at least I should see 2 mac addresses after reboot. where may i have gone wrong?
Hey,
thanks it was usefull. But with some bad coding:)
first:
# cd /etc/udev/rules.d
# mv 70-persistent-net.rules /root/
# reboot
second:
# ifconfig eth1 | awk ‘/HWaddr/ { print $5}’
Thanks a lot for your helpful post :)
I perfected the whole process ;)
# mv /etc/udev/rules.d/70-persistent-net.rules /root/
Remove MAC-address from the following files
# nano /etc/sysconfig/network-scripts/ifcfg-eth0
# nano /etc/sysconfig/network-scripts/ifcfg-eth1
# reboot
This is a great article!!
On red hat 5 & 6 it works removing the /etc/udev/rules.d/70-persistent-net.rules files and removing the mac address from the ifcfg-ethX files. This is done on the original machine to prevent the future clone to create a new ifcfg-ethY
Any Idea on how does it work with suse ?