我今天升级了我的互联网路由器,发现运行Fedora 36的Linux系统不能再执行DNS名称解析。我也有安卓设备,Windows 10,Windows 11和CentOS 7.9系统在网络上,没有任何问题,这次升级。
在我的CentOS机器上,/etc/resolv.conf包含:
# Generated by NetworkManager
nameserver 10.0.1.1在我的Fedora 36机器上,它包含:
# This is /run/systemd/resolve/stub-resolv.conf managed by man:systemd-resolved(8).
# Do not edit.
#
# This file might be symlinked as /etc/resolv.conf. If you're looking at
# /etc/resolv.conf and seeing this text, you have followed the symlink.
#
# 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 "resolvectl status" to see details about the uplink DNS servers
# currently in use.
#
# Third party programs should typically 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 trust-ad
search .Fedora 36使用systemd解析服务来管理DNS名称服务器,并向该文件中添加其他条目(如8.8.8.8 ),并重新启动该服务将重新生成该文件并丢失任何更改。
我不明白发生了什么,只有我的Fedora 36系统现在无法解析域名,我一直无法找到修复它的方法。我尝试过很多不同的Google搜索,但是在发行版和旧版本的Fedora之间有很多相互矛盾的信息,很多信息要么是无关的,要么包含了没有改变行为的过程。
我对通过本地网络访问这个系统没有问题,而且它可以很好地平IP地址。但我不能打开任何域名。
我得到的错误是:
$ ping google.com
ping: google.com: Temporary failure in name resolution我尝试重新启动解决方案和dnsmaq服务:
systemctl restart systemd-resolved.service
systemctl restart dnsmasq确保DNS端口处于打开状态:
firewall-cmd --permanent --add-port=43/tcp
firewall-cmd --permanent --add-port=53/tcp
firewall-cmd --reload我试着把以太网适配器调下来,然后再备份:
nmcli con down id Ethernet
nmcli con up id Ethernet我尝试添加8.8.8.8作为我的以太网卡的接口DNS:
systemd-resolve --interface enp9s0 --set-dns 8.8.8.8我也尝试过刷新我的DNS缓存:
resolvectl flush-caches
sudo resolvectl flush-caches这个服务器是无头的,所以我只能通过SSH访问它。这意味着我不能从桌面或GUI中更改任何设置。
问题是什么,它是如何发生的,我如何解决它?我不明白问题出在哪里,也不明白该如何进行。
以下是一些补充信息:
$ resolvectl status
Global
Protocols: LLMNR=resolve -mDNS -DNSOverTLS DNSSEC=no/unsupported
resolv.conf mode: stub
Link 2 (enp9s0)
Current Scopes: LLMNR/IPv4 LLMNR/IPv6
Protocols: -DefaultRoute +LLMNR -mDNS -DNSOverTLS DNSSEC=no/unsupported
Link 3 (wlp8s0)
Current Scopes: none
Protocols: -DefaultRoute +LLMNR -mDNS -DNSOverTLS DNSSEC=no/unsupported$ systemd-resolve --statistics
DNSSEC supported by current servers: no
Transactions
Current Transactions: 0
Total Transactions: 0
Cache
Current Cache Size: 0
Cache Hits: 0
Cache Misses: 0
DNSSEC Verdicts
Secure: 0
Insecure: 0
Bogus: 0
Indeterminate: 0$ systemctl status systemd-resolved
● systemd-resolved.service - Network Name Resolution
Loaded: loaded (/usr/lib/systemd/system/systemd-resolved.service; enabled; vendor preset: enabled)
Active: active (running) since Wed 2022-07-27 16:34:57 EDT; 16min ago
Docs: man:systemd-resolved.service(8)
man:org.freedesktop.resolve1(5)
https://www.freedesktop.org/wiki/Software/systemd/writing-network-configuration-managers
https://www.freedesktop.org/wiki/Software/systemd/writing-resolver-clients
Main PID: 1992495 (systemd-resolve)
Status: "Processing requests..."
Tasks: 1 (limit: 76912)
Memory: 4.0M
CPU: 61ms
CGroup: /system.slice/systemd-resolved.service
└─ 1992495 /usr/lib/systemd/systemd-resolved
Jul 27 16:34:57 lserver systemd[1]: Starting systemd-resolved.service - Network Name Resolution...
Jul 27 16:34:57 lserver systemd-resolved[1992495]: Positive Trust Anchors:
Jul 27 16:34:57 lserver systemd-resolved[1992495]: . IN DS 20326 8 2 e06d44b80b8f1d39a95c0b0d7c65d08458e880409bbc683>
Jul 27 16:34:57 lserver systemd-resolved[1992495]: Negative trust anchors: home.arpa 10.in-addr.arpa 16.172.in-addr.>
Jul 27 16:34:57 lserver systemd-resolved[1992495]: Using system hostname 'lserver'.
Jul 27 16:34:57 lserver systemd[1]: Started systemd-resolved.service - Network Name Resolution.
Jul 27 16:48:02 lserver systemd-resolved[1992495]: Flushed all caches.
Jul 27 16:48:30 lserver systemd-resolved[1992495]: Flushed all caches.$ systemctl status dnsmasq
● dnsmasq.service - DNS caching server.
Loaded: loaded (/usr/lib/systemd/system/dnsmasq.service; disabled; vendor preset: disabled)
Active: active (running) since Wed 2022-07-27 16:49:49 EDT; 50s ago
Process: 2045570 ExecStart=/usr/sbin/dnsmasq (code=exited, status=0/SUCCESS)
Main PID: 2045572 (dnsmasq)
Tasks: 1 (limit: 76912)
Memory: 600.0K
CPU: 3ms
CGroup: /system.slice/dnsmasq.service
└─ 2045572 /usr/sbin/dnsmasq
Jul 27 16:49:49 lserver systemd[1]: Starting dnsmasq.service - DNS caching server....
Jul 27 16:49:49 lserver dnsmasq[2045572]: started, version 2.86 cachesize 150
Jul 27 16:49:49 lserver dnsmasq[2045572]: compile time options: IPv6 GNU-getopt DBus no-UBus no-i18n IDN2 DHCP DHCPv>
Jul 27 16:49:49 lserver dnsmasq[2045572]: reading /etc/resolv.conf
Jul 27 16:49:49 lserver dnsmasq[2045572]: using nameserver 127.0.0.53#53
Jul 27 16:49:49 lserver systemd[1]: Started dnsmasq.service - DNS caching server..
Jul 27 16:49:49 lserver dnsmasq[2045572]: read /etc/hosts - 2 addresses我以前的路由器是带WRT3200ACM的Linksys OpenWRT。我的新路由器是一个带有FreshTomato的网具FreshTomato。我似乎将路由器软件配置为充当本地DNS服务器,这反映在我的CentOS机器上的nameserver条目默认为10.0.1.1,这是网络上的默认网关地址。然而,根据网络上的每一个设备,它似乎都在履行自己的职责。这仍然不能解释为什么Fedora 36是唯一有问题的系统。
由于这次升级,我的IP地址没有改变。默认网关始终配置为10.0.1.1,此机器的IP始终是静态的,为10.0.1.21。对LAN的唯一改变是路由器交换。一切都应该“刚刚好”,因为我已经预先配置了所有必要的端口转发。
应评论意见的要求提供的补充资料:
$ dig @10.0.1.1 bbc.co.uk
; <<>> DiG 9.16.30-RH <<>> @10.0.1.1 bbc.co.uk
; (1 server found)
;; global options: +cmd
;; Got answer:
;; ->>HEADER<<- opcode: QUERY, status: NOERROR, id: 16748
;; flags: qr rd ra; QUERY: 1, ANSWER: 4, AUTHORITY: 0, ADDITIONAL: 1
;; OPT PSEUDOSECTION:
; EDNS: version: 0, flags:; udp: 512
;; QUESTION SECTION:
;bbc.co.uk. IN A
;; ANSWER SECTION:
bbc.co.uk. 177 IN A 151.101.64.81
bbc.co.uk. 177 IN A 151.101.128.81
bbc.co.uk. 177 IN A 151.101.192.81
bbc.co.uk. 177 IN A 151.101.0.81
;; Query time: 9 msec
;; SERVER: 10.0.1.1#53(10.0.1.1)
;; WHEN: Wed Jul 27 17:21:01 EDT 2022
;; MSG SIZE rcvd: 102$ dig @127.0.0.53 bbc.co.uk
; <<>> DiG 9.16.30-RH <<>> @127.0.0.53 bbc.co.uk
; (1 server found)
;; global options: +cmd
;; Got answer:
;; ->>HEADER<<- opcode: QUERY, status: SERVFAIL, id: 58582
;; flags: qr aa rd ra; QUERY: 1, ANSWER: 0, AUTHORITY: 0, ADDITIONAL: 1
;; OPT PSEUDOSECTION:
; EDNS: version: 0, flags:; udp: 65494
;; QUESTION SECTION:
;bbc.co.uk. IN A
;; Query time: 0 msec
;; SERVER: 127.0.0.53#53(127.0.0.53)
;; WHEN: Wed Jul 27 17:21:26 EDT 2022
;; MSG SIZE rcvd: 38$ dig @8.8.8.8
; <<>> DiG 9.16.30-RH <<>> @8.8.8.8
; (1 server found)
;; global options: +cmd
;; Got answer:
;; ->>HEADER<<- opcode: QUERY, status: NOERROR, id: 32553
;; flags: qr rd ra ad; QUERY: 1, ANSWER: 13, AUTHORITY: 0, ADDITIONAL: 1
;; OPT PSEUDOSECTION:
; EDNS: version: 0, flags:; udp: 512
;; QUESTION SECTION:
;. IN NS
;; ANSWER SECTION:
. 615 IN NS m.root-servers.net.
. 615 IN NS b.root-servers.net.
. 615 IN NS c.root-servers.net.
. 615 IN NS d.root-servers.net.
. 615 IN NS e.root-servers.net.
. 615 IN NS f.root-servers.net.
. 615 IN NS g.root-servers.net.
. 615 IN NS h.root-servers.net.
. 615 IN NS a.root-servers.net.
. 615 IN NS i.root-servers.net.
. 615 IN NS j.root-servers.net.
. 615 IN NS k.root-servers.net.
. 615 IN NS l.root-servers.net.
;; Query time: 15 msec
;; SERVER: 8.8.8.8#53(8.8.8.8)
;; WHEN: Wed Jul 27 17:21:32 EDT 2022
;; MSG SIZE rcvd: 239$ journalctl _SYSTEMD_UNIT=systemd-resolved.service
...
-- Boot 66eaabbbfb7e4f7b9f34c9b3316f1e07 --
Jul 15 08:06:43 lserver systemd-resolved[1456]: Positive Trust Anchors:
Jul 15 08:06:43 lserver systemd-resolved[1456]: . IN DS 20326 8 2 e06d44b80b8f1d39a95c0b0d7c65d08458e880409bbc683457104237c7f8ec8d
Jul 15 08:06:43 lserver systemd-resolved[1456]: Negative trust anchors: home.arpa 10.in-addr.arpa 16.172.in-addr.arpa 17.172.in-addr.arpa 18.172.in-addr.arpa 19.172.in-addr.arpa 20.172.in-addr.>
Jul 15 08:06:43 lserver systemd-resolved[1456]: Using system hostname 'lserver'.
Jul 15 08:06:48 lserver systemd-resolved[1456]: enp9s0: Bus client set default route setting: yes
Jul 15 08:06:48 lserver systemd-resolved[1456]: enp9s0: Bus client set DNS server list to: fdf5:328d:f2ee::1
Jul 27 12:35:17 lserver systemd-resolved[1456]: enp9s0: Bus client set default route setting: no
Jul 27 12:35:17 lserver systemd-resolved[1456]: enp9s0: Bus client reset DNS server list.
Jul 27 14:55:04 lserver systemd-resolved[1456]: Flushed all caches.
Jul 27 14:55:08 lserver systemd-resolved[1456]: Flushed all caches.
Jul 27 14:55:42 lserver systemd-resolved[1456]: Flushed all caches.
Jul 27 14:55:47 lserver systemd-resolved[1456]: [Scope protocol=llmnr interface=enp9s0 family=AF_INET6]
Jul 27 14:55:47 lserver systemd-resolved[1456]: [Scope protocol=llmnr interface=enp9s0 family=AF_INET]
Jul 27 14:55:47 lserver systemd-resolved[1456]: [Scope protocol=dns]
Jul 27 14:57:58 lserver systemd-resolved[1620611]: Positive Trust Anchors:发布于 2022-07-27 23:19:05
我正在回答我自己的问题,以分享我最终使用的解决方法,但我不愿意接受它,因为我认为操作系统应该能够自动配置DNS服务器。我仍然不确定为什么存在这个问题,为什么它只发生在我交换路由器之后,并且只发生在我的Fedora 36系统上。
为了解决这个问题,我最终复制了我的CentOS机器的行为,其中DNS服务器被设置为默认网关,这是我的路由器的地址10.0.1.1。对于systemd解析,这是通过编辑/etc/systemd/resolved.conf文件并向DNS=行添加一个条目来完成的。
[Resolve]
DNS=10.0.1.1它也适用于其他已知的DNS主机,如8.8.8.8、1.1.1.1等。但是使用我的路由器是有意义的,因为它也在那里执行DNS查找,并且有自己的缓存。
我不明白为什么这是一个问题,无论是Fedora 36还是我的环境,但我觉得这是一个我不应该去处理的问题。
https://unix.stackexchange.com/questions/711529
复制相似问题