/etc/hosts file.nslookup <hostname.example.com>
Example for a failed DNS resolution:
root@<host> [ ~ ]# nslookup hostname.example.com;; connection timed out; no servers could be reached
Example for a successful DNS resolution:
root@<host> [ ~ ]# nslookup hostname.example.comServer: <DNS_Server>.example.comAddress: <###.##.##.###>#53
Name: hostname.example.comAddress: ###.##.##.###
cp /etc/hosts /etc/hosts.backup
Note: Changes made to /etc/hosts on ESXi host 7.0 U3 and above is not persistent after an ESXi reboot. Use ESXCLI method to add or remove the host entry: Configure the DNS Hosts File by Using ESXCLI Commands
1. Login to ESXi host or vCenter via SSH as a root user
2. Use vi editor to edit the /etc/hosts file.
vi /etc/hosts
3. Add or edit or delete a host entry in the /etc/hosts file:
a. Add a host entry in the /etc/hosts file on a vCenter server or ESXi host.
b. Edit a host entry in the /etc/hosts file on a vCenter server or ESXi host.
c. Delete a host entry in the /etc/hosts file on a vCenter server or ESXi host.
1. In the vi editor, press i to enter in to insert mode to start editing where the cursor is, or press o to start editing on a new line below the cursor. The bottom of the vi editor may show -- INSERT -- while the insert mode is active within vi.
2. Add the required host entry at the bottom line in the below forma.
<IP address> <hostname.example.com> <host_shortname>
Example: 192.##.##.### hostname.example.com hostname
3. Save the file and exit (press ESC, type :wq!, press Enter).
4. To exit vi editor without saving the file, press Esc, type :q, then press Enter.
1. In the vi editor, without entering insert mode, use the arrow keys to move to the character that needs to be modified, press R, then press the key for the character you want to change to. This option can be used to modify minor changes like IP address, hostname.
2. Save the file and exit (press ESC, type :wq!, press Enter).
3. To exit vi editor without saving the file, press Esc, type :q, then press Enter.
1. In the vi editor, use arrow keys to point the cursor to the host entry that needs to be delete.
2. Press d twice to delete the whole line. You can also press x to delete only one character at a time when you are not in insert mode.
3. Save the file and exit (press ESC, type :wq!, press Enter).
4. To exit vi editor without saving the file, press Esc, type :q, then press Enter.