VMWare changed my network device names!!!

Print Friendly, PDF & Email

So, you’ve built a nice little VMWare/ESX/vSphere machine (Linux specifically) and you copy it to another drive. The first time you start it up, VMWare asks you whether you ‘Moved’ or ‘Copied’ it. Being the honest guy that you are, you obviously say ‘I Copied It’. Bobs your uncle, your machine boots up and everything is fine. Uh, not quite ….

Most people will hardly notice the difference [especially Desktop users who use a DHCP assigned IP Address], but behind the scenes your network connections will have different names. eth0 would have became eth1 or eth2 and eth1 might have became eth3 [should you have more than one connection that is 😉 – the example below is based on a VM with two interfaces ]

The reason for this is the following:
When VMWare asked you whether you ‘Moved’ or ‘Copied’ the machine, it did so to determine whether your MAC addresses should stay the same or whether new ones should be generated which are unique (on some VERY large networks, you might have duplicates…but the odds of that is about the same as winning the Euro Millions). When Ubuntu (or whatever flavour of Linux you are running) boots up with the new MAC addresses, it does not recognize it as the MAC’s that were previously used and as such the NIC(s) are assigned new names, e.g. eth1 where it always was eth0.

How do you change this back to what you want? Actually quite simple.
In the terminal:

Go to the /etc/udev/rules.d directory

cd /etc/udev/rules.d

Edit 70-persistent-net.rules

vim 70-persistent-net.rules

You should see something as follows:

# 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.
 
# PCI device 0x1022:0x2000 (pcnet32)
SUBSYSTEM=="net", ACTION=="add", DRIVERS=="?*", ATTR{address}=="00:0c:29:da:c8:7e", ATTR{type}=="1", KERNEL=="eth*", NAME="eth1"
 
# PCI device 0x1022:0x2000 (pcnet32)
SUBSYSTEM=="net", ACTION=="add", DRIVERS=="?*", ATTR{address}=="00:0c:29:da:c8:74", ATTR{type}=="1", KERNEL=="eth*", NAME="eth0"
 
# PCI device 0x1022:0x2000 (vmxnet)
SUBSYSTEM=="net", ACTION=="add", DRIVERS=="?*", ATTR{address}=="00:0c:29:28:3d:22", ATTR{type}=="1", KERNEL=="eth*", NAME="eth2"
 
# PCI device 0x1022:0x2000 (vmxnet)
SUBSYSTEM=="net", ACTION=="add", DRIVERS=="?*", ATTR{address}=="00:0c:29:28:3d:2c", ATTR{type}=="1", KERNEL=="eth*", NAME="eth3"

As you can see, there are still references to eth0 and eth1, although my current VM is only allowing me to use eth2 and eth3.

To fix this, comment out the first two entries as shown, and then modify the second two entries to state eth0 and eth1 respectively (Look at the ‘name’ attribute of each entry).

# 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.
 
# PCI device 0x1022:0x2000 (pcnet32)
# SUBSYSTEM=="net", ACTION=="add", DRIVERS=="?*", ATTR{address}=="00:0c:29:da:c8:7e", ATTR{type}=="1", KERNEL=="eth*", NAME="eth1"
 
# PCI device 0x1022:0x2000 (pcnet32)
# SUBSYSTEM=="net", ACTION=="add", DRIVERS=="?*", ATTR{address}=="00:0c:29:da:c8:74", ATTR{type}=="1", KERNEL=="eth*", NAME="eth0"
 
# PCI device 0x1022:0x2000 (vmxnet)
SUBSYSTEM=="net", ACTION=="add", DRIVERS=="?*", ATTR{address}=="00:0c:29:28:3d:22", ATTR{type}=="1", KERNEL=="eth*", NAME="eth0"
 
# PCI device 0x1022:0x2000 (vmxnet)
SUBSYSTEM=="net", ACTION=="add", DRIVERS=="?*", ATTR{address}=="00:0c:29:28:3d:2c", ATTR{type}=="1", KERNEL=="eth*", NAME="eth1"

That should do it. I would recommend restarting your machine after doing this. If you have manually set-up connections, also remember to modify your /etc/network/interfaces file to comply with your new settings.

If this is a bit confusing, feel free to state so in the comments section below and I’ll try to explain in a different way.

P.S.
I haven’t tested this on Oracle VirtualBox or XEN, but I wouldn’t be surprised it the same thing happens there.

1 comment

  1. After coming accross this again, I thought I’d share another way…

    You can simply remove (or backup if you’re peculiar about these things) the /etc/udev/rules.d/70-persistent-net.rules file and reboot the machine.

    A new file will be generated and interface names will start at eth0 again.

Leave a Reply

Your email address will not be published. Required fields are marked *

This site uses Akismet to reduce spam. Learn how your comment data is processed.