Dnsmasq

如何衡量 DNS 記憶體效率/記憶體項目?

  • December 10, 2020

我已dnsmasq在 Debian 伺服器上配置為僅記憶體 DNS 伺服器,並且執行良好(我通過 dig 看到改進的 DNS 響應時間)。

但是,我想隨時了解什麼dnsmasq是記憶體,以便我可以開始考慮我正在實現的效率(即命中率)。

我查看了手冊頁和網路,但無法找到我dnsmasq在任何時候看到的記憶體內容(不像您可以為租約做的那樣,例如,租約保存在 dnsmasq.lease 文件中)。

dnsmasqDNS記憶體是否僅保存在記憶體中?還是我必須做一些日誌文件修改?

我無權訪問,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.

引用自:https://unix.stackexchange.com/questions/162973