Answers:
我没有访问权限,dnsmasq
但根据这个标题为dnsmasq的线程,它是否在缓存?您可以将信号USR1发送到该dnsmasq
进程,使它将统计信息转储到系统日志中。
$ sudo pkill -USR1 dnsmasq
然后查阅系统日志:
$ sudo tail /var/log/syslog
Jan 21 13:37:57 dnsmasq[29469]: time 1232566677
Jan 21 13:37:57 dnsmasq[29469]: cache size 150, 0/475 cache insertions re-used unexpired cache entries.
Jan 21 13:37:57 dnsmasq[29469]: queries forwarded 392, queries answered locally 16
Jan 21 13:37:57 dnsmasq[29469]: server 208.67.222.222#53: queries sent 206, retried or failed 12
Jan 21 13:37:57 dnsmasq[29469]: server 208.67.220.220#53: queries sent 210, retried or failed 6
注意:我相信,它将dnsmasq
保留其缓存在RAM中。
因此,如果要转储缓存,则需要-q
在dnsmasq
调用时启用该开关。dnsmasq
手册页中提到了这一点:
-d, --no-daemon
Debug mode: don't fork to the background, don't write a pid file,
don't change user id, generate a complete cache dump on
receipt on SIGUSR1, log to stderr as well as syslog, don't fork new
processes to handle TCP queries. Note that this option is for use in
debugging only, to stop dnsmasq daemonising in production, use -k.
-q, --log-queries
Log the results of DNS queries handled by dnsmasq. Enable a full
cache dump on receipt of SIGUSR1.
logread | tail
。
journalctl
输出中发出SIGUSR1后,我找不到dnsmasq的任何条目。有没有一种方法可以明确指定dnsmasq应该在哪里转储记录?
从手册页获取此信息的另一种方法:
DNS中也可以使用缓存统计信息作为对CHAOS类和域绑定中的TXT类型查询的答案。域名为cachesize.bind,insertions.bind,evictions.bind,misses.bind,hits.bind,auth.bind和servers.bind。使用dig实用程序进行查询的示例命令为
dig +short chaos txt cachesize.bind
dig +short chaos txt hits.bind
dig +short chaos txt misses.bind
如果您的系统上有类似systemd-resolve的内容,则需要使用以下命令直接查询服务器:
dig +short chaos txt hits.bind @serverIP