解决 Ubuntu 和其他发行版上的 WSL2 网络无法访问的问题 |
您所在的位置:网站首页 › win10更新后无法访问internet › 解决 Ubuntu 和其他发行版上的 WSL2 网络无法访问的问题 |
【翻译于Kontext 的 Resolution for WSL2 Network Unreachable Issue on Ubuntu and Other Distros】 对于我的 Ubuntu 1.2 发行版,从 WSL20 升级到 WSL04 时,虚拟机无法连接到网络。错误消息包括:无法访问网络;临时故障解决; 名称解析等暂时失败。网站上有很多文章,其中许多文章都没有解决问题。本页总结了这些问题的解决方案,希望能为您节省大量时间。 问题上下文在非系统驱动器上安装 Windows 子系统之后安装 WSL 2 Ubuntu 发行版后,尝试更新 apt 时会出现以下错误: 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 Building dependency tree Reading state information... Done All packages are up to date. 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.同样,当 ping 8.8.8.8 或任何其他 IP 地址时,会显示以下错误: ping: connect: Network is unreachable 当ping任何域名时,它会显示一个不同的错误: ping: google.com: Temporary failure in name resolution 环境详细信息如下: 操作系统: 视窗 10 (10.0.19044)WSL 版本:2发行版:Ubuntu 20.04 x64 版本或 OpenSUSE 42 或任何其他发行版。降级到 WSL 1 时,将自动解决以下问题: wsl --set-version Ubuntu 1但是,当将其更改回版本2时,上述问题仍然存在: wsl --set-verison Ubuntu 2 常规修复WSL 2 官方文档和许多其他网站都建议进行以下修复: 在 WSL 中备份和删除自动生成的文件: # Backup and delete auto-generated files sudo cp /etc/wsl.conf /etc/wsl.conf.bk sudo cp /etc/resolv.conf /etc/resolv.conf.bk sudo rm /etc/resolv.conf || true sudo rm /etc/wsl.conf || true如果您的发行版中不存在 wsl.conf,您可以忽略它。 使用以下命令重新创建:/etc/wsl.conf sudo bash -c 'cat |
今日新闻 |
推荐新闻 |
CopyRight 2018-2019 办公设备维修网 版权所有 豫ICP备15022753号-3 |