dnsmasq 在 Debian 上啟動失敗

dnsmasq 在 Debian 上啟動失敗

這是systemctl status dnsmasq.service的內容:

● dnsmasq.service - dnsmasq - A lightweight DHCP and caching DNS server
   Loaded: loaded (/lib/systemd/system/dnsmasq.service; enabled; vendor preset: enabled)
   Active: failed (Result: exit-code) since Sat 2019-06-29 12:37:37 CEST; 23s ago
  Process: 24641 ExecStart=/etc/init.d/dnsmasq systemd-exec (code=exited, status=2)
  Process: 24638 ExecStartPre=/usr/sbin/dnsmasq --test (code=exited, status=0/SUCCESS)

這是期刊內容:

-- Logs begin at Tue 2019-06-25 11:49:21 CEST, end at Sat 2019-06-29 12:48:50 CEST. --
Jun 25 11:49:29 EddLinux kernel: nouveau 0000:01:00.0: preinit failed with -22
Jun 25 11:49:29 EddLinux kernel: nouveau: DRM:00000000:00000080: init failed with -22
Jun 25 11:49:32 EddLinux avahi-daemon[297]: chroot.c: open() failed: No such file or directory
Jun 25 11:49:33 EddLinux systemd-rfkill[421]: Failed to open device: No such device
Jun 25 11:49:35 EddLinux dhclient[502]: Failed to get interface index: No such device
Jun 25 11:49:35 EddLinux dhclient[502]: 
Jun 25 11:49:35 EddLinux dhclient[502]: If you think you have received this message due to a bug rather
Jun 25 11:49:35 EddLinux dhclient[502]: than a configuration issue please read the section on submitting
Jun 25 11:49:35 EddLinux dhclient[502]: bugs on either our web page at www.isc.org or in the README file
Jun 25 11:49:35 EddLinux dhclient[502]: before submitting a bug.  These pages explain the proper
Jun 25 11:49:35 EddLinux dhclient[502]: process and the information we find helpful for debugging..
Jun 25 11:49:35 EddLinux dhclient[502]: 
Jun 25 11:49:35 EddLinux dhclient[502]: exiting.
Jun 25 11:49:35 EddLinux systemd[1]: Failed to start Raise network interfaces.
Jun 25 11:49:44 EddLinux wpa_supplicant[571]: nl80211: Unexpected encryption algorithm 5
Jun 25 12:17:49 EddLinux wpa_supplicant[571]: nl80211: Unexpected encryption algorithm 5
Jun 25 13:32:38 EddLinux wpa_supplicant[571]: nl80211: Unexpected encryption algorithm 5
Jun 25 13:32:43 EddLinux wpa_supplicant[571]: nl80211: Unexpected encryption algorithm 5
Jun 25 17:36:10 EddLinux wpa_supplicant[571]: nl80211: Unexpected encryption algorithm 5
Jun 25 18:29:26 EddLinux kernel: ACPI Error: No installed handler for fixed event - PowerButton (2), disabling (20160831/evevent-291)
Jun 25 18:46:36 EddLinux wpa_supplicant[571]: nl80211: Unexpected encryption algorithm 5
Jun 25 18:50:57 EddLinux kernel: ACPI Error: No installed handler for fixed event - PowerButton (2), disabling (20160831/evevent-291)
Jun 26 12:29:22 EddLinux wpa_supplicant[571]: nl80211: Unexpected encryption algorithm 5
Jun 26 13:08:52 EddLinux anacron[4522]: Can't find sendmail at /usr/sbin/sendmail, not mailing output
Jun 26 14:20:05 EddLinux wpa_supplicant[571]: nl80211: Unexpected encryption algorithm 5
Jun 26 14:31:18 EddLinux kernel: ACPI Error: No installed handler for fixed event - PowerButton (2), disabling (20160831/evevent-291)
Jun 26 15:38:34 EddLinux wpa_supplicant[571]: nl80211: Unexpected encryption algorithm 5
Jun 26 15:38:47 EddLinux kernel: sd 6:0:0:0: [sdb] No Caching mode page found
Jun 26 15:38:47 EddLinux kernel: sd 6:0:0:0: [sdb] Assuming drive cache: write through
Jun 26 15:42:56 EddLinux kernel: ACPI Error: No installed handler for fixed event - PowerButton (2), disabling (20160831/evevent-291)
Jun 26 15:52:46 EddLinux wpa_supplicant[571]: nl80211: Unexpected encryption algorithm 5
Jun 26 16:21:11 EddLinux kernel: ACPI Error: No installed handler for fixed event - PowerButton (2), disabling (20160831/evevent-291)
Jun 26 17:39:35 EddLinux wpa_supplicant[571]: nl80211: Unexpected encryption algorithm 5
Jun 26 18:16:05 EddLinux kernel: ACPI Error: No installed handler for fixed event - PowerButton (2), disabling (20160831/evevent-291)
Jun 26 18:25:44 EddLinux wpa_supplicant[571]: nl80211: Unexpected encryption algorithm 5
Jun 26 20:30:11 EddLinux kernel: ACPI Error: No installed handler for fixed event - PowerButton (2), disabling (20160831/evevent-291)
Jun 27 16:39:10 EddLinux wpa_supplicant[571]: nl80211: Unexpected encryption algorithm 5
Jun 27 17:06:50 EddLinux anacron[11980]: Can't find sendmail at /usr/sbin/sendmail, not mailing output
Jun 27 17:38:13 EddLinux kernel: ACPI Error: No installed handler for fixed event - PowerButton (2), disabling (20160831/evevent-291)
Jun 27 18:11:44 EddLinux wpa_supplicant[571]: nl80211: Unexpected encryption algorithm 5
Jun 27 18:12:28 EddLinux wpa_supplicant[571]: nl80211: Unexpected encryption algorithm 5
Jun 27 18:50:12 EddLinux kernel: ACPI Error: No installed handler for fixed event - PowerButton (2), disabling (20160831/evevent-291)
Jun 28 11:46:18 EddLinux wpa_supplicant[571]: nl80211: Unexpected encryption algorithm 5
Jun 28 11:48:33 EddLinux kernel: sd 6:0:0:0: [sdb] No Caching mode page found
Jun 28 11:48:33 EddLinux kernel: sd 6:0:0:0: [sdb] Assuming drive cache: write through
Jun 28 11:48:55 EddLinux kernel: FAT-fs (sdb1): unable to read boot sector to mark fs as dirty
Jun 28 11:53:31 EddLinux kernel: sd 6:0:0:0: [sdb] No Caching mode page found
Jun 28 11:53:31 EddLinux kernel: sd 6:0:0:0: [sdb] Assuming drive cache: write through
Jun 28 11:53:41 EddLinux wpa_supplicant[571]: nl80211: Unexpected encryption algorithm 5
Jun 28 12:08:31 EddLinux anacron[17533]: Can't find sendmail at /usr/sbin/sendmail, not mailing output
Jun 28 12:52:24 EddLinux kernel: ACPI Error: No installed handler for fixed event - PowerButton (2), disabling (20160831/evevent-291)
Jun 29 12:13:35 EddLinux anacron[21404]: Can't find sendmail at /usr/sbin/sendmail, not mailing output
Jun 29 12:35:05 EddLinux dnsmasq[24574]: failed to create listening socket for port 53: Address already in use
Jun 29 12:35:05 EddLinux dnsmasq[24574]: FAILED to start up
Jun 29 12:35:05 EddLinux systemd[1]: Failed to start dnsmasq - A lightweight DHCP and caching DNS server.
Jun 29 12:37:37 EddLinux dnsmasq[24641]: failed to create listening socket for port 53: Address already in use
Jun 29 12:37:37 EddLinux dnsmasq[24641]: FAILED to start up
Jun 29 12:37:37 EddLinux systemd[1]: Failed to start dnsmasq - A lightweight DHCP and caching DNS server.

