How to Prevent Cloned VM Has Same IP Address as Original VM
Cloning is a convenient feature to create multiple same virtual machines. But if their IP addresses are all the same, too, it may cause IP conflict and affect the network access. If you find your cloned VM has same IP as the original, you can view this article to see how to prevent it from happening.
Case: Cloned VM has same IP address
I have a lab environment at home running esxi 5.5. I went to clone my VM and syspreped it before hand. I selected the option 'I copied it' and proceeded to clone the VM, however I was expecting the clone vm to have a new mac address but it's exactly the same as the original with the same IP. (Note server is set to static ip) How do I safely change the IP address of the clone and is there a best practice method to clone a VM?
- Question from communities.vmware.com
You may run into the same situation as the above case, after VMware ESXi clone VM with or without vCenter Server, selected ‘I copied it’ option, only to find that the new VMs acquire the same DHCP IP addresses from the DHCP server, for example, ubuntu clone same IP address, no matter if guest customization is applied or not.
This often happens after cloning VMs that are running Ubuntu as guest operating system (OS) from VM template or a parent VM. In this article, I will introduce how to deal with the situation of cloned VM has same IP address.
The reason why cloned VM has same IP as original VM
Whether you are using host-only, network address translation (NAT), or bridged networking, each virtual machine must be assigned a unique IP address, dynamically or statically, as any regular computer. IP conflict can cause serious problems on the network. You may find that networking does not work in a cloned Linux virtual machine.
Although the cloning feature provided by hypervisors is supposed to prevent this from happening, there are still many people find their virtual machines created from template were fighting over the same IP address.
According to VMware, this issue often occurs when clone Ubuntu guest virtual machine. The newly cloned VM includes the same /etc/machine-id as the VM template or parent VM it was cloned from.
For Linux OS which uses /etc/netplan with default network renderer as systemd-networkd, such as Ubuntu Server 18.04, Ubuntu 19.10 and Ubuntu 20.04, the value of /etc/machine-id is used as a unique identifier when the DHCP server assigns an IP address for the Operating System. If two or more these guest OSes include the same /etc/machine-id, then they get the same IP addresses from the DHCP server.
In summary, the machine id is being used to request an IP address from DHCP, rather than the Mac address. That’s why even though each VM created from the standard template has a unique Mac address, they still assigned the same IP address from the DHCP server.
How to prevent cloned VM has same IP address
Currently there is no resolution to the problem that cloned VM has same IP address as the original VM. But luckily, there are still workarounds you can try to prevent this issue from happening.
To work around this issue, VMware recommends to prepare a VM template running an Ubuntu Guest OS with an empty /etc/machine-id, or alternatively, prepare a VM template explicitly setting the dhcp client identifier to mac.
Here are the specific steps:
1. Clone your VM template to a new VM.
2. Power on the new VM and run these commands inside the Linux Guest OS:
echo -n > /etc/machine-id
ln -s /etc/machine-id /var/lib/dbus/machine-id
3. Re-clone the new VM to a new VM template.
An alternative way to clone VMs: Backup and restore VM to new location
In fact, there is not just one way to clone a virtual machine. Except for vCenter Server, you can still clone your VMs via backup and restore tools. Here I recommend you AOMEI Cyber Backup, a professional backup software that capable of cloning VMs to new location with simple steps.
✦ Batch VM Backup: batch backup large numbers of VMs managed by vCenter Server or standalone ESXi hosts.
✦ Image-level independent Backup: create independent backups of VMware ESXi or Hyper-V VMs at image-level.
✦ Restore to New Location: you can restore VM backup to another data storage or host, and reset the RAM and Virtual Processor.
AOMEI Cyber Backup support both paid and free versions of VMware ESXi 6.0 and later versions, and also support Microsoft Hyper-V. Next I will demonstrate how to clone VM to new location on AOMEI Cyber Backup.
You can click the following button to start a 30-day free trial.
*You can choose to install this VM backup software on either Windows or Linux system.
How to clone VM to new location
1. Bind Devices: Access AOMEI Cyber Backup web client, navigate to Source Device > VMware > + Add VMware Device to add vCenter or Standalone ESXi host as the source device, and then click … > Bind Device.
2. Create Backup Task: Navigate to Backup Task > + Create New Task, and then set the Task Name, Backup Type, Device, Target, Schedule, and Cleanup according to your needs. Then click Start Backup.
The accomplished backup task will be listed in Backup Task.
3. Click ... > Restore on the backup task to open the wizard. Select Restore to new location option, specify the target host, data storage, and provide a name for the VM. Then click Start Restore to clone the VM to new location.
Cloning is a convenient feature to create multiple same VMs on original host, or replicate VM to another host. In this article, I summarized the reason why cloned VM has same IP as original, and introduced how to prevent it from happening. Hope it could be helpful to you.
Except for the built-in cloning feature, you can try AOMEI Cyber Backup to clone VM in a backup and restore way. In addition, it also allows you to backup VMware VM to external hard drive for safer storage.