WSL Windows IP 互访

WSL2 访问 Windows IP

WSL:

cat /etc/resolv.conf

nameserver 即为可访问的 Windows IP

Windows 开启 WSL2 对 Windows 的访问

添加规则允许 WSL2 通过防火墙。

Powershell:

New-NetFirewallRule -DisplayName "WSL" -Direction Inbound  -InterfaceAlias "vEthernet (WSL)"  -Action Allow

Windows 访问 WSL2 IP

Powershell:

wsl hostname -I

参考