Using virtualisation (VMs) like Virtualbox, KVM etc, people sometimes “clone” existing UBUNTU 20.04 Server VMs and later experience a problem in DHCP enabled networks. These VMs seem to clinge to their former IP address, not requesting unique addresses. Thus having problems with networking. That even happends with changed/unique MAC addresses.
That behaviour may affect even earlier UBUNTU versions and some DEBIAN based distros as well. It does NOT affect manual/fixed/static network configurations.
The problem can be caused by a unfortune combination of DHCP Client and DHCP Server in the network. While historically DHCP servers are used to hand out unique IP adresses to every new MAC address, a client or server today “can” request/send also other client identification information as well. Like “machine id”. So a DHCP client and/or server may hand out “the same IP address” to different network interfaces (different MAC addresses) IF those DHCP clients present themselfs with the same machine (installation) ID.
Since the VMs in these cases has been cloned, all these VMs contain the same machine id.
You can check the machine ID of your UBUNTU installation like that:
cat /etc/machine-id cat /var/lib/dbus/machine-id
As you can see here, there may even be more that one place where your machine id/installation id has been placed.
As always there are more than just one solution to any problem. Some people seem to have success by deleting or replacing the IDs in those files. However, if you dont care for unique machine IDs and just want to have the DHCP client work again as once intended, you can just tell the DHCP client what unique ID to use to request a new IP address.
Since for UBUNTU Server these days “netplan” is the default network manager i'll show how i did it on my VMs:
# set new fqdn/hostname hostnamectl set-hostname newFullQualifiedHostname.lan # update /etc/hosts with that new hostname (full + short) sed -i "s/\(^127.0.1.1\s\).*/\1$(hostname -f)\t$(hostname -s)/" /etc/hosts
cat << EOF > /etc/netplan/00-installer-config.yaml network: ethernets: enp0s3: dhcp4: true dhcp-identifier: mac version: 2 EOF netplan apply reboot