4

I've cloned two vSphere VMs off of an Ubuntu 17.10 template. After boot, they both claim the same IP and fight for it (ssh connections break off as the IP switches between them).

The hostnames and MAC addresses are different between the two machines. dhclient correctly claims two separate IPs, but the resolver in use is systemd-networkd.

10

systemd-networkd uses a different method to generate the DUID than dhclient. dhclient by default uses the link-layer address while systemd-networkd uses the contents of /etc/machine-id. Since the VMs were cloned, they have the same machine-id and the DHCP server returns the same IP for both.

To fix, replace the contents of one or both of /etc/machine-id. This can be anything, but deleting the file and running systemd-machine-id-setup will create a random machine-id in the same way done on machine setup.

  • 2
    See unix.stackexchange.com/questions/402999 for why that does not work, what one actually has to do, and what state the machine has to be in to do it. – JdeBP Jan 24 '18 at 13:13
  • Interesting. Good catch. +1 – Rui F Ribeiro Jan 24 '18 at 19:01
  • Wow. I've been banging my head on this one. I'm finally getting different IPs after following your suggestion. Although, onto my next issue. I cannot seem to ping the VMs from Host. Ugg! – jersey bean May 16 at 17:27
  • Nevermind. Problem solved. Thx for your post! – jersey bean May 16 at 18:20
  • Solved it for me, thanks! – Izac May 23 at 9:07
1

What about netplan configuration? There is an option dhcp-configuration that can be used as follows (excerpt from netplan examples):

network:
  version: 2
  ethernets:
    enp3s0:
      dhcp4: yes
      dhcp-identifier: mac

by default it is using machine-id, but by changing this feature we can 'force' it not to.

Excerpt from manpages/netplan, giving more insights:

       dhcp-identifier (scalar)
              When  set  to `mac'; pass that setting over to systemd-networkd to use the device's
              MAC address as a unique identifier rather than a RFC4361-compliant Client ID.  This
              has no effect when NetworkManager is used as a renderer.

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.