1

vSphere 7.0 + Ubuntu 18 / 20 (tried both)

I am trying the steps from this blog post:

I also tried this blog:

Both times all my cloned Ubuntu 18 (or Ubuntu 20) VMs all get the same IP:

Every 30.0s: govc find / -type m -name 'k8s*' | xargs govc vm.info | grep 'Name:\|IP'                                primary: Thu Jun 16 21:31:29 2022

Name:           k8s-worker3
  IP address:   192.168.3.73
Name:           k8s-worker2
  IP address:   192.168.3.73
Name:           k8s-worker1
  IP address:   192.168.3.73
Name:           k8s-master
  IP address:   192.168.3.73

I'm thinking something must be wrong either with my setup or with my DHCP server itself (running on a Windows Server 2012 R2 VM). However, I have no DHCP reservation for this IP (192.168.3.73) at all, let alone a MAC for it.

I have tried the steps from this VMware KB: https://kb.vmware.com/s/article/82229

echo -n > /etc/machine-id
rm /var/lib/dbus/machine-id
ln -s /etc/machine-id /var/lib/dbus/machine-id

Nothing seems to work. Can someone please explain exactly how to get Cloud-Init to force the cloned Ubuntu VM to get a unique / new IP address?

KidACrimson
  • 394
  • 1
  • 7
  • 23
  • 1
    Are you actually seeing them being retrieved from DHCP in the first place? – u1686_grawity Jun 17 '22 at 04:28
  • Good question, thanks. Yes, I can see them in the DHCP mmc console on my Windows Server. However, only the first one that takes the IP `192.168.3.73 ` is listed. – KidACrimson Jun 17 '22 at 04:41
  • 1
    Did you reset /etc/machine-id in each clone? (The command in your post is strangely line-wrapped...) Does networkctl in each VM say that it's received the address from DHCP, and specifically from your server? – u1686_grawity Jun 17 '22 at 05:01
  • Sorry, that was a formatting issue on my side. Fixed now. I did not reset `/etc/machine-id` in *each* clone, only the original one....doesn't that defeat the purpose of having a "golden" image? I would need to either use cloud-init or vApp options (in vSphere) to have it reset on each/all VMs. – KidACrimson Jun 17 '22 at 14:37

1 Answers1

0

Finally found the fix - force Netplan to use the MAC to ensure DHCP assigns a unique IP:

https://unix.stackexchange.com/questions/419321/why-are-my-cloned-linux-vms-fighting-for-the-same-ip

root@Ubuntu-20:/etc/netplan# cat 01-netcfg.yaml
# This file describes the network interfaces available on your system
# For more information, see netplan(5).
network:
  version: 2
  renderer: networkd
  ethernets:
    ens160:
      dhcp4: yes
      dhcp-identifier: mac

# Last line was the fix
KidACrimson
  • 394
  • 1
  • 7
  • 23