dnsmasq 重启后不工作

dnsmasq 重启后不工作

重新启动后,dnsmasq 服务正在运行,但不响应远程请求(尝试从另一台计算机使用“dig @10.0.0.1 stackexchange.com”)。我认为该日志看起来不错:

Aug 11 17:41:04 srvname systemd[1]: Starting dnsmasq - A lightweight DHCP and caching DNS server...
Aug 11 17:41:04 srvname dnsmasq[488]: dnsmasq: syntax check OK.
Aug 11 17:41:04 srvname dnsmasq[530]: started, version 2.76 cachesize 150
Aug 11 17:41:04 srvname dnsmasq[530]: compile time options: IPv6 GNU-getopt DBus i18n IDN DHCP DHCPv6 no-Lua TFTP conntrack ips
Aug 11 17:41:04 srvname dnsmasq[530]: DNS service limited to local subnets
Aug 11 17:41:04 srvname dnsmasq[530]: using nameserver 208.67.222.222#53
Aug 11 17:41:04 srvname dnsmasq[530]: using nameserver 208.67.220.220#53
Aug 11 17:41:04 srvname dnsmasq[530]: read /etc/hosts - 5 addresses
Aug 11 17:41:04 srvname systemd[1]: Started dnsmasq - A lightweight DHCP and caching DNS server.
Aug 11 17:41:21 srvname dnsmasq[530]: Ignoring query from non-local network

我不知道最后一行来自哪里,但在我执行任何操作之前重新启动后它立即就在那里。

如果我重新启动 dnsmasq 服务,除了最后一行之外,我会得到相同的日志条目,然后网络上的所有计算机都可以访问它 - 一切都很好。

dnsmasq 配置:

domain-needed
bogus-priv
no-resolv
server=208.67.220.220
server=208.67.222.222
address=/homeserver.mydomain.com/10.0.0.99

最后一行是为了让我的本地网络上的计算机能够使用其域名找到服务器本身。我的互联网路由器不会自行将 homeserver.mydomain.com 的请求从本地网络转发到 10.0.0.99(这是某些路由器具有的功能,而某些路由器(例如我的路由器)则没有)。

除了此配置之外,我还从列表中过滤掉恶意软件服务器。

相关 iptables 配置(iptables-persistent 文件):

-A INPUT -p udp -m udp --dport 53 -j ACCEPT
-A OUTPUT -p udp -m udp --sport 53 -j ACCEPT

到目前为止,我已经找到了两种可能的解决方案,但我不知道如何实现它们:

  • 在之前的问题中有人提到禁用 IPv6 帮助他们解决了类似的问题。但是,我不知道该怎么做。
  • 一位朋友建议,服务启动的顺序可能是问题所在,并将 dnsmasq 移到最后,以便它最后启动。但是,我也不知道如何修改它。我已经尝试过的是将以下行放入 /etc/network/interfaces 中:“post-up /usr/sbin/service dnsmasq restart”(尝试在网络出现后强制重新启动)。然而,这也没有帮助。

操作系统:Debian GNU/Linux 9 (stretch)
内核:Linux 4.9.0-8-amd64 #1 SMP Debian 4.9.110-3+deb9u4 (2018-08-21) x86_64 GNU/Linux
硬件:Asus VivoMini Intel N3000

答案1

interface=eth0按照 mosvy 的建议添加到 dnsmasq.conf 解决了这个问题。

相关内容