无法从WSL2 Ubuntu中ping通Ubuntu虚拟机

5

我正试图从我的WSL2 Ubuntu系统中ping我的Ubuntu虚拟机,反之亦然。两个Ubuntu的版本都是20.04.1。但是我可以从本地的Windows中ping通Ubuntu虚拟机。

从Windows到Ubuntu虚拟机

WUVM

从WSL2 Ubuntu到Ubuntu虚拟机

WSLUVM

2个回答

8
我们需要在两个虚拟交换机之间启用转发。使用以下命令(具有管理员权限),根据我的虚拟交换机名称设置生效。
Get-NetIPInterface | where {$_.InterfaceAlias -eq 'vEthernet (WSL)' -or $_.InterfaceAlias -eq 'vEthernet (Default Switch)'} | Set-NetIPInterface -Forwarding Enabled

以下是我的网络连接

在这里输入图片描述


1

这是一个很棒的命令行!为了减少日志输出,可以进行一些小的改进,只有在状态为Disabled时才激活Enabled。

Get-NetIPInterface | select ifIndex,InterfaceAlias,AddressFamily,ConnectionState,Forwarding| where {$_.InterfaceAlias -eq 'vEthernet (WSL)' -or $_.InterfaceAlias -eq 'vEthernet (Default Switch)'} | where {$_.Forwarding -eq 'Disabled'} | Set-NetIPInterface -Forwarding 'Enabled'

网页内容由stack overflow 提供, 点击上面的
可以查看英文原文,
原文链接