IP Address duplicates/conflicts when cloning from a template

Jan 23, 2021
51
18
13
Hi all,

One of the first things I did after setting up my PVE was creating a basic installation of Ubuntu Server, get it set up with all the basic bits, and then convert it to a template.

I have cloned (full clone) this template a number of times and I did notice that each time I cloned it, the new VM would boot up on the same IP as the previous one I set up. I obviously checked mac addresses and PVE is assigning a new mac address to each clone, so I was a bit confused as my router shouldn't have been assigning an in-use IP to a different client. Most of the servers are still set to DHCP while I am going through setting each one of them up. I tried renewing the DHCP lease from the console but that didn't make a difference. What I had to do, was a sudo dhclient -r ens18, and then remove the network interface from the hardware of the VM and then add a new one back. Then it would pick up a new DHCP address. I thought it was a bit weird, and a bit of pain but I went through each VM instance and did this one by one, while at the same time setting a unique hostname.

Now, something even weirder has happened. I had to restart my PVE a couple of times today, and when I went to access one of my VMs in a web browser I could not connect. What found was that a whole bunch of my VMs were up on the same IP address. Some even had the conflicted address and then another unique address. It was really weird. I have currently got all the conflicting ones shut down while I investigate what the problem might be. I've probably done something wrong but I'm hoping it's fixable.

What is the current guidance on cloning from a template and networking configuration of the new machine? Is there something I should have done before converting to a template or is there something I need to do now?

Any help and advice would be greatly appreciated.

Thanks,

FS
 
Last edited:
In the end it is just the MAC address of the virtual NIC that is the same, change the mac address in the VM and the problem is solved. machine-id is a deep rabbit hole and the tools to change it are lousy and really convoluted.

Machine-ID also is not used by a lot of things, the MAC address of a NIC is a fundamental ID of a network interface, this is a much easier way:

Supposing your vm has only one virtual NIC, you can

  • stop the vm
  • from pve web interface, remove the virtual nic (eg: eth0)
  • create a new one, this will get a new MAC, and your vm will always see it as eth0.
  • restart the vm and check if everything works fine
This is done at the host level, so is guest OS independent.
 
Last edited:
This is so strange.
Had the same problem.
The strange part is that i created a new MAC on the same interface on VM1, and still the dhcp server said it delegated the same IP to both different MAC adresses on VM1 and VM2. I had to remove the adapter, and add a new one on one of the machines to pull a new IP.

Incredible

Thanks for the Post and answers :)
 
  • Like
Reactions: stefa
If you want to read more regarding this, this article explains how the DUID, which is used as a identifier for dhcp-clients, is generated: https://unix.stackexchange.com/ques...network-duid-iaid-and-dhcpv4-clientidentifier

In essence, all the values used are the same for common vms - a static prefix, the machine id and the interface name (in cloud init oftentimes eth0).
To generate a new one, you can do the following:

rm -f /etc/machine-id && dbus-uuidgen --ensure=/etc/machine-id && rm /var/lib/dbus/machine-id && dbus-uuidgen --ensure

For reference, i took that from here: https://unix.stackexchange.com/questions/402999/is-it-ok-to-change-etc-machine-id

If you want to change the machine id in an offline image, you need to make sure the file exists - otherwise systemd-networkd will not be able to create a DUID for dhcp-requests.
 
Last edited:

About

The Proxmox community has been around for many years and offers help and support for Proxmox VE, Proxmox Backup Server, and Proxmox Mail Gateway.
We think our community is one of the best thanks to people like you!

Get your subscription!

The Proxmox team works very hard to make sure you are running the best software and getting stable updates and security enhancements, as well as quick enterprise support. Tens of thousands of happy customers have a Proxmox subscription. Get yours easily in our online shop.

Buy now!