Cloned VMs from template receive the same DHCP IP address

zikou

Member
Nov 13, 2024
56
5
8
Hello,

I have a Proxmox VM that I configured as a template. I use this template to create/clone multiple VMs.

My network setup is:

  • Proxmox
  • pfSense as the router/DHCP server
  • pfSense DHCP assigns IP addresses dynamically
  • VMs use DHCP; I do not configure static IP addresses in Terraform or Proxmox
  • I use Terraform to create the VMs from the Proxmox template
The problem is that when I clone the template, the cloned VMs receive the same IP address from pfSense.
What is the recommended way to prepare the Linux VM before converting it to a Proxmox template so that every cloned VM receives a different DHCP IP address?
 
Because on Linux, usually the machine ID is used to identify against the DHCP server. Windows usually takes the MAC address.

Lookup how you can prepare a Debian based system (which Proxmox VE is) to be a template. You usually need to empty the machine ID, so that a new one is created on the next boot. The same goes for the host SSH keys. But those usually need to be "semi-automatically" by having a systemd unit that creates new host keys as a one shot unit that only runs once and enable it before you finally shut down the VM before converting it to a template.

I don't find a full guide quickly, but you should be able to find them on your own.

One thing with Proxmox VE though is that it is not intended to run with dynamic IPs! Make sure that you finalize the machines after deployment and make sure that the IP in the /etc/hosts file matches the configured one. This step is important as Proxmox VE needs to figure out its host name reliably!
 
I think a workaround might be possible via pfSense, I just looked and found the option Ignore Client Identifiers:
When set, the DHCP server will not record a unique identifier (UID) in clientlease data if present in the client DHCP request.
This option may be useful when a client can dual boot using different clientidentifiers but the same hardware (MAC) address.

With the Kea DHCP backend, if a client does not send correct and matchingclient identifier values for all of its requests, checking this box can avoidlog messages such as ALLOC_ENGINE_V4_DISCOVER_ADDRESS_CONFLICT for leasedatabase entries which are not actually conflicting.


Note
This server behavior violates the official DHCP specification.


I have not test myself. just a thought
 
Last edited:
on Linux, usually the machine ID is used to identify against the DHCP server.

I have not experienced this. I wasn't even aware it was a thing. All my Linux boxes use the MAC. Granted they are all very similar (debian with dhcpcd) and run against the same dhcp (kea) this at least proves you should be able to get it working without messing with the installed system.

Templates should of course be cleaned before but this can be useful if you ever need to clone existing systems to try out or investigate something.