An interesting feature request that was raised internally was for ESXi to support DDNS (Dynamic DNS) which allows a host client to update it's DNS record when using a DHCP Server. In most environments, to assign a hostname from DHCP, a DHCP reservation is used and this is maintained by the DHCP Server versus DDNS, where it is maintained by the client. Thanks to my colleague Eric Wager who did some quick research and found that ESXi does in fact supports DDNS and has been since ESXi 5.0.
I have not worked with DDNS much in the past and I have only seen it used for free/paid online services targeted at consumers to provide a well known address when their public IP Address changes frequently as with most ISPs. If your DHCP Server supports DDNS, this can be a handy feature to have, especially as you add new hosts you no longer have to manually create individual DNS record before hand and great for a lab environment. I did a big more digging to have a better understanding of how DDNS works with ESXi.
To enable support for DDNS on your ESXi host, you just need to set the hostname for the following ESXi Advanced Setting:
/Misc/PreferredHostName
You can do this in a variety of ways using either the vSphere Web/C# Client or using the command-line with ESXCLI.
Here is the syntax for the command:
esxcli system settings advanced set -o /Misc/PreferredHostName -s vesxi04.primp-industries.com
Once you have configured the setting, for the changes to go into effect, you will need to restart the management network. The easiest way to do this is via DCUI which you can run remotely by just typing dcui if you have an SSH session to your ESXi host. If you are using scripted install such as Kickstart, this can easily be automated as part of the post-install and upon first boot, DDNS will be enabled and configured with the proper hostname.
To test this in my lab environment, before enabling DDNS, I performed a reverse lookup of the assigned IP Address of my ESXi host from my DHCP server. In this example, the host received the address 192.168.1.135.
As you can see from the screenshot, a hostname could not be resolved as I would expect. After our changes, if we perform the reverse lookup again, we should now see the hostname that we had configured.
Another useful tidbit is the DHCP Client on ESXi is an ISC BIND implementation and this means if you require advanced things such as authentication keys, you can configured these options in /etc/dhclient-vmkX.conf where X is the specific VMkernel interface. For most deployments, you should not have to edit this file. Also if you want to prevent your DHCP Server from overriding the hostname of your ESXi host, you can add the following entry to the dhclient-vmkX.conf configuration file:
interface vmk0 {
supersede host-name "vesxi04.primp-industries.com";
}
Just when I thought I knew about all the awesome features ESXi offers, it is a nice surprise to learn about another one!
Anonymous says
This is indeed a nice feature. We found it and tried to use it in our deployment (vSphere 5.0) but we bumped into a problem: it is not supported by Host Profiles. Indeed, /Misc/PreferredHostName is embedded in the profile and we didn't find a way to make this value appear in the Answer File. So when we used Autodeploy, all our hosts have the same preferred hostname.
Anonymous says
It's available in ESX 5.1 onwards via the answerfile/host profile/ Autodeply. It's available as:
HostNamePolicy -> hostName ->
John Hossbach says
Running ESXi 5.5 build 2068190 on a standalone host and this isn't working. Did it go away in 5.5? I set /Misc/PreferredHostName and restarted the Management Network. My AD DNS forward and reverse lookup zones are configured for unsecure dynamic updates.
Random Sysadmin says
Thank you. I didn't want to set a static IP and create an A record. I wanted to use DHCP and just connect by hostname, this worked perfectly. The only thing that was weird was that DCUI over SSH seemed like it worked, but it didn't actually restart the management network, or reboot the host when I told it to. Perhaps it was my SSH client (MobaXTerm). I had to physically go to the machine and restart the management network.