目录
问题:
DNS 服务出错导致,无法连接远程服务器
# apt-get update
Err:1 http://apt.postgresql.org/pub/repos/apt focal-pgdg-testing InRelease
Temporary failure resolving 'apt.postgresql.org'
Err:2 https://ftp.postgresql.org/pub/pgadmin/pgadmin4/apt/focal pgadmin4 InRelease
Temporary failure resolving 'ftp.postgresql.org'
Err:3 http://it.archive.ubuntu.com/ubuntu focal InRelease
Temporary failure resolving 'it.archive.ubuntu.com'
Err:4 http://nightly.odoo.com/12.0/nightly/deb ./ InRelease
Temporary failure resolving 'nightly.odoo.com'
Err:5 http://apt.postgresql.org/pub/repos/apt focal-pgdg InRelease
Temporary failure resolving 'apt.postgresql.org'
Err:6 http://it.archive.ubuntu.com/ubuntu focal-updates InRelease
Temporary failure resolving 'it.archive.ubuntu.com'
Err:7 http://security.ubuntu.com/ubuntu focal-security InRelease
Temporary failure resolving 'security.ubuntu.com'
Err:8 http://it.archive.ubuntu.com/ubuntu focal-backports InRelease
Temporary failure resolving 'it.archive.ubuntu.com'
Reading package lists... Done
W: Failed to fetch http://it.archive.ubuntu.com/ubuntu/dists/focal/InRelease Temporary failure resolving 'it.archive.ubuntu.com'
W: Failed to fetch http://it.archive.ubuntu.com/ubuntu/dists/focal-updates/InRelease Temporary failure resolving 'it.archive.ubuntu.com'
W: Failed to fetch http://it.archive.ubuntu.com/ubuntu/dists/focal-backports/InRelease Temporary failure resolving 'it.archive.ubuntu.com'
W: Failed to fetch http://security.ubuntu.com/ubuntu/dists/focal-security/InRelease Temporary failure resolving 'security.ubuntu.com'
W: Failed to fetch http://nightly.odoo.com/12.0/nightly/deb/./InRelease Temporary failure resolving 'nightly.odoo.com'
W: Failed to fetch https://ftp.postgresql.org/pub/pgadmin/pgadmin4/apt/focal/dists/pgadmin4/InRelease Temporary failure resolving 'ftp.postgresql.org'
W: Failed to fetch http://apt.postgresql.org/pub/repos/apt/dists/focal-pgdg-testing/InRelease Temporary failure resolving 'apt.postgresql.org'
W: Failed to fetch http://apt.postgresql.org/pub/repos/apt/dists/focal-pgdg/InRelease Temporary failure resolving 'apt.postgresql.org'
W: Some index files failed to download. They have been ignored, or old ones used instead.
解决方法1
resolvconf -u
手动更新DNS 服务,但是重启后需要重新执行这个命令。
解决方法2
1、检查状态
systemd-resolve --status
# systemd-resolve --status
Failed to get global data: Unit dbus-org.freedesktop.resolve1.service not found.
2、重新连接服务
sudo ln -sf /lib/systemd/system/systemd-resolved.service /etc/systemd/system/dbus-org.freedesktop.resolve1.service
3、重启服务
sudo systemctl restart systemd-resolved.service
4、确认状态
~# systemd-resolve --status
Global
LLMNR setting: no
MulticastDNS setting: no
DNSOverTLS setting: no
DNSSEC setting: no
DNSSEC supported: no
Current DNS Server: 8.8.8.8
DNS Servers: 8.8.8.8
DNSSEC NTA: 10.in-addr.arpa
16.172.in-addr.arpa
168.192.in-addr.arpa
17.172.in-addr.arpa
18.172.in-addr.arpa
19.172.in-addr.arpa
20.172.in-addr.arpa
21.172.in-addr.arpa
22.172.in-addr.arpa
23.172.in-addr.arpa
24.172.in-addr.arpa
25.172.in-addr.arpa
26.172.in-addr.arpa
27.172.in-addr.arpa
28.172.in-addr.arpa