If you clone Linux virtual machines on your hypervisor (whether it be VMware ESXi, Hyper-V, or KVM/Proxmox), they will get the same IP address from the DHCP server after powering on, even if the VMs have different MAC addresses.
By default, the IP address in Linux is not bound to the MAC address, but to the Client ID. Until you change the machine-id, the cloned Linux virtual machines will receive the same IP address.
You can reset and regenerate the Client ID using the commands:
# rm -f /etc/machine-id # dbus-uuidgen --ensure=/etc/machine-id
Your VM will get a new unique IP address from DHCP after the reboot. Thus, after cloning a Linux VM, you need to:
- Change the VM’s MAC address on the hypervisor;
- Change hostname
# hostnamectl set-hostname newhostname
- Set a new hostname in
- Generate new machine-id.
If the netplan is enabled in your Linux distro (for example, Ubunu 18.04 and newer), you can change the binding of an IP address to a MAC address instead of a machine-id:
$ echo "send dhcp-client-identifier = hardware;" >>/etc/dhcp/dhclient.conf $ rm /var/lib/dhcp/* $ systemctl restart networking
Or use the dhcp-identifier: mac option in the netplan configuration file:
$ sudo nano /etc/netplan/myNetplan.yaml
network: ethernets: eth0: dhcp4: true dhcp-identifier: mac version: 2
$ sudo netplan apply