Some weeks ago my customer wanted to change ESXi hostnames. This is not difficult and can be done without VM downtime using the below steps:
- Place ESXi host into maintenance mode
- Remove the host from cluster/vCenter inventory
- Change a record in DNS (or vCenter hosts file)
- Add the ESXi host again to the vCenter inventory using a new name
- Exit from maintenance mode
A procedure is a little bit more complicated where NSX is deployed and configured on a cluster where the name of ESXi hosts have to be changed. There are (at least) two things needed to be taken into consideration if you want to replace ESXi hostnames in an elegant way.
VXLAN
If a vSphere cluster is configured for VXLAN, you should remember that NSX uses IP pool to address a special vmkernel interface - VTEP and:
- if you have a new vSphere cluster without VM running on it, you can just unconfigure NSX (VXLAN) on this cluster. Change ESXi hostnames and configure VXLAN again.
- if you have a vSphere cluster with VMs running and using VXLAN, a procedure is a little longer because you can't unconfigure VXLAN on the cluster (there are used by VMs). You should remove a host from the cluster (after placing the host into maintenance mode) and make it a standalone host outside of any cluster. NSX automatically removes NSX modules (vibs) and allocated IP addresses from the IP pool. If you remove the host from inventory when it is still in the NSX cluster you will have a stale IP address and you need to use Rest API to release it. For example, using this procedure.
Guest Introspection
The second thing is Guest Introspection. As you probably now, NSX deploys a system VM on each (at least in current NSX version đŸ˜‰ ) ESXi host where antivirus protection by 3rd party needs to be used. Recently VMware changed a NSX behaviour and each VM name contains FQDN or IP address (it depends on how ESXi hosts are added to the vCenter inventory. I recommend FQDN) of ESXi hosting this VM. You should unconfigure vSphere cluster from Guest Introspection and configure it again after changing ESXi hostnames.
Summary
Changing ESXi hostnames can be time-consuming if there are many dependencies as the example mentioned above - NSX services. Another example outside of NSX can be VM backup. VMware hasn't introduced a special vmkernel just for VADP and if the backup/restore traffic is sent by a dedicated interface, the hosts file also needs to be updated on backup servers.