I cloned an Ubuntu 20.04 VM and was frustrated to see both boxes kept getting the same DHCP IP address despite having different network MAC addresses. I finally found on this helpful post which states Ubuntu 20.04 uses systemd-networkd for DHCP leases which behaves differently than dhclient. As wickedchicken states,
systemd-networkd
uses a different method to generate the DUID thandhclient
.dhclient
by default uses the link-layer address whilesystemd-networkd
uses the contents of/etc/machine-id
. Since the VMs were cloned, they have the samemachine-id
and the DHCP server returns the same IP for both.
To fix, replace the contents of one or both of/etc/machine-id
. This can be anything, but deleting the file and runningsystemd-machine-id-setup
will create a randommachine-id
in the same way done on machine setup.
So my fix was to run the following on the cloned machine:
sudo rm /etc/machine-id
sudo systemd-machine-id-setup
sudo reboot
That did the trick!
For the systems that registered their hostnames under the wrong IPs, I had to take the following action for my Ubuntu 20.04 desktop as well as my Ubiquiti USG-Pro 4
Ubiquiti: Clear DHCP lease
clear dhcp lease ip <ip_address>
Ubuntu desktop: Flush DNS
sudo systemd-resolve --flush-caches