How to debug dnsmasq requiring a service restart in order to work?

On a server of mine, I have dnsmasq setup; it is configured as another server, where it works (although, with other hardware and o/s).

On this specific host though, dnsmasq doesn't work after boot (the clients can't resolve names), but it does, if I manually restart it (service dnsmasq restart).

I can't figure out anything from the logs, which don't show any problem. Extract of syslog, immediately after boot:

15:Apr 13 12:31:39 <server_hostname> systemd[1]: Stopping dnsmasq - A lightweight DHCP and caching DNS server...
276:Apr 13 12:32:22 <server_hostname> systemd[1]: Starting dnsmasq - A lightweight DHCP and caching DNS server...
285:Apr 13 12:32:22 <server_hostname> dnsmasq[592]: dnsmasq: syntax check OK.
511:Apr 13 12:32:22 <server_hostname> dnsmasq[622]: started, version 2.75 cachesize 150
512:Apr 13 12:32:22 <server_hostname> dnsmasq[622]: compile time options: IPv6 GNU-getopt DBus i18n IDN DHCP DHCPv6 no-Lua TFTP conntrack ipset auth DNSSEC loop-detect inotify
513:Apr 13 12:32:22 <server_hostname> dnsmasq[622]: DNS service limited to local subnets
514:Apr 13 12:32:22 <server_hostname> dnsmasq[622]: warning: ignoring resolv-file flag because no-resolv is set
515:Apr 13 12:32:22 <server_hostname> dnsmasq-dhcp[622]: DHCP, IP range 192.168.166.2 -- 192.168.166.254, lease time 1h
516:Apr 13 12:32:22 <server_hostname> dnsmasq[622]: using nameserver 209.222.18.218#53
517:Apr 13 12:32:22 <server_hostname> dnsmasq[622]: using nameserver 209.222.18.222#53
518:Apr 13 12:32:22 <server_hostname> dnsmasq[622]: read /etc/hosts - 5 addresses
558:Apr 13 12:32:22 <server_hostname> systemd[1]: Started dnsmasq - A lightweight DHCP and caching DNS server.
568:Apr 13 12:32:24 <server_hostname> dnsmasq-dhcp[622]: DHCP packet received on eth1 which has no address
575:Apr 13 12:32:27 <server_hostname> dnsmasq-dhcp[622]: DHCP packet received on eth1 which has no address
589:Apr 13 12:32:32 <server_hostname> dnsmasq-dhcp[622]: DHCPDISCOVER(eth1) 192.168.166.129 <client_mac>
590:Apr 13 12:32:32 <server_hostname> dnsmasq-dhcp[622]: DHCPOFFER(eth1) 192.168.166.129 <client_mac>
591:Apr 13 12:32:32 <server_hostname> dnsmasq-dhcp[622]: DHCPREQUEST(eth1) 192.168.166.129 <client_mac>
592:Apr 13 12:32:32 <server_hostname> dnsmasq-dhcp[622]: DHCPACK(eth1) 192.168.166.129 <client_mac> <client_hostname>

Entries added after executing service dnsmasq restart:

625:Apr 13 12:33:39 <server_hostname> systemd[1]: Stopping dnsmasq - A lightweight DHCP and caching DNS server...
626:Apr 13 12:33:39 <server_hostname> dnsmasq[622]: exiting on receipt of SIGTERM
627:Apr 13 12:33:39 <server_hostname> systemd[1]: Stopped dnsmasq - A lightweight DHCP and caching DNS server.
628:Apr 13 12:33:39 <server_hostname> systemd[1]: Starting dnsmasq - A lightweight DHCP and caching DNS server...
629:Apr 13 12:33:39 <server_hostname> dnsmasq[875]: dnsmasq: syntax check OK.
630:Apr 13 12:33:39 <server_hostname> dnsmasq[885]: started, version 2.75 cachesize 150
631:Apr 13 12:33:39 <server_hostname> dnsmasq[885]: compile time options: IPv6 GNU-getopt DBus i18n IDN DHCP DHCPv6 no-Lua TFTP conntrack ipset auth DNSSEC loop-detect inotify
632:Apr 13 12:33:39 <server_hostname> dnsmasq[885]: DNS service limited to local subnets
633:Apr 13 12:33:39 <server_hostname> dnsmasq[885]: warning: ignoring resolv-file flag because no-resolv is set
634:Apr 13 12:33:39 <server_hostname> dnsmasq-dhcp[885]: DHCP, IP range 192.168.166.2 -- 192.168.166.254, lease time 1h
635:Apr 13 12:33:39 <server_hostname> dnsmasq[885]: using nameserver 209.222.18.218#53
636:Apr 13 12:33:39 <server_hostname> dnsmasq[885]: using nameserver 209.222.18.222#53
637:Apr 13 12:33:39 <server_hostname> dnsmasq[885]: read /etc/hosts - 5 addresses
638:Apr 13 12:33:40 <server_hostname> systemd[1]: Started dnsmasq - A lightweight DHCP and caching DNS server.

The server is an Ubuntu 16.04; dnsmasq version is 2.75-1ubuntu0.16.04.4.

The configuration (under /etc/dnsmasq.d/) is:

bind-interfaces
dhcp-range=eth1,192.168.100.2,192.168.100.254
server=<dns_server_1>
server=<dns_server_2>
no-resolv

How can I debug this problem? What's the possible cause?

1
задан 13 April 2018 в 13:50
1 ответ

На самом деле это состояние гонки между systemd и dnsmasq, которое также может произойти на Raspbian.

Решение состоит в том, чтобы убедиться, что сетевые интерфейсы включены до запуска dnsmasq:

sudo systemctl edit dnsmasq

И добавьте:

[Unit]
After=network-online.target
Wants=network-online.target

Ссылка: https://discourse.pi-hole.net/t/have-to-manually-restart-dns-server-when-reboot-pihole-another-one/2255

0
ответ дан 4 December 2019 в 04:03

Теги

Похожие вопросы