You can use ESXCLI to set up a DNS server.

The following example illustrates setting up a DNS server. Specify one of the options listed in Connection Options for vCLI Host Management Commands in place of <conn_options>.

Procedure

  1. Print a list of DNS servers configured on the system in the order in which they will be used.
    esxcli <conn_options> network ip dns server list
    If DNS is not set up for the target server, the command returns an empty string.
  2. Add a server by running esxcli network ip dns server add and specifying the server IPv4 or IPv6 address.
    esxcli <conn_options> network ip dns server add --server=<str>
  3. Change the DNS settings.
    • Specify the DNS server by using the --dns option and the DNS host.
      esxcli <conn_options> network ip dns server add --server=<server>
      Run the command multiple times to specify multiple DNS hosts.
    • Configure the DNS host name for the server specified by --server or --vihost.
      esxcli <conn_options> system hostname set --host=<new_host_name>
    • Configure the DNS domain name for the server specified by --server or --vihost.
      esxcli <conn_options> system hostname --domain=mydomain.biz
  4. To turn on DHCP, enable DHCP and set the VMkernel NIC.
    • Turn on DHCP for IPv4.
      esxcli <conn_options> network ip interface ipv4 set --type dhcp/none/static
      esxcli <conn_options> network ip interface ipv4 set --peer-dns=<str>
    • Turn on DHCP for IPv6.
      esxcli <conn_options> network ip interface ipv6 set --enable-dhcpv6=true/false
      esxcli <conn_options> network ip interface ipv6 set --peer-dns=<str>