How to resolve IP conflicts on Ubuntu Server clones

back | 2025-01-24

How to resolve IP conflicts on Ubuntu Server clones

If you've ever cloned a Ubuntu Server VM on a DHCP network, you'll notice that they try to occupy the same address even though their MAC addresses are different. This guide explains how to resolve this conflict for Ubuntu Server versions 18.04–24.04.

Cause

Resolution

To fix the issue, you can instruct Netplan to use MAC addresses instead of DUID.

  1. Edit /etc/netplan/50-cloud-init.yaml, and add dhcp-identifier: mac:

    network:
        ethernet:
            enp1s0: # This will vary by interface name
                dhcp4: true
                dhcp-identifier: mac # Add this line

  2. Apply the configuration:

    sudo netplan apply

  3. Request a new address via DHCP:

    sudo dhclient -r
    sudo dhclient

There are other solutions that will work. For example, you could edit the DUID at /etc/machine-id to a unique value, preventing the conflict. However, the method in this guide works just as well.