(The following hostname and domain name are examples and do not represent any real entities.)
An ESXi host was installed and configured with an outdated domain name, such as 'example1.com' and added to vCenter. Subsequently the old DNS server will be removed and a new DNS server with a new domain name, say, 'example2.com', will be introduced. So settings of DNS server, new domain name in ESXi hosts were changed accordingly,
The host was removed from vCenter with the old domain name and then added into vCenter again with the new domain name. Everything seems fine,
But eventually we see the old domain name in inventory,
To prevent connectivity issues with the host during DNS transition, an additional change was made in the file /etc/hosts of vCenter. An entry of the old and new FQDN was added to /etc/hosts, such as,
IP-address esxi.example1.com esxi.example2.com
The modified file /etc/hosts of vCenter is the problem. When we are adding the host with the new FQDN esxi.example2.com, the outdated name was referenced.
Need to remove the host from vCenter, remove or comment out the line in /etc/hosts of vCenter,
IP-address esxi.example1.com esxi.example2.com
then add the host with the new FQDN again.