WSL2 无法访问 windows ip(通过 `ip route | grep default | awk '{print $3}` 检索)

Mit*_*ril 6 networking windows-subsystem-for-linux wsl2

测试代码:

winip=$(ip route | grep default | awk '{print $3}')
ping $winip
Run Code Online (Sandbox Code Playgroud)

结果: 图像

其实我想在windows上使用代理服务主机。我看到很多人用上面的命令成功了,为什么我失败了?或者 wsl2 遇到新问题?

Mit*_*ril 6

好的。感谢该网站所有者的好意https://lengthmin.me/posts/wsl2-network-tricks/

我发现这是由于Windows防火墙...但似乎添加wsl2路径到白名单没有生效,需要关闭防火墙来解决这个问题。


感谢https://github.com/microsoft/WSL/issues/4585#issuecomment-610061194

这就是解决方案

New-NetFirewallRule -DisplayName "WSL" -Direction Inbound  -InterfaceAlias "vEthernet (WSL)"  -Action Allow
Run Code Online (Sandbox Code Playgroud)