在将服务器从Ubuntu20.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
有什么办法解决这个问题吗?我已经尝试了好几个小时,但没有成功。
发布于 2023-01-27 21:39:25
运行sudo dpkg-reconfigure resolvconf
解决了这个问题。(见这里)。
https://askubuntu.com/questions/1452215
复制相似问题