修复Ubuntu 20.04 Temporary failure resolving错误

如何解决 Temporary failure resolving错误?

虽然此错误消息最有可能与DNS服务器名称解析相关,但第一步是检查我们的Internet连接。

$ ping -c 2 8.8.8.8
PING 8.8.8.8 (8.8.8.8) 56(84) bytes of data.
64 bytes from 8.8.8.8: icmp_seq=1 ttl=54 time=10.4 ms
64 bytes from 8.8.8.8: icmp_seq=2 ttl=54 time=10.2 ms
--- 8.8.8.8 ping statistics --
2 packets transmitted, 2 received, 0% packet loss, time 1006ms
rtt min/avg/max/mdev = 10.157/10.291/10.425/0.134 ms

检查DNS服务器网络配置设置:

$ systemd-resolve --status | grep Current
      Current Scopes: DNS
  Current DNS Server: 192.168.1.1

测试DNS服务器是否能ping通:

$ ping -c 2 192.168.1.1
PING 192.168.1.1 (192.168.1.1) 56(84) bytes of data.
64 bytes from 192.168.1.1: icmp_seq=1 ttl=64 time=0.535 ms
64 bytes from 192.168.1.1: icmp_seq=2 ttl=64 time=0.570 ms
--- 192.168.1.1 ping statistics --
2 packets transmitted, 2 received, 0% packet loss, time 1016ms
rtt min/avg/max/mdev = 0.535/0.552/0.570/0.017 ms

通过尝试解析DNS名称来测试DNS服务器。

$ dig @192.168.1.1 onitroad.com
; <<>> DiG 9.11.5-P4-5.1ubuntu4-Ubuntu <<>> @192.168.1.1 onitroad.com
; (1 server found)
;; global options: +cmd
;; Got answer:
;; ->>HEADER<<- opcode: QUERY, status: NOERROR, id: 21662
;; flags: qr rd ra; QUERY: 1, ANSWER: 2, AUTHORITY: 0, ADDITIONAL: 1
;; OPT PSEUDOSECTION:
; EDNS: version: 0, flags:; udp: 4096
;; QUESTION SECTION:
;onitroad.com.		IN	A
;; ANSWER SECTION:
onitroad.com.	300	IN	A	104.26.3.13
onitroad.com.	300	IN	A	104.26.2.13
;; Query time: 408 msec
;; SERVER: 192.168.1.1#53(192.168.1.1)
;; WHEN: Wed Dec 11 14:02:07 AEDT 2019
;; MSG SIZE  rcvd: 76

通过尝试解决DNS主机名来确认系统范围的设置。

$ resolvectl query onitroad.com
onitroad.com: 104.26.3.13                   -- link: enp0s3
                 104.26.2.13                   -- link: enp0s3
-- Information acquired via protocol DNS in 2.7ms.
-- Data is authenticated: no
日期:2020-07-07 20:55:52 来源:oir作者:oir