ESXi changing the host name - 夜莺博客

ESXi changing the host name

原文:ESXi changing the host name — theDXT (Daniel Keer)

Here is how to change the host name in ESXi (specifically ESXi 7). This guide keeps the original click-by-click walkthrough and adds the CLI methods, DNS prerequisites, vCenter and certificate side effects, verification steps and the problems that most often catch people out.

Why the ESXi host name matters

On a standalone ESXi host the host name looks cosmetic: you can reach the host by IP address and everything appears to work. As soon as the host is managed by vCenter, backed up by a third-party tool, monitored over SNMP/syslog or used with iSCSI/NFS storage, the name becomes a hard dependency.

  • vCenter registration — vCenter stores the FQDN of the host it manages. If the DNS record no longer resolves, or resolves to a different address than the management IP, the host shows up at the top of the ESXi Host object in the inventory with name/address mismatch alarms.
  • Certificates and thumbprints — the host's self-signed certificate is generated against the configured host name at build time. Renaming a host does not automatically regenerate the certificate, so the presented certificate no longer matches the FQDN you connect to.
  • Logging and monitoring — syslog, SNMP and NetFlow records are tagged with the host name. Renaming mid-life creates a discontinuity in your dashboards.
  • Backup and storage — VADP-based backup products and array-side host entries (iSCSI initiator groups, NFS export permissions) may be pinned to the previous name or IP.

Practical upshot: treat a rename as a small change with real consequences. Announce it, do it in a maintenance window, and update DNS first.

Prerequisites and preparation

  • Access out of band. You will be changing management networking settings. Have iDRAC/iLO/IPMI or physical console access ready in case you lose network connectivity.
  • ESXi version: ESXi 6.5, 6.7, 7.0 and 8.0 all support the methods below. The UI paths are almost identical; the ESXCLI syntax is identical.
  • Valid name: a host name label may contain letters, digits and hyphens only. Underscores, spaces and non-ASCII characters are rejected. Maximum 63 characters per label, 255 for the FQDN.
  • DNS: create (and if possible pre-publish) both an A record for the new FQDN and a matching PTR record. vCenter, NTP peers and backup servers should be able to resolve the new name before the change to avoid alerts.
  • Remove ambiguity: if the host is in a vCenter cluster, put it into maintenance mode when the workload allows it. This is not strictly required for a rename, but it guarantees no live VM operations are interrupted if connectivity blips.
  • Document the old values: run the read-only commands below and save the output — this is your rollback reference.
# Run over SSH (enable first: Host > Manage > Services > TSM-SSH > Start)
esxcli system hostname get
esxcli network ip interface ipv4 get
esxcli network ip dns server list
esxcli network ip dns search list

Expected output of esxcli system hostname get is three lines: Host Name, Domain Name and Fully Qualified Domain Name. Write these down before you change them.

Method 1: ESXi Host Client (GUI)

This is the method shown in the original walkthrough and the one most administrators use. Log in to the Host Client at https://<management-ip>/ui.

  1. Navigate to Host > Manage > Networking. In newer builds the left-hand navigation simply shows Networking under the host's Manage tab.

Image 3

  1. Click on TCP/IP stacks.

Image 4

  1. Click on the Default TCP/IP stack.

Image 5

  1. Click on Edit settings.

Image 6

  1. Give it the correct settings — set Host name to the short name (for example esxi01) and Domain name to your DNS suffix (for example lab.example.com). The read-only field below shows the resulting FQDN, so check it before saving.

Image 7

  1. Click Save. That's it — you are done. The change takes effect immediately for new connections; existing sessions keep the old name until they reconnect.

Tip: on the same Edit settings dialog you can add DNS servers and search domains, so you can fix resolution at the same time as the rename.

Method 2: Direct Console User Interface (DCUI)

If you cannot reach the Host Client, the DCUI is available on the physical console or via the remote KVM (iDRAC/iLO). Use the arrow keys, Enter to select and Esc to go back.

  1. Press F2 and authenticate as root.
  2. Select Configure Management Network.
  3. Select DNS Configuration.
  4. Fill in Primary DNS Server, Alternate DNS Server, Hostname and DNS Suffixes.
  5. Press Enter to apply, then press Esc and confirm Apply changes and restart management network? with Y.
  6. If the host does not pick up the new name, go back to the top-level DCUI menu, choose Troubleshooting Options > Restart Management Agents and press F11 twice.

Method 3: ESXCLI over SSH

For scripting, hosts without working management UI, or when you want the rename to be repeatable, use ESXCLI. Enable SSH from Host > Manage > Services > TSM-SSH > Start, or from the DCUI under Troubleshooting Options.

# Set the short name and the domain name
esxcli system hostname set --host=esxi01
esxcli system hostname set --domain=lab.example.com

# Or set the FQDN in one shot (this overwrites host + domain)
esxcli system hostname set --fqdn=esxi01.lab.example.com

# Confirm
esxcli system hostname get

Then set resolution, because a renamed host with a stale DNS server entry will still fail to resolve itself:

esxcli network ip dns server add -s 192.168.10.10
esxcli network ip dns server add -s 192.168.10.11
esxcli network ip dns search add -d lab.example.com

