编辑:在我输入这个问题的过程中,它显然已自行修复,现在它按预期工作。我仍然对为什么会发生这种情况感兴趣:)
我的设置如下:
我在 address 有一个本地 DNS 服务器(准确地说是 pihole)192.168.1.200
。我的家庭网络中的 address 也有一台服务器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。
我已经用
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
而
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
解决我的问题的是运行
sudo /etc/init.d/dns-clean restart