WSL 似乎根本没有连接到网络

WSL 似乎根本没有连接到网络

系统详细信息:

  • Windows 11 专业版
  • 来自微软网站的官方 ISO 映像 + Christitus WinUtil 创建自定义映像(用于删除过度安装的软件)

问题详细信息,总结一下问题,这里是终端中的命令及其各自的响应:

  • ping google.com
    Temporary failure in name resolution
  • ping 1.1.1.1
ping: connect: Network is unreachable
  • sudo apt update
Ign:1 http://security.ubuntu.com/ubuntu jammy-security InRelease
Ign:3 (link for Ubuntu archive) jammy-updates InRelease
Ign:4 (link for Ubuntu archive) jammy-backports InRelease
Err:2 (link for Ubuntu archive) jammy InRelease
  Temporary failure resolving '(link for Ubuntu archive)'
Err:1 http://security.ubuntu.com/ubuntu jammy-security InRelease
  Temporary failure resolving 'security.ubuntu.com'
Err:3 (link for Ubuntu archive) jammy-updates InRelease
  Temporary failure resolving '(link for Ubuntu archive)'
Err:4 (link for Ubuntu archive) jammy-backports InRelease
  Temporary failure resolving '(link for Ubuntu archive)'
Reading package lists... Done
Building dependency tree... Done
Reading state information... Done
All packages are up to date.
W: Failed to fetch http://archive.ubuntu.com/ubuntu/dists/jammy/InRelease  Temporary failure resolving 'archive.ubuntu.com'
W: Failed to fetch http://archive.ubuntu.com/ubuntu/dists/jammy-updates/InRelease  Temporary failure resolving 'archive.ubuntu.com'
W: Failed to fetch http://archive.ubuntu.com/ubuntu/dists/jammy-backports/InRelease  Temporary failure resolving 'archive.ubuntu.com'
W: Failed to fetch http://security.ubuntu.com/ubuntu/dists/jammy-security/InRelease  Temporary failure resolving 'security.ubuntu.com'
W: Some index files failed to download. They have been ignored, or old ones used instead.

我已尝试过:

  • 改变/etc/resolv.conf/etc/wsl.conf
  • 变得etc/resolv.conf不可变
  • 重置网络设置
  • 未注册的 Ubuntu 并且已禁用Hyper-V虚拟机平台西弗吉尼亚海岸多次(每次禁用和启用后重新启动)

结果:无,没有任何效果,没有任何问题得到解决

编辑1:我使用的 Ubuntu 发行版是 22.04 LTS

我想我找到了问题的根源,至少现在是这样。在我的网络适配器中,Hyper-V 没有创建允许 wsl 通过它访问我的其他网络适配器的虚拟交换机,所以我认为问题就在这里……我尝试使用 Hyper-V 管理器创建虚拟交换机,但到目前为止还没有成功……

编辑2:据我所知,经过多次卸载并重新安装后,WSL 和 Ubuntu 似乎都无法正确安装。

wsl --version这是我当前情况下的函数输出:

WSL version: 2.1.5.0
Kernel version: 5.15.146.1-2
WSLg version: 1.0.60
MSRDC version: 1.2.5105
Direct3D version: 1.611.1-81528511
DXCore version: 10.0.25131.1002-220531-1700.rs-onecore-base2-hyp
Windows version: 10.0.22631.3235

当我尝试启动 ubuntu 时,我得到了以下信息:

Launching Ubuntu...
Installing, this may take a few minutes...
WslRegisterDistribution failed with error: 0x80070002
Error: 0x80070002 The system cannot find the file specified.

Press any key to continue...

我已尝试从 Microsoft 网站手动下载更新:https://wslstorestorage.blob.core.windows.net/wslblob/wsl_update_x64.msi\ 但徒劳无功......现在我甚至无法再安装 Ubuntu,是的,当我尝试下载其他特定版本的 Ubuntu 发行版(例如 22.04、20.04 等)时也会发生同样的情况......

笔记:

好吧,然而就在它坏掉之前,所以这次它不想再安装了,我认为我遇到了第一个问题,因为没有虚拟交换机适配器允许 wsl 和发行版连接到我正在使用的网络。通常,此适配器的名称是 vEthernet,由 hyper-v 管理。我尝试通过 hyper-v 管理器手动创建一个,但徒劳无功……

答案1

当使用默认设置安装时,Ubuntu VM 中的网络在 WSL 上不起作用(截至本文发布之日)。

这不是 Ubuntu 的问题,答案属于 SuperUser 网站。我在那里发布了类似问题的答案: https://superuser.com/questions/1691097/wsl2-cannot-access-the-internet-on-windows-11

因为 Ask Ubuntu 用户可能会发现这很有用,所以无论如何做一个简短的总结:

在虚拟机中启用网络的最佳方式是使用部分networkingMode=mirrored中的设置。[wsl2].wslconfig

相关内容