Score:2

cloud-image passes default hostname to dhcp server despite cloud-init script

tr flag

How do I get the Ubuntu 20.04 Cloud Image to send an individual hostname along with its initial dhcp request?

I am deploying Ubuntu 20.04 Cloud Images on vSphere using Nutanix Calm and a cloud-init cloud-config script to set the hostname, add a user and pass ssh keys.

The Vm is created and boots, the hostname appears in vSphere correctly and the user is created along with an ssh key.

However, the dhcp server (ISC) returns the same IP for each instance I create despite them having individual MAC addresses, as the cloud image always sends the same hostname "ubuntuguest" to the dhcp server, and the dhcp server apparently uses the hostname and not the MAC address to assign the IP addresses.

The hostname is a user-variable entered at runtime which is passed to the cloud-init user-data and which, once the vm has been created does get set, just not in time for the initial dhcp request.

Andrew Lowther avatar
jp flag
Did you ever boot the image before starting to deploy VMs based on it? When the image gets booted the first time it will create `/etc/machine-id`. By default, this is what is used as the DHCP identifier. See https://kb.vmware.com/s/article/82229
mangohost

Post an answer

Most people don’t grasp that asking a lot of questions unlocks learning and improves interpersonal bonding. In Alison’s studies, for example, though people could accurately recall how many questions had been asked in their conversations, they didn’t intuit the link between questions and liking. Across four studies, in which participants were engaged in conversations themselves or read transcripts of others’ conversations, people tended not to realize that question asking would influence—or had influenced—the level of amity between the conversationalists.