; generated by /sbin/dhclient-script search mcdc nameserver 10.0.4.48 nameserver 8.8.8.8
如果我做nslookup www.google.com它的工作原理
nslookup www.google.com ;; Got SERVFAIL reply from 10.0.4.48,trying next server Server: 8.8.8.8 Address: 8.8.8.8#53 Non-authoritative answer: www.google.com canonical name = www.l.google.com.
但是当我卷曲www.google.com时,它无法解析主机.
我尝试在strace下运行curl,发现curl只使用resolv.conf中的第一个名称服务器,而不是第二个.如果我切换两个名称服务器行,www.google.com解析,但内部DNS名称没有,所以这不是一个好的解决方法.
如何修复resolv.conf以使用两个名称服务器?
解决方法
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.)
有关更多信息,另请参见resolver(5)手册页.
您可以使用rotate更改解析程序的行为,这将以循环顺序查询名称服务器:
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.
但是,如果nslookup从第一个名称服务器接收到SERVFAIL,它将使用第二个名称服务器.从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)