# Verify
esxcli network ip dns server list
esxcli network ip dns search list
nslookup esxi01.lab.example.com

Apply the change to the management services so the new name is used everywhere:

/etc/init.d/hostd restart
/etc/init.d/vpxa restart
# If you prefer the blunt instrument:
services.sh restart

Note that services.sh restart restarts hostd, vpxa, the SNMP agent and the NTP daemon. In-flight tasks are aborted, which is another reason to do this in a maintenance window.

Renaming a host that is managed by vCenter

Changing the name on the host itself is only half the job. vCenter connected to the old FQDN will lose contact with hostd, and after a few minutes the host shows as Not responding in the inventory.

  1. Update the DNS A and PTR records so that both the old and the new name resolve during the transition.
  2. Rename the host on the ESXi side using one of the methods above.
  3. In vCenter, wait for the host to be flagged, or right-click the host and choose Connection > Disconnect followed by Connection > Connect.
  4. If the host was renamed to an entirely new FQDN, the cleanest approach in vSphere 7/8 is to put the host in maintenance mode, Remove it from the inventory (choose Do not move VMs only if the host is in maintenance mode) and Add Host again using the new FQDN. This refreshes the stored certificate and any host-profile bindings.
  5. Re-apply host profiles, distributed switch membership and any vCenter-level permissions that were bound to the old name.

If the host is licensed per-host but the license key is assigned at vCenter level, re-adding is painless. If you use a distributed switch or NSX, verify that the uplink/transport-node configuration still references the correct management interface.

Certificates after a rename

The management certificate on an ESXi host is generated at install time against the host name used then. After a rename, browsers and management tools will report a name mismatch.

# ESXi 6.5 / 6.7 / 7.0: regenerate the self-signed certificates
/sbin/generate-certificates
/etc/init.d/hostd restart
/etc/init.d/vpxa restart

Regenerating certificates changes the host thumbprint. If the host is in vCenter, you will be asked to accept the new thumbprint on reconnect. If you use a custom CA-signed certificate, reissue it with the new FQDN in the Subject Alternative Name field instead of regenerating self-signed certs, then restart hostd and vpxa.

Verification

# 1. Host name is what you expect
esxcli system hostname get
hostname -f

# 2. Forward and reverse resolution
nslookup esxi01.lab.example.com

# 3. Management services are healthy
/etc/init.d/hostd status
/etc/init.d/vpxa status

# 4. The Host Client banner shows the new name after a fresh login
#    (https://<management-ip>/ui)
  • In the Host Client, click the host object: the summary panel should show the new FQDN.
  • From another host or a workstation, ping the new FQDN and confirm it resolves to the management IP.
  • In vCenter, confirm the host is Connected, with no configuration issues about name/address mismatch.
  • Check that backups, monitoring and NTP are still working — these are the systems that silently depend on the old name.

Common problems

The host becomes unreachable after the change. A rename should never affect routing, but a mistyped domain suffix or a DNS server entry can make the host fail to resolve its own FQDN. Revert via the DCUI: Configure Management Network > DNS Configuration, then Troubleshooting Options > Restart Management Agents.

Host shows as "Not responding" in vCenter. Expected after a rename. Disconnect/reconnect the host, or remove and re-add it with the new FQDN. If you cannot access the host at all, check that the vpxa service started: /etc/init.d/vpxa status.

Certificate warnings in the browser or in vCenter. The certificate no longer matches the FQDN. Regenerate self-signed certificates, or reissue a CA-signed certificate with the new name in the SAN field.

The name reverts after a reboot. This happens when the change was made somewhere that does not persist — for example editing configuration files directly instead of using esxcli or the DCUI, or when a host profile is enforced by vCenter and puts the old name back. Fix the host profile or detach the host from it, then set the name again.

Validation error when saving the new name. Underscores, spaces, uppercase-only oddities and names starting or ending with a hyphen are rejected. Use only letters, digits and hyphens, and keep the label short.

Everything works except monitoring/backup. Those tools cache the old FQDN. Update the host entry in your monitoring, backup, SNMP trap receiver and syslog collector.

Two hosts answer to the same name. Duplicate names break vCenter and DNS alike. Before renaming, confirm from the DNS administrator that the target name is unused, and check the lease table of your DHCP server.

Rollback

Rolling back is the same procedure with the old values. Keep the pre-change output of esxcli system hostname get, esxcli network ip dns server list and esxcli network ip dns search list, then set the name back with esxcli system hostname set --fqdn=old.example.com and restart hostd and vpxa. If the host is managed by vCenter, remember to reconnect it there as well.

Summary

Changing the host name in ESXi takes seconds — three fields in the TCP/IP stack dialog, two menus in the DCUI, or a single esxcli system hostname set --fqdn command. The work around it is what matters: publish DNS first, expect the certificate and vCenter connections to need attention, restart the management agents, and verify forward and reverse resolution from a second system before you declare success. On a standalone lab host you can be casual about it; on production hardware managed by vCenter, treat the rename as a change with a rollback plan and a maintenance window.