systemd-resolve 似乎无法查询指定的 DNS 服务器

systemd-resolve 似乎无法查询指定的 DNS 服务器

编辑:在我输入这个问题的时间里,它似乎已经自行修复,现在按预期工作了。我仍然对为什么会发生这种情况感兴趣 :)

我的设置如下:

我在地址处有一个本地 DNS 服务器(准确地说是 pihole)192.168.1.200。我在我的家庭网络中也有一个地址为 的服务器192.168.1.300。我的域example.com指向我的公共 IP 5.5.5.5。pihole 有一些自定义 DNS 条目,因此当我在本地网络中时,example.com解析为192.168.1.300而不是5.5.5.5(为了避免 NAT 问题),我已将我的 wifi 的 DNS 服务器设置为192.168.1.200。(它也设置在路由器中...)

现在不知何故,我仍然从 systemd-resolve 获取 5.5.5.5 IP。

我已经用以下方法刷新了 DNS 缓存 sudo systemd-resolve --flush-caches

sudo systemd-resolve --statistics返回缓存大小为 0

systemd-resolve --status | grep "DNS Servers"节目192.168.1.200

现在到了有趣的部分:

dig example.com返回5.5.5.5

while dig example.com @192.168.1.200返回192.168.1.300

这怎么可能?如何让 systemd-resolve 真正查询我设置的 DNS 服务器?

更多信息:

  • ls -al /etc/resolv.conf返回 lrwxrwxrwx 1 root root 39 Sep 26 2019 /etc/resolv.conf -> ../run/systemd/resolve/stub-resolv.conf
  • cat /etc/resolv.conf返回
# This file is managed by man:systemd-resolved(8). Do not edit.
#
# This is a dynamic resolv.conf file for connecting local clients to the
# internal DNS stub resolver of systemd-resolved. This file lists all
# configured search domains.
#
# Run "systemd-resolve --status" to see details about the uplink DNS servers
# currently in use.
#
# Third party programs must not access this file directly, but only through the
# symlink at /etc/resolv.conf. To manage man:resolv.conf(5) in a different way,
# replace this symlink by a static file or a different symlink.
#
# See man:systemd-resolved.service(8) for details about the supported modes of
# operation for /etc/resolv.conf.

nameserver 127.0.0.53
options edns0
search home
  • dpkg -l *dnsmasq*返回
Desired=Unknown/Install/Remove/Purge/Hold
| Status=Not/Inst/Conf-files/Unpacked/halF-conf/Half-inst/trig-aWait/Trig-pend
|/ Err?=(none)/Reinst-required (Status,Err: uppercase=bad)
||/ Name                   Version          Architecture     Description
+++-======================-================-================-==================================================
un  dnsmasq                <none>           <none>           (no description available)
ii  dnsmasq-base           2.79-1           amd64            Small caching DNS proxy and DHCP/TFTP server
un  dnsmasq-base-lua       <none>           <none>           (no description available)

  • grep -i dns /etc/systemd/resolved.conf返回
#DNS=
#FallbackDNS=
#MulticastDNS=no
#DNSSEC=no
#DNSStubListener=yes

答案1

解决我的问题的是运行sudo /etc/init.d/dns-clean restart

相关内容