Add name servers to the configuration file
On Linux, the DNS servers that the system uses for name resolution are defined in the /etc/resolv.conf file. That file should contain at least one
The name servers are prioritized in the order the system finds them in the file. Use the IP addresses of the name servers when entering them, because the system won’t know what to do with domain names
until after it knows how to get to the DNS servers.
Open the resolv.conf file with an editor, such as
#sudo nano /etc/resolv.conf
Modify or enter nameserver as follows:
nameserver IP-ADDRESS
nameserver IP-ADDRESS
Save and close the file. To test DNS configuration type any one of the following command:
$host google.com
If you see valid output such as actual IP address or able to ping to remote server via hostname, it means that the dns is working for you
nameserver
line. Each nameserver
line defines a DNS server. The name servers are prioritized in the order the system finds them in the file. Use the IP addresses of the name servers when entering them, because the system won’t know what to do with domain names
until after it knows how to get to the DNS servers.
Open the resolv.conf file with an editor, such as
nano
, to make the necessary changes (if it doesn’t exist already, this command creates the file).#sudo nano /etc/resolv.conf
Modify or enter nameserver as follows:
nameserver IP-ADDRESS
nameserver IP-ADDRESS
Save and close the file. To test DNS configuration type any one of the following command:
$host google.com
If you see valid output such as actual IP address or able to ping to remote server via hostname, it means that the dns is working for you