I’m quite busy with VMware these days. I actually believe VMware’s dogma “the virtual machine is more robust and qualitatively better than the physical machine” is correct.
However, after installing two VM’s running Ubuntu Linux to do some failover testing, I noticed something odd about the numbering of the network interfaces. Good old eth0 was missing. Instead, there was an eth1 present…
Now I had this issue in the past, but always worked around it by just using eth1 instead of eth0. But maybe it would be better to find out about this and fix it “the right way”.
The problem is caused by the copying of the virtual machines. I have a VM template which I use as a base image. I then copy and customise this image when I need to implement new VM’s. The process goes like this:
- You copy your VM and maybe change its configuration.
- Boot the VM. VMWare (server at least) will then ask you whether you copied or changed the VM. This is because the system needs to know whether or not to assign a new GUID to the VM you created. Since this is a new VM derived from a template, of course we will choose ‘I copied this VM’ in order to get a new GUID. Nothing new so far…
- Here it goes wrong: the VM boots but (one time only) the MAC address of all its network interfaces is changed. This is of course necessary to prevent multiple VM’s (derived from the same template) having the same MAC address. Ubuntu detects that its previous (pre-copy) network interface no longer exists and assigns a new device name to the NIC because of the changed mac-address.
This is handled by the UDEV system. Ubuntu will actually record the mac address of every network interface and use this information to make sure that every device always gets assigned the same interface name. So in fact, eth0 will always be bound to the same mac address. However, this system is what’s causing us trouble in this case.
Luckily, this is easily remedied. Several sources on the internet mention editing the /etc/iftab file but this must be for older Ubuntu versions since I could find neither this file nor its man page. Creating the file wit the correct contents also has no effect.
In fact it is necessary tochange the udev rules for persistent naming of network devices (whoa!).
This is easier than you might fear. Have a look ath the 70-persistent-net.rules fiile in the /etc/udev/rules.d folder:
root@ubuntu:/etc/udev/rules.d# ls -l 70-persistent-net.rules -rw-r--r-- 1 root root 375 2008-11-19 03:44 70-persistent-net.rules
The following are the contents of this file after I modified it:
# 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:e8:3b:ac", ATTR{type}=="1", KERNEL=="eth*", NAME="eth0"
It’s clear what needs to be done: before changing this file, it had two entries. One (eth0) for the old NIC, and a new one (eth1) for the ‘new’ NIC. I just removed the old entry and renamed the device name (eth1) for the new entry to eth0.
Alternatively, you could delete the new entry and change the mac address for the old entry to your new mac address.