Centos – Why don’t the server query the 2nd entry in the resolv.conf

centosdomain-name-systemresolv.conf

I have a CentOS 6.4 box.

As with all the other boxes in this rack, it has two NICs: one internal (192.168.1.x) and one external (visible to the world).

We run our own cacheing resolver (using Unbound) on one of the servers in our rack (192.168.1.11), and it has some local DNS entries configured (mario.local, luigi.local, etc.) so that we can simply ping/ssh/ftp to "hostname" FROM any local box TO any other local box without going over one of the external switches (which incurs charges from our ISP).

If my /etc/resolv.conf looks like this:

search local
nameserver 192.168.1.11
nameserver 8.8.8.8
nameserver 74.82.42.42

and I ping "mario" I get:

# ping mario
PING mario.local (192.168.1.3) 56(84) bytes of data.
64 bytes from 192.168.1.3: icmp_seq=1 ttl=64 time=0.738 ms

However, the local DNS server is much slower than the Google public DNS server, so I'd prefer to have that one first in the list. So if I change /etc/resolve.conf to this:

search local
nameserver 8.8.8.8
nameserver 192.168.1.11
nameserver 74.82.42.42

I would expect a ping to "mario" to attempt resolution of mario.local on 8.8.8.8, fail, then query the 2nd DNS server in the list (192.168.1.11) and resolve. But instead, I get:

# ping mario
ping: unknown host mario

Any idea what I'm doing wrong – or am I misunderstanding how resolve.conf is supposed to work? I'm wondering if it could it be related to routing.

My expectation is that if the first DNS server can't resolve an IP, the second resolv.conf entry gets a shot, but that's not working. Help!

Best Answer

The resolver will query the second name server only if the attempt to reach the first name server times out. In your case, it is not a time out issue, it is a resolution failure, so there is no need to query the remaining name servers.

You can test this by adding an IP which doesn't have a name server running in the first line, and the real name server below it - like this

 search local
 nameserver 1.2.3.4
 nameserver 192.168.1.11
 nameserver 8.8.8.8

The first one will definitely time out, then the remaining name server will be queried in that order.

Related Topic