The Wiert Corner – irregular stream of stuff

Jeroen W. Pluimers on .NET, C#, Delphi, databases, and personal interests

  • My badges

  • Twitter Updates

  • My Flickr Stream

  • Pages

  • All categories

  • Enter your email address to subscribe to this blog and receive notifications of new posts by email.

    Join 2,914 other followers

ESXi: getting and setting the host name, domain and fqdn

Posted by jpluimers on 2022/01/19

A few links and notes:

  1. [Wayback] Changing the hostname of an ESX or ESXi host (1010821)

    Run these commands to change the hostname in ESXi 5.x, ESXi 6.x,ESXi 7.x, using the command line:

    • esxcli system hostname set –host=hostname
    • esxcli system hostname set –fqdn=fqdn
  2. [Wayback] ESX Host appears as localhost.localdomain in VMware Infrastructure/vSphere client (2009720)

    Cause

    The name resolution parameters were not properly configured during the installation of the ESX host.
  3. [Wayback] Domain repoint for embedded vCenter Server fails with error: “domain_consolidator Failed to set machine id” (71020)

    This issue is caused by a mismatch between the FQDN that was configured as the PNID during the vCenter Server deployment and the hostname that is currently configured.

I had a mismatch happen because of the second entry: a host configured in a different domain than it was deployed to.

Here are the commands to list and change the hosts name, domain and fqdn:

# hostname --help
BusyBox v1.29.3 (2021-01-17 01:25:00 PST) multi-call binary.

Usage: hostname [OPTIONS] [HOSTNAME | -F FILE]

Get or set hostname or DNS domain name

    -s  Short
    -i  Addresses for the hostname
    -d  DNS domain name
    -f  Fully qualified domain name
    -F FILE Use FILE's content as hostname

And the commands to change them (see also ESXi 6.5: change the host name in the “new” vSphere HTML5 Web Client, or using DHCP option 12, where I let the DHCP server take care of this):

# esxcli system hostname set --help
Usage: esxcli system hostname set [cmd options]

Description: 
  set                   This command allows the user to set the hostname, domain name or fully qualified domain name of the ESX host.

Cmd options:
  -d|--domain=     The domain name to set for the ESX host. This option is mutually exclusive with the --fqdn option.
  -f|--fqdn=       Set the fully qualified domain name of the ESX host.
  -H|--host=       The host name to set for the ESX host. This name should not contain the DNS domain name of the host and can only contain letters, numbers and '-'. NOTE this is not the fully qualified name, that can be set with the --fqdn option.
                        This option is mutually exclusive with the --fqdn option.

Note that esxcli system hostname get always outputs all parts, and does not allow to split the parts, unlike the help shows:

# esxcli system hostname get --help
Usage: esxcli system hostname get [cmd options]

Description: 
  get                   Get the host, domain or fully qualified name of the ESX host.

Cmd options:

Examples:

# hostname -s
X9SRI3F-ESXi
# hostname -f
X9SRI3F-ESXi.fritz.box
# hostname -d
fritz.box
# hostname -i
192.168.124.41
# esxcli system hostname get
   Domain Name: fritz.box
   Fully Qualified Domain Name: X9SRI3F-ESXi.fritz.box
   Host Name: X9SRI3F-ESXi
# esxcli system hostname set --domain=fritz.box
# esxcli system hostname set --fqdn=X9SRI3F-ESXi.fritz.box
# esxcli system hostname set --host=X9SRI3F-ESXi

References:

  • [Wayback] ESXi date and time | Nbctcp’s Weblog
    #esxcli system hostname set –host=esx0
    #esxcli system hostname set –domain=poc.com
    #vim-cmd vimsvc/license –set xxxxx-xxxxx-xxxxx-xxxxx-xxxx
  • [Wayback] VMware : Changer le Hostname ESXi en CLI – VroomBlog which has a lot of screenshots with info blurred out, but the statements are OK after I set the markup to code and replaced all U+2013 EN DASH () with double dashes (--):
    # esxcli system hostname --help
    # esxcli system hostname get
    # esxcli system hostname set --host=Nom_Host
    # esxcli system hostname set --domain=Nom_De _Domain
    # esxcli system hostname set --fqdn=Nom_Host.Nom_De _Domain

    The last statement is marked “ou directement via”, which means that you can set the host and domain in one go using the fqdn syntax.

–jeroen

Leave a Reply

Fill in your details below or click an icon to log in:

WordPress.com Logo

You are commenting using your WordPress.com account. Log Out /  Change )

Twitter picture

You are commenting using your Twitter account. Log Out /  Change )

Facebook photo

You are commenting using your Facebook account. Log Out /  Change )

Connecting to %s

This site uses Akismet to reduce spam. Learn how your comment data is processed.

 
%d bloggers like this: