驗證 dnsmasq 配置

驗證 dnsmasq 配置

如何驗證dnsmasq配置?

dnsmasq曾經能夠在 中提供有關其自身的詳細信息/var/log/daemon.log,如中所述dnsmasq 測試

但是,當我重新啟動 dnsmasq 服務時,沒有記錄任何內容/var/log/daemon.log

% echo "    *** DEBUG `date --rfc-3339=seconds` DEBUG *** " >> /var/log/daemon.log

% service dnsmasq restart 
* Restarting DNS forwarder and DHCP server dnsmasq                      [ OK ] 

% tail /var/log/daemon.log
*** DEBUG 2013-11-27 23:04:08-05:00 DEBUG *** 

這是 Ubuntu 13.10 Saucy。

答案1

--無守護程式

dnsmasq如果直接運行它,則會將錯誤列印到終端。 ie dnsmasq --no-daemon,或使用所有日誌記錄選項:

$ dnsmasq --no-daemon --log-queries=extra --log-dhcp --log-debug -C /path/to/dnsmasq.conf

dnsmasq它自己會嘗試啟動 dnsmasq,如果發現任何問題,則會在配置中給出行號。

- 測試

dnsmasq --test將對設定檔進行基本語法檢查。如果成功,它應該會列印類似的內容

$ dnsmasq --test
dnsmasq: syntax check OK.

人為的失敗看起來像

$ echo 'A-VERY-BAD-OPTION' > /tmp/tmp.conf
$ dnsmasq -C /tmp/tmp.conf --test

dnsmasq: bad option at line 1 of /tmp/tmp.conf

權限

如果您在沒有然後sudo的情況下測試良好的配置,dnsmasq 最終應該達到嘗試開始偵聽連接埠 53 的階段,但由於權限而失敗。

如果您使用sudo(或您port=1024在配置中設定或更高),那麼 dnsmasq 實際上應該開始運行,但您可能必須kill手動執行該過程。如果您使用過--no-daemon,那麼這很容易做到Ctrl-C

答案2

AFAIK dnsmasq 通常會記錄到 syslog 服務。預設情況下它使用設施 DAEMON。

FWIW:「它對我有用」(在 Fedora 18 / 19 中)。

如果您沒有看到任何訊息,我建議您驗證您的系統日誌配置。或者,更實際的方法是嘗試「grep -c dnsmasq /var/log/*」之類的方法。

另請參閱此處手冊頁中的登入詳細說明: http://www.thekelleys.org.uk/dnsmasq/docs/dnsmasq-man.html

那裡提到的日誌記錄還有一些其他可能性會影響其行為,例如,如果設施包含“/”字元。

其他子系統 (sys-) 日誌記錄是否正確?您可以使用「logger」指令讓 syslog 記錄訊息嗎?

哈!

羅布。

答案3

DNSMASQ 是 linux/unix 上常見的 DNS/DHCP cace 解決方案之一,一些很好的連結:

help.ubuntu.com/community/Dnsmasq manpages.ubuntu.com/manpages/lucid/man8/dnsmasq.8.html wiki.debian.org/HowTo/dnsmasq

  1. 驗證步驟:開啟/etc/dnsmasq.conf下的偵錯日誌記錄:

日誌查詢
日誌 dhcp

  1. 然後,重新啟動並在挖掘主機名稱時觀察日誌:

在 debian 變體上,dnsmasq 預設會記錄在 /var/log/syslog 中。

相關內容