VMware Cloud Community
rightclix
Enthusiast
Enthusiast

Clone VM has same IP address

Hello all,

I have a lab environment at home running esxi 5.5. I went to clone my Server 2012 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?

Thanks

13 Replies
continuum
Immortal
Immortal

"I copied" should have changed the MAC address.
I would power off the VM, remove it from inventory , manually delete the MAC address parameters from the vmx-file and then re-register the VM.


________________________________________________
Do you need support with a VMFS recovery problem ? - send a message via skype "sanbarrow"
I do not support Workstation 16 at this time ...

Reply
0 Kudos
rightclix
Enthusiast
Enthusiast

I will try that and let you know.

Thanks

Reply
0 Kudos
rightclix
Enthusiast
Enthusiast

Hi Continuum.

Unfortunately that didn't work. So I did as instructed, removed it from inventory, downloaded the vmx file, edited the parameters by removing the lines following the link below. (note I deleted the lines but left the "  ") , uploaded the file back to the inventory and it's exactly the same.

https://kabri.uk/2008/07/16/force-vmware-to-generate-a-new-mac-address/

Did I do it right?

How do I check if the VM is getting the address via dhcp from my physical router?

Reply
0 Kudos
MikeStoica
Expert
Expert

Do an ipconfig /all and see if the DHCP Server IP address is the one from the router.

Reply
0 Kudos
chhsiao1981
Contributor
Contributor

rightclix

I encountered this question as well~

I'm wondering did you find the solution?~

I found that the mac-address of the VMs are displayed differently,

and is also confirmed from ipconfig in the VM.

However, somehow the IPs are assigned as the same.

But the IPs are assigned as different if I create a new VM from scratch instead of cloning a VM.

Reply
0 Kudos
jburen
Expert
Expert

Or you could clone the VM, remove the nic and re-add it again. That should give the VM a new mac address. Another option is to clone the VM and then convert it into a template. Then create a new VM from that template. That should also work.

Consider giving Kudos if you think my response helped you in any way.
Reply
0 Kudos
chhsiao1981
Contributor
Contributor

We bought a Dell server with VMWare ESXi 6.5 in 2017.

I am very sure that the MAC-address are DIFFERENT between the original-VM and the cloned-VM.

(I used

vmkfstools -i "${PREFIX_DIR}/${FROM_VM}/${FROM_VM}_0.vmdk" "${PREFIX_DIR}/${TO_VM}/${TO_VM}_0.vmdk" -d thin

sed "s/${FROM_VM}/${TO_VM}/g" "${PREFIX_DIR}/${FROM_VM}/${FROM_VM}.vmx" > "${PREFIX_DIR}/${TO_VM}/${TO_VM}.vmx"

and clicked on "I copied the VM" to do the cloning.)

However, it seems like something happened in VM-network and both VMs received same IP from the

outside-DHCP-server.

It's possible that we need to use vSphere to do this cloning-feature though~

pastedImage_4.png

Reply
0 Kudos
jburen
Expert
Expert

Are you sure that the IP address is not set in the guest OS? You actually see two leases in the DHCP server? I find that hard to believe. Most DHCP servers have a mechanisme to detect duplicate IP addresses. So please check again that the guest OS is using DHCP and that you see the leases in the DHCP server.

Consider giving Kudos if you think my response helped you in any way.
Reply
0 Kudos
chhsiao1981
Contributor
Contributor

The guestOS that I am running is 18.04.2.

I am sure that the ip is assigned from the outside-DHCP-server.

It looks like something happened in VMNet and the 2 VMs are considered as the same outside the VMWare ESXi.

pastedImage_0.png

Reply
0 Kudos
chhsiao1981
Contributor
Contributor

I just tested on 16.04 as well.

It looks the ip-allocation on 16.04 is perfectly great~

but not on 18.04

pastedImage_0.png

Reply
0 Kudos
jburen
Expert
Expert

The cause of the problem could be that the built-in network config of Ubuntu 18.04 no longer uses the NIC Mac address as the default id for DHCP requests.

The traditional (and I believe "sensible") behavior can be restored by adding dhcp-identifier: macto the configuration in the /etc/netplan/xxx.yaml (cloud-init) file as follows:

network: renderer: networkd version: 2 ethernets: nicdevicename: dhcp4: true dhcp-identifier: mac 

Where "nicdevicename" is the name of your network device

Use

sudo netplan apply 

to try the new configuration. If you get any errors, please note that precise indentation is very important in .yaml files..

Consider giving Kudos if you think my response helped you in any way.
DOMO21
Contributor
Contributor

This is the solution!!!

Thanks @jburen for your contribution

Reply
0 Kudos
behniafb
Contributor
Contributor

Solution:

Use these URLs below as the step-by-step solution (changing the

/etc/netplan/config.yaml

 didn't work for me).

But as said above, it's because of same machine-id.
The URLs:
1. https://kb.vmware.com/s/article/82229
2. https://www.dtonias.com/create-vm-template-vmware-workstation/ (For creating a template of the VM)

Reply
0 Kudos