Home > Support > HOWTO List > Checking /etc/resolv.conf name servers

Checking /etc/resolv.conf name servers

Linux servers can use /etc/resolv.conf to list name servers that the server will use when trying to convert a domain name (like example.com) to an IP address (like that it can use.

/etc/resolv.conf can have one or more name server entries.  If one name server is not working, then the server will attempt to use another one.

If one of the name servers in the /etc/resolv.conf is not working then you can see all sorts of 'odd' problems crop up on your server. Basically anything that does a domain name lookup can be affected. For example, mail receiving could get slowed down, since if your mail server converts the IP address of the server it is connecting to to a domain name via its ptr dns record.

Typically the symptom will be that tasks that require lookups take a 'long time' (30 seconds to a few minutes) to complete.  Since the server may be trying non-responsive name servers and waiting for a dns timeout.

To check that your name server entries are working run the following:

ns=$(cat /etc/resolv.conf  | grep -v '^#' | grep nameserver | awk '{print $2}')
for i in $ns; do ptr=$(host $i | sed 's/Name: //' | sed 's/ .*//g' | head -n 1)
  if dig @$i -t ns rimuhosting.com |grep -qai 'rimuhosting'; then 
    echo $i $ptr OK; 
    echo $i $ptr failed; 

You can use this script to replace non-working DNS servers in your /etc/resolv.conf: http://proj.ri.mu/fixdns (or if your dns is not working:

The easiest way to run it is with something like this:

wget -O fixdns
bash fixdns