I've run into the following problem on both VMware Fusion (for Macs) and with VMware ESXi/vSphere. Many of you are familiar with the problem, and it is described at VMware KB: "Networking does not work in a cloned Linux virtual machine (2002767) ."
- Create a CentOS VM.
- This is a bare-bones VM with a minimal set of software and a functioning network stack. The idea is that we take the minimal VM, clone it and add more software later.
- Clone that VM
- VMware Fusion or vCenter will assign a new MAC address to the network interface on the cloned VM.
- Linux doesn't know about this new MAC address and thus networking doesn't work. The file
/etc/sysconfig/network-scripts/ifcfg-ethNhas the MAC address of the interface on the first machine.
- To fix this, I need to find the MAC address of the new VM, edit
ifcfg-ethNand add this MAC to the
HWADDR=field. I can't simply cut and paste the MAC into the field, so this can be an error-prone task, especially if I forget my pen and paper to write down the MAC.
- (Bonus points) On the new VM, often eth0, eth1, etc. display in the wrong order. Fixing this involves an arcane dance around
I can do this, but it's error prone and kind of a pain when I simply wanted to spin up a new VM to test something.
Is there a way to simplify this manual process? When you clone a new machine, how do you fix the MAC address problem?