首页
学习
活动
专区
圈层
工具
发布
首页
学习
活动
专区
圈层
工具
MCP广场
社区首页 >问答首页 >如何解决在ubuntu20.04上解决WSL 2的问题

如何解决在ubuntu20.04上解决WSL 2的问题
EN

Ask Ubuntu用户
提问于 2022-04-21 09:41:29
回答 1查看 5.1K关注 0票数 0

在尝试运行apt-get update并将所需的包安装到我的WSL 2 Ubuntu20.04实例时,我会收到以下错误:

代码语言:javascript
运行
复制
:~$ 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?

我能做些什么让这件事起作用吗?

EN

回答 1

Ask Ubuntu用户

发布于 2022-04-21 11:47:15

这个问题是因为系统无法联系能够解决域名的DNS服务器。这里有一些解决办法..。

暂时,您可以使用您想要使用的DNS服务器编辑/etc/resolv.conf文件。例如,添加行nameserver 8.8.8.8,保存文件,然后重试。

对于持久的DNS配置,您可能需要编辑/etc/systemd/resolved.conf文件。删除DNSFallbackDNS符号,取消对#D5行的注释。

现在添加您喜欢的DNS服务器。无论如何,FallbackDNS行是可选的。

代码语言:javascript
运行
复制
DNS=8.8.8.8
FallbackDNS=8.8.4.4

保存文件并退出。此外,您可能希望清除任何缓存的查询。使用命令systemd-resolve --flush-cachesresolvectl flush-caches

现在DNS应该可以正常工作。

票数 0
EN
页面原文内容由Ask Ubuntu提供。腾讯云小微IT领域专用引擎提供翻译支持
原文链接:

https://askubuntu.com/questions/1403476

复制
相关文章

相似问题

领券
问题归档专栏文章快讯文章归档关键词归档开发者手册归档开发者手册 Section 归档