Setting the DNS Configuration
You can set the DNS configuration with ESXCLI or with vicfg-dns.
Setting the DNS Configuration with ESXCLI
The esxcli network ip dns command lists and specifies the DNS configuration of your ESXi host.
In network environments where a DHCP server and a DNS server are available, ESXi hosts are automatically assigned DNS names.
In network environments where automatic DNS is not available or you do not want to use automatic DNS, you can configure static DNS information, including a host name, primary name server, secondary name server, and DNS suffixes.
The esxcli network ip dns namespace includes two namespaces.
esxcli network ip dns search includes commands for DNS search domain configuration.
esxcli network ip dns server includes commands for DNS server configuration.
The following example illustrates setting up a DNS server. Specify one of the options listed in Connection Options in place of <conn_options>.
To set up a DNS Server
1
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 address or IPv6 address.
esxcli <conn_options> network ip dns server add --server=<str>
3
Change the settings with esxcli network ip dns.
Specify the DNS server 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.
esxcli <conn_options> system hostname set --host=<new_host_name>
esxcli <conn_options> system hostname --domain=mydomain.biz
4
esxcli <conn_options> network ip interface ipv4 set --type dhcp/none/static
esxcli <conn_options> network ip interface ipv4 set --peer-dns=<str>
esxcli <conn_options> network ip interface ipv6 set --enable-dhcpv6=true/false
esxcli <conn_options> network ip interface ipv6 set --peer-dns=<str>
To modify DNS setup for a preconfigured server
1
esxcli <conn_options> system hostname get
esxcli <conn_options> network ip dns server list
esxcli <conn_options> network ip interface ipv4 get
esxcli <conn_options> network ip interface ipv6 get
2
If the DNS properties are set, and you want to change the DHCP settings, you must specify the virtual network adapter to use when overriding the system DNS. Override the existing DHCP setting as follows:
esxcli <conn_options> network ip interface ipv4 set --type dhcp/none/static
esxcli <conn_options> network ip interface ipv6 set --enable-dhcpv6=true/false
Setting the DNS Configuration with vicfg-dns
The vicfg-dns command lists and specifies the DNS configuration of your ESXi host. Call the command without command-specific options to list the existing DNS configuration. You can also use esxcli network ip dns for DNS management.
In network environments where a DHCP server and a DNS server are available, ESXi hosts are automatically assigned DNS names.
In network environments where automatic DNS is not available or not desirable, you can configure static DNS information, including a host name, primary name server, secondary name server, and DNS suffixes.
The following example illustrates setting up a DNS server. Specify one of the options listed in Connection Options in place of <conn_options>.
To set up DNS
1
Run vicfg-dns without command-specific options to display DNS properties for the specified server.
vicfg-dns <conn_options>
If DNS is not set up for the target server, the command returns an error.
2
To change the settings, use vicfg-dns with --dns, --domain, or --hostname.
Specify the DNS server by using the --dns option and a comma-separated list of hosts, in order of preference.
vicfg-dns <conn_options --dns <dns1,dns2>
vicfg-dns <conn_options> -n dns_host_name
vicfg-dns <conn_options> -d mydomain.biz
3
vicfg-dns <conn_options> --dhcp yes
To modify DNS setup for a preconfigured server
1
Run vicfg-dns without command-specific options to display DNS properties for the specified server.
vicfg-dns <conn_options>
The information includes the host name, domain name, DHCP setting (true or false), and DNS servers on the ESXi host.
2
If the DNS properties are set, and you want to change the DHCP settings, you must specify the virtual network adapter to use when overriding the system DNS. v_nic must be one of the VMkernel network adapters.
Override the existing DHCP setting as follows:
vicfg-dns <conn_options> --dhcp yes --v_nic <vnic>