在尝试运行apt-get update
并将所需的包安装到我的WSL 2 Ubuntu20.04实例时,我会收到以下错误:
:~$ sudo apt-get update && sudo apt-get upgrade
Err:1 http://archive.ubuntu.com/ubuntu focal InRelease
Temporary failure resolving 'archive.ubuntu.com'
Err:2 http://security.ubuntu.com/ubuntu focal-security InRelease
Temporary failure resolving 'security.ubuntu.com'
Err:3 http://archive.ubuntu.com/ubuntu focal-updates InRelease
Temporary failure resolving 'archive.ubuntu.com'
Err:4 http://archive.ubuntu.com/ubuntu focal-backports InRelease
Temporary failure resolving 'archive.ubuntu.com'
Reading package lists... Done
W: Failed to fetch http://archive.ubuntu.com/ubuntu/dists/focal/InRelease Temporary failure resolving 'archive.ubuntu.com'
W: Failed to fetch http://archive.ubuntu.com/ubuntu/dists/focal-updates/InRelease Temporary failure resolving 'archive.ubuntu.com'
W: Failed to fetch http://archive.ubuntu.com/ubuntu/dists/focal-backports/InRelease Temporary failure resolving 'archive.ubuntu.com'
W: Failed to fetch http://security.ubuntu.com/ubuntu/dists/focal-security/InRelease Temporary failure resolving 'security.ubuntu.com'
W: Some index files failed to download. They have been ignored, or old ones used instead.
Reading package lists... Done
Building dependency tree
Reading state information... Done
Calculating upgrade... Done
0 upgraded, 0 newly installed, 0 to remove and 0 not upgraded.
:~$ sudo apt install unzip
Reading package lists... Done
Building dependency tree
Reading state information... Done
Suggested packages:
zip
The following NEW packages will be installed:
unzip
0 upgraded, 1 newly installed, 0 to remove and 0 not upgraded.
Need to get 169 kB of archives.
After this operation, 593 kB of additional disk space will be used.
Err:1 http://archive.ubuntu.com/ubuntu focal/main amd64 unzip amd64 6.0-25ubuntu1
Temporary failure resolving 'archive.ubuntu.com'
E: Failed to fetch http://archive.ubuntu.com/ubuntu/pool/main/u/unzip/unzip_6.0-25ubuntu1_amd64.deb Temporary failure resolving 'archive.ubuntu.com'
E: Unable to fetch some archives, maybe run apt-get update or try with --fix-missing?
我能做些什么让这件事起作用吗?
发布于 2022-04-21 11:47:15
这个问题是因为系统无法联系能够解决域名的DNS服务器。这里有一些解决办法..。
暂时,您可以使用您想要使用的DNS服务器编辑/etc/resolv.conf
文件。例如,添加行nameserver 8.8.8.8
,保存文件,然后重试。
对于持久的DNS配置,您可能需要编辑/etc/systemd/resolved.conf
文件。删除DNS
和FallbackDNS
符号,取消对#
和D5
行的注释。
现在添加您喜欢的DNS服务器。无论如何,FallbackDNS
行是可选的。
DNS=8.8.8.8
FallbackDNS=8.8.4.4
保存文件并退出。此外,您可能希望清除任何缓存的查询。使用命令systemd-resolve --flush-caches
或resolvectl flush-caches
现在DNS应该可以正常工作。
https://askubuntu.com/questions/1403476
复制相似问题