If you’re looking to copy an Ubuntu virtual machine to make a clone, you’re going to run into an issue with any network interface you may have attached.

The issue stems down to how Ubuntu handles hardware. It automagically picks up new interfaces based on their MAC (hardware) address. When you copy (not move) a VM in VMWare ESXi (and most other variations), VMWare smartly assigns a new MAC to the network interface(s). That being said, Ubuntu detects this as an addition of hardware, rather than a change.

Every interface will be assigned a new eth #. So if you have eth0 and eth1 before copying, you’ll have eth2 and eth3 following the copy.
Rather than having to deal with these new interface names, we can actually change them. You’ll need to edit the following file as root:

/etc/udev/rules.d/70-persistent-net.rules

You should see twice as many network interfaces as you have before. In my example, my VM only had one interface so it looked like this:

# 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)
SUBSYSTEM=="net", ACTION=="add", DRIVERS=="?*", ATTR{address}=="00:0c:29:cd:e3:3d", ATTR{dev_id}=="0x0", ATTR{type}=="1", KERNEL=="eth*", NAME="eth0"
# PCI device 0x1022:0x2000 (pcnet32)
SUBSYSTEM=="net", ACTION=="add", DRIVERS=="?*", ATTR{address}=="00:0c:29:1e:17:68", ATTR{dev_id}=="0x0", ATTR{type}=="1", KERNEL=="eth*", NAME="eth1"

As you can see, Ubuntu now thinks that there are two devices. To fix this, simply comment out the first SUBSYSTEM line and edit the other to reflect the old interface name like this:

# PCI device 0x1022:0x2000 (pcnet32)
#SUBSYSTEM=="net", ACTION=="add", DRIVERS=="?*", ATTR{address}=="00:0c:29:cd:e3:3d", ATTR{dev_id}=="0x0", ATTR{type}=="1", KERNEL=="eth*", NAME="eth0"
# PCI device 0x1022:0x2000 (pcnet32)
SUBSYSTEM=="net", ACTION=="add", DRIVERS=="?*", ATTR{address}=="00:0c:29:1e:17:68", ATTR{dev_id}=="0x0", ATTR{type}=="1", KERNEL=="eth*", NAME="eth0"

Once you have made your required changes, simply close and save the file and reboot your VM.

reboot

And to check your work:

ifconfig -a

You should now see your network interfaces with proper names!

Sorry, comments are closed.