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
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
#sudo nano /etc/resolv.conf
Modify or enter the nameserver as follows:
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 the nameserver as follows:
nameserver IP-ADDRESS
nameserver IP-ADDRESS
Save and close the file. To test DNS configuration type any one of the following commands:
$ host google.com
If you see valid output such as actual IP address or are able to ping to a remote server via hostname, it means that the DNS is working for you