domain-name-system – / etc / resolv.conf中的第二个名称服务器未被wget选中

我的resolv.conf看起来像这样:
; 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以使用两个名称服务器?

解决方法

resolv.conf和解析程序的默认行为是按列出的顺序尝试服务器.如果第一个名称服务器超时,解析器将只尝试下一个名称服务器. resolv.conf manpage说:

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)

相关文章

HTML代码中要想改变字体颜色,常常需要使用CSS样式表。CSS是...
HTML代码如何让字体盖住图片呢?需要使用CSS的position属性及...
HTML代码字体设置 在HTML中,我们可以使用标签来设置网页中的...
在网页设计中,HTML代码的字体和字号选择是非常重要的一个环...
HTML(Hypertext Markup Language,超文本标记语言)是一种用...
外链是指在一个网页中添加一个指向其他网站的链接,用户可以...