VMWare Image Clone Problem: eth0 Renamed As eth1

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:


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.

๐Ÿง Get the latest tutorials on Linux, Open Source & DevOps via RSS feed or Weekly email newsletter.

๐Ÿง 24 comments so far... add one
CategoryList of Unix and Linux commands
Disk space analyzersncdu pydf
File Managementcat
FirewallAlpine Awall CentOS 8 OpenSUSE RHEL 8 Ubuntu 16.04 Ubuntu 18.04 Ubuntu 20.04
Network UtilitiesNetHogs dig host ip nmap
OpenVPNCentOS 7 CentOS 8 Debian 10 Debian 8/9 Ubuntu 18.04 Ubuntu 20.04
Package Managerapk apt
Processes Managementbg chroot cron disown fg jobs killall kill pidof pstree pwdx time
Searchinggrep whereis which
User Informationgroups id lastcomm last lid/libuser-lid logname members users whoami who w
WireGuard VPNAlpine CentOS 8 Debian 10 Firewall Ubuntu 20.04
24 comments… add one
  • Sudanking Jul 11, 2011 @ 12:12

    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.

  • less Nov 16, 2011 @ 19:17

    removing /etc/udev/rules.d/cp 70-persistent-net.rules worked for me


  • Buzz Jan 4, 2012 @ 11:42

    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.

  • Andreas Feb 12, 2012 @ 18:25

    Saved me a lot of work. Thanks for the article!

  • denicfr Apr 30, 2012 @ 10:42

    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}'`
            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
    I had it in a .conf file /etc/init/.
    I hope it helps...
    • PatLh Mar 10, 2013 @ 4:07

      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 !

    • LinuxGuy Sep 25, 2015 @ 20:00

      Thanks for the help, I tweaked it a bit.

      #! /bin/sh
      # Make sure user running this script is root
      if [ `id -u` != "0" ]
      	echo "You must be root"
      #Checking for rules file
      if [ -e "/etc/udev/rules.d/70-persistent-net.rules" ]
      echo "NetworkManager found"
      echo "NetworkManager not found"
      echo Re-enumerating the network interfaces...
      # Stop networking
      service network stop
      #  ERROR
      # Get the drivers and bounce the NICs
      lspci -nnv | awk '{
      if ($0 ~ /~$/) { getDriver = 0; }
      if (getDriver == 0 && $0 ~ /.*Ethernet controller.*/) { getDriver=1; }
      if (getDriver == 1 && $0 ~ /.*Kernel driver.*/) { printf ("%sn", $5); }
      }' | sort | uniq | while read a; do
      echo Unloading network module $a from kernel space
      rmmod $a
      # Remove the static enumerations
      rm -fv /etc/udev/rules.d/70-persistent-net.rules
      # Remove UUID from ifcfg files
      sed -i /^UUID/d /etc/sysconfig/networking/devices/ifcfg-eth*
      sed -i /^UUID/d /etc/sysconfig/network-scripts/ifcfg-eth*
      # Remove HWADDR from ifcfg files
      sed -i /^HWADDR/d /etc/sysconfig/networking/devices/ifcfg-eth*
      sed -i /^HWADDR/d /etc/sysconfig/network-scripts/ifcfg-eth*
      echo Reloading driver via udev
      # Tickle udev
      /sbin/udevadm trigger
      /sbin/udevadm control --reload-rules
      # Restart networking
      echo "Please wait..."
      service NetworkManager restart
      sleep 10;
      service network restart
      echo "NOTES: 1) If you run system-config-network-tui"
      echo "          Open each NIC and save to automatically add current HWADDR to ifcfg"
      echo "       2) If you run nm-connection-editor"
      echo "          Open each nic and save to automatically add current UUID to ifcfg"
      echo "Network repair is complete..above options are supplemental"
  • Martin Allert Jun 18, 2012 @ 8:42

    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.

  • venkat Jul 3, 2012 @ 11:40

    good information.

  • eiger3970 Jul 29, 2012 @ 1:08

    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

  • toughdeep Oct 16, 2012 @ 16:15

    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?

  • battila.hu Nov 7, 2012 @ 16:12


    thanks it was usefull. But with some bad coding:)


    # cd /etc/udev/rules.d
    # mv 70-persistent-net.rules /root/
    # reboot


    # ifconfig eth1 | awk ‘/HWaddr/ { print $5}’

  • maryam Nov 19, 2012 @ 11:43

    Thanks a lot for your helpful post ๐Ÿ™‚

  • blogo Nov 30, 2012 @ 8:22

    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

  • Herms Mar 5, 2013 @ 18:55

    This is a great article!!

  • Tris Apr 30, 2013 @ 16:20

    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 ?

  • Andrea Nov 26, 2013 @ 18:09

    Thank you mate.. ๐Ÿ™‚

  • Carl May 29, 2014 @ 22:20

    I was trying to copy a VM that contained a snapshot, evidently there is extra path and file name info in there, which presents a problem because snapshots may be more than 2GB:
    grep -n GameServer1 UDB1-Snapshot1.vmsn
    11495040:nvram = “GameServer1.nvram”
    11495057:displayName = “GameServer1”
    11495058:extendedConfigFile = “GameServer1.vmxf”
    11495074:scsi0:0.fileName = “GameServer1.vmdk”
    11495088:sched.swap.derivedName = “/vmfs/volumes/5321bbd3-ad5bdbf5-9ec4-f01fafd599b9/GameServer1/GameServer1-25db7aa3.vswp”

    I was able to copy this too using the sed utility after inflating the snapshot:
    cat path/GameServer1-Snapshot1.vmsn |sed ‘s/GameServer1/UDB1/g’ > path/UDB1-Snapshot1.vmsn

    This may take a long time depending on the file size. All the other files I had copied normally and edited using vim. Hope this helps.

  • Peter Aug 25, 2014 @ 9:16

    Thank you!

    Saved me a lot of Time!!

  • Rune Stoknes Aug 7, 2015 @ 8:15

    Excellent post!
    I’m a Linux noob but have to manage and clone some of our vitual Linux servers from time to time – that’s when I faced this issue.
    Played around with system-config-network and added the new ethX adapter (showd up as eth5 in ifconfig) – and that would actually give me network connectivity – but doing it your way also gives the Network Manager full control of the NIC / displays correctly in the GUI.
    Thanks for sharing!


  • Kent Rubin Aug 13, 2015 @ 15:23

    Thank you! This did the trick!

  • Hongchol Oct 24, 2015 @ 0:36

    Excellent post. Resolved my VM problem. Thanks.

  • Ammar May 9, 2016 @ 10:55

    I had the same issue go though different forums but cant fix it..
    I follow a hit and trial ….
    Clone the VM without LAN card .. remove from the edit setting while clonning..
    then after clone i found no lan card in the edit setting and also verify from ifconfig -a
    note the MAC address by adding new nic and change the one at the vi /etc/sysconfig/network-scripts/ifcfg-eth0 by the new MAC address.

    same and assign new ip address from the SETUP and issue resolved…


  • Gonzalo Feb 15, 2017 @ 12:59

    Delete UUID y MAC from ifcfg-eth0 script

    #rm โ€“f /etc/udev/rules.d/70-persistent-net.rules
    #vim /etc/sysconfig/network-scripts/ifcfg-eth0
    #ip link set eth1 name eth0
    # /etc/init.d/network restart

Leave a Reply

Your email address will not be published.

Use HTML <pre>...</pre> for code samples. Still have questions? Post it on our forum