Resolv.conf options not being honored

digdomain-name-systemresolv.conf

Was hoping to implement the "options rotate" directive within resolv.conf to have DNS lookups rotate through the nameservers listed in that file. As I understand it that is the point of this directive. It does not work on any system that I have tried to date. It always uses the first nameserver directive in the file and disregards the rest unless of an error.

I tested by using a fake DNS python script that mimics a DNS server and always replies with the same bogus 192.168.1.1 address regardless of the request. When placed first in the file it would always go to this server and when placed second it would never go. This is with the "options rotate" directive included in the file.

# cat /etc/resolv.conf
search some.toplevel
options rotate
nameserver 10.0.0.2 <- fake python DNS server
nameserver 10.0.0.3 <- real DNS server

Fake DNS server pythons script used

Also, I used the dig command and the host command. I verified they make use of the resolv library. I tried this on CentOS 5.6 as well as on my personal ubuntu with totally different versions of the related packages. I'm totally stumped here, need some help on this one.

Best Answer

There's a hint about this on http://docstore.mik.ua/orelly/networking_2ndEd/dns/ch06_01.htm:

In other words, an instance of the resolver still queries the first name server in resolv.conf first, but for the next domain name it looks up, it queries the second name server first, and so on.

Note that many programs can't take advantage of this since most programs initialize the resolver, look up a name, then exit. Rotation has no effect on repeated ping commands, for example, because each ping process initializes the resolver, queries the first name server in resolv.conf, and then exits before using the resolver again. Each successive invocation of ping has no idea which name server the previous one used -- or even that ping was run earlier. But long-lived processes that send lots of queries, such as a sendmail daemon, can take advantage of rotation.