升级 Ubuntu 20.04 至 22.04 后 DNS 解析中断

升级 Ubuntu 20.04 至 22.04 后 DNS 解析中断

将服务器从 Ubuntu 20.04 升级到 22.04 后,DNS 名称解析不再起作用。ping 8.8.8.8有效但ping google.com返回ping: google.com: Name or service not known。 此外,wget 不起作用并且sudo apt update无法解析:

~$ sudo apt update
Ign:1 http://de.archive.ubuntu.com/ubuntu jammy InRelease
Ign:2 http://de.archive.ubuntu.com/ubuntu jammy-updates InRelease
Ign:3 http://de.archive.ubuntu.com/ubuntu jammy-backports InRelease
Ign:4 http://security.ubuntu.com/ubuntu jammy-security InRelease
Ign:4 http://security.ubuntu.com/ubuntu jammy-security InRelease
Ign:1 http://de.archive.ubuntu.com/ubuntu jammy InRelease
Ign:2 http://de.archive.ubuntu.com/ubuntu jammy-updates InRelease
Ign:3 http://de.archive.ubuntu.com/ubuntu jammy-backports InRelease
Ign:4 http://security.ubuntu.com/ubuntu jammy-security InRelease
Ign:1 http://de.archive.ubuntu.com/ubuntu jammy InRelease
Ign:2 http://de.archive.ubuntu.com/ubuntu jammy-updates InRelease
Ign:3 http://de.archive.ubuntu.com/ubuntu jammy-backports InRelease
Err:1 http://de.archive.ubuntu.com/ubuntu jammy InRelease
  Could not resolve 'de.archive.ubuntu.com'
Err:4 http://security.ubuntu.com/ubuntu jammy-security InRelease
  Could not resolve 'security.ubuntu.com'
Err:2 http://de.archive.ubuntu.com/ubuntu jammy-updates InRelease
  Could not resolve 'de.archive.ubuntu.com'
Err:3 http://de.archive.ubuntu.com/ubuntu jammy-backports InRelease
  Could not resolve 'de.archive.ubuntu.com'
Reading package lists... Done
Building dependency tree... Done
Reading state information... Done
All packages are up to date.
W: Failed to fetch http://de.archive.ubuntu.com/ubuntu/dists/jammy/InRelease  Could not resolve 'de.archive.ubuntu.com'
W: Failed to fetch http://de.archive.ubuntu.com/ubuntu/dists/jammy-updates/InRelease  Could not resolve 'de.archive.ubuntu.com'
W: Failed to fetch http://de.archive.ubuntu.com/ubuntu/dists/jammy-backports/InRelease  Could not resolve 'de.archive.ubuntu.com'
W: Failed to fetch http://security.ubuntu.com/ubuntu/dists/jammy-security/InRelease  Could not resolve 'security.ubuntu.com'
W: Some index files failed to download. They have been ignored, or old ones used instead.

我尝试8.8.8.8在 中使用 作为名称服务器/etc/resolv.conf。在这种情况下,ping google.com返回ping: google.com: Temporary failure in name resolution

仅当我运行 时sudo dhclient eth0,一切才正常工作。但是,直到下次重新启动机器为止。

以下是有关该系统的更多信息,可能会有所帮助:

~$ ls -la /etc/resolv.conf
-rwxrwxrwx 1 root root 340 Jan 27 21:08 /etc/resolv.conf

~$ cat /etc/resolv.conf
# Dynamic resolv.conf(5) file for glibc resolver(3) generated by resolvconf(8)
#     DO NOT EDIT THIS FILE BY HAND -- YOUR CHANGES WILL BE OVERWRITTEN
# 127.0.0.53 is the systemd-resolved stub resolver.
# run "systemd-resolve --status" to see details about the actual nameservers.

nameserver 127.0.0.53
search DOMAINS

~$ resolvectl
Global
       Protocols: -LLMNR -mDNS -DNSOverTLS DNSSEC=no/unsupported
resolv.conf mode: foreign
      DNS Domain: DOMAINS

Link 2 (eth0)
Current Scopes: none
     Protocols: -DefaultRoute +LLMNR -mDNS -DNSOverTLS DNSSEC=no/unsupported

Link 3 (eth1)
Current Scopes: none
     Protocols: -DefaultRoute +LLMNR -mDNS -DNSOverTLS DNSSEC=no/unsupported

Link 4 (docker0)
Current Scopes: none
     Protocols: -DefaultRoute +LLMNR -mDNS -DNSOverTLS DNSSEC=no/unsupported

~$ sudo service systemd-resolved status
○ systemd-resolved.service - Network Name Resolution
     Loaded: loaded (/lib/systemd/system/systemd-resolved.service; disabled; vendor preset: enabled)
     Active: inactive (dead)
       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

~$ sudo ufw status
Status: inactive

有什么想法可以解决这个问题吗?我已经尝试了几个小时,但没有成功。

答案1

运行sudo dpkg-reconfigure resolvconf解决了这个问题。(见这里)。

相关内容