In case of cloning Ubuntu OS with version 20.+ we can notice that DHCP treat all virtual machines as one. Possible reason could be that machine id for all OS copies is the same.
To check machine-id use command:
cat /etc/machine-id
- Virtualization (Virtualbox, Vmware)
- Cloned Ubuntu Virtual Machines have assigned same IP address by DHCP.
- Machine-Id doesn't change
- Enter source Ubuntu VM
- Download script and make it executable
wget https://raw.githubusercontent.com/greencashew/ubuntu-20-machine-id-reset-script/main/reset-machine-id.sh && chmod +x reset-machine-id.sh
- Run
sudo ./reset-machine-id.sh install
- Clone source virtual machine
- Start cloned virtual machines
- Machine id-s for each VM should be different.
sudo ./reset-machine-id.sh Reset machine id and create already run indicator under path $RESET_FILE_PATH
sudo ./reset-machine-id.sh install Install service which run reset-machine-id.sh on every system startup if indicator file $RESET_FILE_PATH doesn't exists.
sudo ./reset-machine-id.sh prepare Remove indicator file so reset id script file can run during next startup.
sudo ./reset-machine-id.sh uninstall Uninstall script
sudo ./reset-machine-id.sh help Open this help
You can also run below commands manually on each machine:
sudo rm -f /etc/machine-id
sudo dbus-uuidgen --ensure=/etc/machine-id
sudo rm /var/lib/dbus/machine-id
sudo dbus-uuidgen --ensure
sudo dhclient -r