Dnsmasqcaching和内部日志USR1信号转储(运行有或没有–no-daemon和–log-queries进行分析时)总是显示:0/0caching,意味着Dnsmasq的cachingfunction不起作用。
还观察到虽然重复的DNS A(主机查询)和A(响应)logging在连续的相同的监听接口上成功地被填充,但是caching计数仍然为0。
任何人有任何想法如何解决/debugging此Dnsmasqcaching不工作的问题?
或者,请build议另一个Ubuntu Linux支持的DNScaching工具,可以configuration为有针对性的接口。
dnsmasq:caching大小150,0 / 0caching插入重新使用的未过期的caching条目
root@host1:~# sudo pkill -USR1 dnsmasq dnsmasq: query[AAAA] host1 from 127.0.0.1 dnsmasq: query[AAAA] host1 from 127.0.0.1 dnsmasq: query[A] host1 from 127.0.0.1 dnsmasq: query[A] host1 from 127.0.0.1 sudo: unable to resolve host host1 dnsmasq: time 1432979095 dnsmasq: cache size 150, 0/0 cache insertions re-used unexpired cache entries. dnsmasq: queries forwarded 0, queries answered locally 4 dnsmasq: Host Address Flags Expires dnsmasq: ip6-loopback ::1 6F IH dnsmasq: pep 127.0.1.1 4FRI H dnsmasq: ip6-mcastprefix ff00:: 6FRI H dnsmasq: ip6-allrouters ff02::2 6FRI H dnsmasq: ip6-localhost ::1 6FRI H dnsmasq: localhost 127.0.0.1 4FRI H dnsmasq: ip6-allnodes ff02::1 6FRI H dnsmasq: ip6-localnet fe00:: 6FRI H [1]- User defined signal 1 /etc/init.d/dnsmasq restart root@host1:~# TCPDUMP ON DNSMASQ Interface: 05:40:47.555213 IP 172.20.20.10.52592 > 172.20.20.2.53: 8856+ A? app.host2.com. (45) 05:40:47.558364 IP 172.20.20.2.53 > 172.20.20.10.52592: 8856* 1/0/0 A 10.60.60.190 (61) 05:41:52.875128 IP 172.20.20.10.60448 > 172.20.20.2.53: 11981+ A? app.host2.com. (45) 05:41:52.878377 IP 172.20.20.2.53 > 172.20.20.10.60448: 11981* 1/0/0 A 10.60.60.190 (61) 05:42:44.241724 IP 172.20.20.10.65300 > 172.20.20.2.53: 6667+ A? app.host2.com. (45) 05:42:44.244808 IP 172.20.20.2.53 > 172.20.20.10.65300: 6667* 1/0/0 A 10.60.60.190 (61) Dnsmasq setting: /etc/dnsmasq.conf log-facility=/var/log/dnsmasq.log log-queries log-dhcp no-daemon listen-address=10.20.20.15 port=53 interface=eth0 bind-interfaces cache-size=1000 neg-ttl=3600 Dnsmasq Running as inline from default: root@host1:~# /etc/init.d/dnsmasq restart * Restarting DNS forwarder and DHCP server dnsmasq dnsmasq: started, version 2.68 cachesize 1000 dnsmasq: compile time options: IPv6 GNU-getopt DBus i18n IDN DHCP DHCPv6 no-Lua TFTP conntrack ipset auth dnsmasq: reading /etc/resolv.conf dnsmasq: using nameserver 11.45.45.9#53 dnsmasq: read /etc/hosts - 7 addresses User defined signal 1 root@host1:~# dnsmasq: time 1433019086 dnsmasq: cache size 1000, 0/0 cache insertions re-used unexpired cache entries. dnsmasq: queries forwarded 0, queries answered locally 0 dnsmasq: queries for authoritative zones 0 dnsmasq: Host Address Flags Expires dnsmasq: ip6-allnodes ff02::1 6FRI H dnsmasq: ip6-localnet fe00:: 6FRI H dnsmasq: ip6-localhost ::1 6FRI H dnsmasq: pep 127.0.1.1 4FRI H dnsmasq: ip6-mcastprefix ff00:: 6FRI H dnsmasq: localhost 127.0.0.1 4FRI H dnsmasq: ip6-loopback ::1 6F IH dnsmasq: ip6-allrouters ff02::2 6FRI H Dnsmasq process status: root@host1:~# ps aux | grep dnsmasq dnsmasq 23437 0.0 0.0 27636 936 ? S 16:36 0:00 /usr/sbin/dnsmasq -x /var/run/dnsmasq/dnsmasq.pid -u dnsmasq -r /var/run/dnsmasq/resolv.conf -7 /etc/dnsmasq.d,.dpkg-dist,.dpkg- old,.dpkg-new Dnsmasq package status: root@host1:~# dpkg -l | grep dnsmasq ii dnsmasq 2.68-1 all Small caching DNS proxy and DHCP/TFTP server ii dnsmasq-base 2.68-1 amd64 Small caching DNS proxy and DHCP/TFTP server ii dnsmasq-utils 2.68-1
我也遇到这个问题,find了我想的根本原因。
请捕获您DNS答复的wireshark转储,并检查“recursion可用”字段是否设置为“服务器可以执行recursion查询”,如果没有设置,那么这些响应将不会被添加到caching。
我遇到了同样的问题。 删除有利于interface listen-address了这个问题 – 这实际上看起来像是在dnsmasq中的一个bug。
关于Arun的回答,我的情况是可以recursion的。
小testing脚本:
sudo kill -usr1 $(pidof dnsmasq) for ((n=0;n<100;n++)); do dig @127.0.0.1 google.com; done sudo kill -usr1 $(pidof dnsmasq) tail /var/log/syslog