I was trying to fix an issue on a server that use mesos-dns.
I discovered a CentOS host with this strange configuration in /etc/resolv.conf
:
# Generated by NetworkManager
search mycorp.corp
# handle company names
nameserver 10.0.0.10
nameserver 10.0.0.11
# handle .mesos
nameserver 10.0.0.100
nameserver 10.0.0.110
nameserver 10.0.0.120
Wow many entries. I usually found only two entries. How does it works? How the OS will choose between the different entry? What is the alogrithm?
As usual, I first read the manual with man resolv.conf
.
Up to MAXNS (currently 3, see <resolv.h>) name servers may be listed, one
per keyword. If there are multiple servers, the resolver library queries them
in the order listed.
I checked in the resolver header file:
% egrep "define MAXNS" /usr/include/resolv.h
# define MAXNS 3 /* max # name servers we'll track */
Same result. So it useless to put more than three entry in your resolv.conf. The code source of the resolver in glibc 2.12.2 show also many loop with an upper limit of MAXNS. For exemple in res_send.c line 392:
for (ns = 0; ns < MAXNS; ns++) {
So take care with /etc/resolv.conf if you put more than three nameserver, extra entries will be silently ignored. And RTFM :-)