美文网首页
Dnsmasq一个超有用的选项

Dnsmasq一个超有用的选项

作者: aneirin | 来源:发表于2020-06-27 13:34 被阅读0次

公司内网使用的DNS服务是用软件Dnsmasq搭建的,最近经常有同事反映一些网站打不开,先前都是可以的。用dig命令分析,显示如下:

aneirin@host-1:~$ time dig @192.168.1.1 www.baidu.com

; <<>> DiG 9.16.4-Debian <<>> @192.168.1.1 www.baidu.com
; (1 server found)
;; global options: +cmd
;; connection timed out; no servers could be reached


real    0m15.008s
user    0m0.008s
sys     0m0.005s

Dnsmasq上游服务器使用的是腾讯DNS服务器119.29.29.29,dig命令同样得不到结果(公共DNS因为请求量大,会不太稳定),

aneirin@host-1:~$ dig @119.29.29.29 www.baidu.com

; <<>> DiG 9.11.5-P4-5.1+deb10u1-Debian <<>> @119.29.29.29 www.baidu.com
; (1 server found)
;; global options: +cmd
;; connection timed out; no servers could be reached

查询Dnsmasq官方文档,发现选项“--all-servers”可以解决这个问题,文档是这样介绍这个选项的:
--all-servers
By default, when dnsmasq has more than one upstream server available, it will send queries to just one server. Setting this flag forces dnsmasq to send all queries to all available servers. The reply from the server which answers first will be returned to the original requester.
在配置文件“/etc/default/dnsmasq”中加入该选项,

DNSMASQ_OPTS="--all-servers"

配置文件“/etc/dnsmasq.conf”中加入两个上游DNS服务器,一个阿里的223.5.5.5,另一个还是使用腾讯的DNS,

server=223.5.5.5        # AliDNS
server=119.29.29.29    # TencentDNS

运行了几周,再没有发现解析超时的情况出现。

相关文章

网友评论

      本文标题:Dnsmasq一个超有用的选项

      本文链接:https://www.haomeiwen.com/subject/umwmfktx.html