ubuntu - Windows10 WSL2 Ubuntu/Debian # 无网络

标签 ubuntu debian windows-subsystem-for-linux apt wsl-2

从 WSL 升级到 WSL2 后

sudo apt-get update
不再工作。后:wsl --set-version Ubuntu-18.04 2输出是:
> sudo apt-get update
Err:1 http://security.ubuntu.com/ubuntu bionic-security InRelease
  Temporary failure resolving 'security.ubuntu.com'
Err:2 http://archive.ubuntu.com/ubuntu bionic InRelease
  Temporary failure resolving 'archive.ubuntu.com'
Err:3 http://archive.ubuntu.com/ubuntu bionic-updates InRelease
  Temporary failure resolving 'archive.ubuntu.com'
Err:4 http://archive.ubuntu.com/ubuntu bionic-backports InRelease
  Temporary failure resolving 'archive.ubuntu.com'
Reading package lists... Done
W: Failed to fetch http://archive.ubuntu.com/ubuntu/dists/bionic/InRelease  Temporary failure resolving 'archive.ubuntu.com'
W: Failed to fetch http://archive.ubuntu.com/ubuntu/dists/bionic-updates/InRelease  Temporary failure resolving 'archive.ubuntu.com'
W: Failed to fetch http://archive.ubuntu.com/ubuntu/dists/bionic-backports/InRelease  Temporary failure resolving 'archive.ubuntu.com'
W: Failed to fetch http://security.ubuntu.com/ubuntu/dists/bionic-security/InRelease  Temporary failure resolving 'security.ubuntu.com'
W: Some index files failed to download. They have been ignored, or old ones used instead.
回到 WSL1 后,问题再次消失。在 Debian 上也是如此,在 CentOS 上也是如此。所以 WSL2 一定有一个错误。
Windows10 build 版本为 19041,今天安装。
WSL2 的任何解决方法?
问候

最佳答案

生成的文件/etc/resolv.conf 是:

nameserver 172.24.0.1



..必须将其更改为

nameserver 8.8.8.8



这解决了问题

关于ubuntu - Windows10 WSL2 Ubuntu/Debian # 无网络,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/60269422/

相关文章:

apache - 使用 SSL 的 Apache2 上的 Gitlab

Ubuntu Google Drive Nautilus 自动备份

linux - 无法在 debian 上安装 libapache2-mod-php5

linux - PhpStorm 未检测到 Debian 8 的自定义主题

c - 不带 "return"命令返回

java - 从 WSL 中完全卸载 openjdk-11

ubuntu - Python 逻辑错误 : clGetPlatformIDs failed: platform not found khr

Android 模拟器无法在 Ubuntu 17.04 上启动

python - 为 Debian 打包时如何访问原始 tarball?

ubuntu - WSL2 : Why do I have to shutdown WSL to restart WSL after restarting PC