Reading Time: 3 minutes

After cloning VMs that are running “recent” version of Ubuntu as Guest Operating System (OS) from VM template or a parent VM, the new VMs acquire the same DHCP IP addresses from the DHCP server, no matter if guest customization is applied or not… also if the two VMs have different MAC addressess.

And doesn’t matter the type of hypervisor that you are using… but, of course, VMware has documented this issue in this article: Cloned VM acquires the same DHCP IP address towards guest customization process (KB 82229).

This could be not a huge problem for server VM, where probably IP will assigned statically and guest customization will work perfectly. But can be a huge issue in other scenarios, like VDI using Ubuntu virtual desktop.

The background

Sound strange, but DHCP servers does not use anymore the client MAC address to assign lease, but they are using a specific field (option 61) called ClientID as documented in RFC 2132: DHCP Options and BOOTP Vendor Extensions.

Not a big issue… but Ubuntu use the value of /etc/machine-id is used as a unique client identifier for DHCP request and this value is generated only at the first time and it’s not based on MAC address… so if you clone a Ubuntu VM you also duplicate this id.

The solution client side

Note also Windows OSes use a ClientID, but it contains a part related to the MAC address… so will not be cloned. Also you can disable the ClientID and use MAC address instead by setting 1 to the registry key HKEY_LOCAL_MACHINE\SYSTEM\CurrentControlSet\Services\Tcpip\Parameters\SkipClientID as described in this page.

For Ubuntu, VMware KB suggest to regenerate the machine-id file by using this script:

echo -n > /etc/machine-id
rm /var/lib/dbus/machine-id
ln -s /etc/machine-id /var/lib/dbus/machine-id

Another option is adding the dhcp-identifier option in the netplan configuration:

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

The solution server side

For Windows DHCP Server (using the default role) I haven’t found (yet) a solution. One possible workaround is just force some reservation using the Ubuntu MAC address (and not the ClientID).

For Linux based DHCP Server there is a specific configuration to use the MAC addresses instead of the clientID:

# If the ignore-client-uids statement is present and has a value of true or on, the UID for clients will not be recorded.
#If this statement is not present or has a value of false or off, then client UIDs will be recorded.
ignore-client-uids on;
Share

Virtualization, Cloud and Storage Architect. Tech Field delegate. VMUG IT Co-Founder and board member. VMware VMTN Moderator and vExpert 2010-24. Dell TechCenter Rockstar 2014-15. Microsoft MVP 2014-16. Veeam Vanguard 2015-23. Nutanix NTC 2014-20. Several certifications including: VCDX-DCV, VCP-DCV/DT/Cloud, VCAP-DCA/DCD/CIA/CID/DTA/DTD, MCSA, MCSE, MCITP, CCA, NPP.