我已經重新安裝了它。歡迎任何幫助!

答案1

問題

無法為連接埠 53 建立偵聽套接字:位址已在使用中

就是這樣。

DNS 使用在連接埠 53 上傳送資料的查詢(大多數情況下使用 UDP,但也可以使用 TCP)。

dnsmasq是(除其他外)所謂的轉送 DNS伺服器,事實上它是一個伺服器意味著它想要至少在 53/UDP 上,也可能在 53/TCP 上。

只有單一進程(正在執行的程式)能夠偵聽特定 IP 位址上具有特定編號的連接埠。因此,該錯誤表示其他某個程式已經偵聽連接埠 53,但dnsmasq未能執行該操作,然後退出。

該怎麼辦

首先,弄清楚 53/UDP 上正在監聽什麼。

  1. 安裝iproute2

    # apt install iproute2
    
  2. 看看誰在使用 53/UDP:

    # ss -nlup
    

    選項的含義是:

    • 展示n數字位址,不要嘗試對它們進行 DNS 解析。
    • 只顯示監聽套接字。
    • 只顯示dp 套接字(實際上是端點,但沒關係)。
    • 展示p打開這些套接字的進程。

    (請注意,您必須以root—maybe via 的方式執行此程式sudo;這取決於您如何配置在系統上提升權限的方式。)

    現在在輸出中找到一條記錄,其中包含類似的內容 [::]:53- 確切的讀數可能有所不同,例如,0.0.0.0:53,但您:53肯定會看到該後綴- 這是端口號, - 然後看到“用戶”列- 它應該列出名稱開啟該套接字的程式的名稱。

    比如說,在我的系統上,相關的類似看起來像UNCONN 0 0 [::]:53 [::]:* users:(("dnsmasq",pid=601,fd=6))(為了簡潔起見,我壓縮了一些空格)。請注意用戶是dnsmasq;在你的系統上這會有所不同。

好的,一旦您找出罪魁禍首,請嘗試考慮如何卸載該程式。這樣做之後,簡單的事情# systemctl restart dnsmasq就可以了。

相關內容