Changing the hostname of an ESX or ESXi host
before I start, there is Important notes you have take care:
-If the management network of the ESX/ESXi host is on a vSphere Distributed Switch, migrate the network to a vSphere Standard Switch before proceeding.
-If the ESX/ESXi host is a part of a VSA cluster, do not remove the host from inventory.
-If ESXi host is a part of a vSAN cluster, the node in maintenance mode may still be primary or backup node in vSAN cluster, and you must manually drag the ESXi host out of the cluster to remove it from the cluster.
then start directly to change name like:
- If the ESX host is part of a cluster, drag it out of the cluster to remove it from the cluster.
- If the ESX host is managed by VirtualCenter/vCenter, disconnect and remove the ESX host from the vCenter.
- Make the modifications in your DNS environment to reflect the correct name and IP association for the new name.
- Log in as root to the console of ESX host.
- Using a text editor, change the name and domain name, if applicable, of the host in these files:
/etc/hosts
/etc/sysconfig/network
Run this command:
esxcfg-advcfg -s ESXi_FQDN /Misc/hostname
where ESXi_FQDN is the new FQDN hostname for the ESX host.
Reboot the ESX host.
Join the ESX host to VirtualCenter/vCenter Server and clusters.
or
- If the ESXi host is part of a cluster, first enter the Maintenance mode to remove it from the cluster.
- If the ESXi host is managed by VirtualCenter/vCenter Server, disconnect and remove the ESXi host from the vCenter Server.
- Connect to the host directly with a vSphere Client.
- Click ESXi host.
- Click the Configuration tab.
- Click DNS and Routing.
- Click Properties.
- In the DNS Configuration tab, edit the Name field. Change anything else that is necessary in your environment.
- Click OK.
- Join the ESX host to VirtualCenter/vCenter Server and clusters.
or
- If the ESXi host is part of a cluster, first enter the Maintenance mode to remove it from the cluster.
- If the ESXi host is managed by VirtualCenter/vCenter Server, disconnect and remove the ESXi host from the vCenter Server.
- Connect to the host directly with a vSphere Client and select the ESXi host
- Select Configure - TCP/IP configuration
- Select the Default TCP/IP Stack, and then click the Edit button
- Set hostname and Domain Click OK.
- Join the ESX host to VirtualCenter/vCenter Server and clusters
or
- If the ESXi host is part of a cluster, first enter the Maintenance mode to remove it from the cluster.
- If the ESXi host is managed by VirtualCenter/vCenter Server, disconnect and remove the ESXi host from the vCenter Server.
- Connect to the ESXi Shell please see Using ESXi Shell in ESXi 5.x, 6.x and 7.x
- Run the below command, the switch host would be used IP and the switch for fully qualified domain name (FQDN).:
esxcli system hostname set --host=hostname
esxcli system hostname set --fqdn=fqdn
5. Join the ESX host to VirtualCenter/vCenter Server and clusters
enjoy it!
Hadi