Server Fault is a question and answer site for system and network administrators. Join them; it only takes a minute:

Sign up
Here's how it works:
  1. Anybody can ask a question
  2. Anybody can answer
  3. The best answers are voted up and rise to the top

My resolv.conf looks like this:

; generated by /sbin/dhclient-script
search mcdc

if I do nslookup it works

;; Got SERVFAIL reply from, trying next server

Non-authoritative answer:  canonical name =

but when I curl, it cannot resolve the host.

I tried running curl under strace, and found curl was only using the first nameserver in resolv.conf, not the second. If I switch the two nameserver lines around, resolves, but internal DNS names do not, so thats not a good workaround.

How can I fix resolv.conf to use both nameservers?

share|improve this question
up vote 9 down vote accepted

The default behavior for resolv.conf and the resolver is to try the servers in the order listed. The resolver will only try the next nameserver if the first nameserver times out. The resolv.conf manpage says:

nameserver Name server IP address

Internet address (in dot notation) of a name server that the resolver should query. Up to MAXNS (currently 3, see ) name servers may be listed, one per keyword. If there are multiple servers, the resolver library queries them in the order listed.


(The algorithm used is to try a name server, and if the query times out, try the next, until out of name servers, then repeat trying all the name servers until a maximum number of retries are made.)

Also see the resolver(5) manual page for more information.

You can alter the resolver's behavior using rotate, which will query the Nameservers in a round-robin order:

rotate sets RES_ROTATE in _res.options, which causes round robin selection of nameservers from among those listed. This has the effect of spreading the query load among all listed servers, rather than having all clients try the first listed server first every time.

However, nslookup will use the second nameserver if it receives a SERVFAIL from the first nameserver. From the nslookup manpage:

[no]fail Try the next nameserver if a nameserver responds with SERVFAIL or a referral (nofail) or terminate query (fail) on such a response.

(Default = nofail)

share|improve this answer

Is a recursive dns server aka resolver?

Or is it only an authoritative server for your internal zones?

You should set up an internal resolver that might also be holding your authoritative data.

share|improve this answer

If you can, I would configure it in this fashion.

search mcdc

share|improve this answer
Which part of the question indicates they run a DNS server on their machine, or want to? – Jay Jun 14 '12 at 16:57
Blake: Note that is typically only used for systems which have a name server caching daemon on the local host. See – Stefan Lasiewski Jun 14 '12 at 18:18

Your Answer


By posting your answer, you agree to the privacy policy and terms of service.

Not the answer you're looking for? Browse other questions tagged or ask your own question.