Renew DNS Servers in VMWare ESXi via ESXCLI Commands

About Issue

If you need to renew DNS servers on an ESXi host and are having trouble finding the DNS field in the ESXi portal, you can use ESXCLI commands to update the DNS servers.


Procedure

  1. Enable SSH Service first on ESXi

  1. Open a console or SSH session to the ESXi host.
ssh root@esxi_ip_address
  1. List Current DNS server IP Address Run the command
esxcli network ip dns server list

DNSServers: 10.1.1.253, 10.1.1.254

  1. Add new DNS server IP address

In this scenario, I use 1.1.1.1 and 1.0.0.1 as the new DNS server address.

esxcli network ip dns server add --server=1.1.1.1
esxcli network ip dns server add --server=1.0.0.1
  1. Remove the exsiting (old) DNS address

Refer to previous list the DNS address (10.1.1.253, 10.1.1.254)

esxcli network ip dns server remove --server=10.1.1.253
esxcli network ip dns server remove --server=10.1.1.254
  1. List Current DNS server IP Address after update.
esxcli network ip dns server list

DNSServers: 1.1.1.1, 1.0.0.1

  1. Finally diable SSH Service on ESXi


Conclusion

Using the ESXCLI commands to update DNS servers is particularly useful when the DNS field is not easily accessible in the ESXi portal, or when there are a large number of ESXi hosts to update.


Reference