Fix Linux VM Guests All Getting The Same DCHP IP
Ubuntu 18.04+ and Debian 12+ use a new machine ID concept instead of a MAC address for identifying itself to DHCP servers.
KVM does not appear to set the machine ID to something new like it does with the MAC address when cloning guests. This means that if you clone an Ubuntu 18.04 instance that uses DHCP to get it's IP address, it and the clone will both get the same IP address, making your life "fun". The solution to this is to run the following commands in either VM and then rebooting, which results in the machine generating a new ID.
sudo truncate -s 0 /etc/machine-id && \
sudo rm /var/lib/dbus/machine-id && \
sudo ln -s /var/lib/dbus/machine-id /etc/machine-id
References
Last updated: 6th July 2023
First published: 4th January 2019
First published: 4th January 2019