我已dnsmasq在 Debian 服务器上配置为仅缓存 DNS 服务器,并且运行良好(我发现通过 dig 改进了 DNS 响应时间)。
但是,我想dnsmasq在任何时候了解什么是缓存,以便我可以开始考虑我正在实现的效率(即命中率)。
我已经查看了手册页和网络,但找不到我如何dnsmasq在任何时候看到缓存的内容(例如,您可以为租用做的事情不同,租用保存在 dnsmasq.lease 文件中)。
dnsmasqDNS 缓存是否仅保存在内存中?还是我必须做一些日志文件处理?
slm*_*slm 23
我无权访问,dnsmasq但根据标题为:dnsmasq 是否缓存?您可以向dnsmasq进程发送信号 USR1 ,使其将统计信息转储到系统日志中。
$ sudo pkill -USR1 dnsmasq
Run Code Online (Sandbox Code Playgroud)
然后查阅系统日志:
$ 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
Run Code Online (Sandbox Code Playgroud)
注意:我相信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.
Run Code Online (Sandbox Code Playgroud)
小智 5
从手册页获取此信息的另一种方法:
缓存统计信息也可在 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
Run Code Online (Sandbox Code Playgroud)
如果您的系统上有类似 systemd-resolve 的东西,那么您需要直接使用以下命令查询服务器:
dig +short chaos txt hits.bind @serverIP
Run Code Online (Sandbox Code Playgroud)