首页 > 系统相关 >windows与wsl互相访问,windows10 / 11与子系统网络互相访问

windows与wsl互相访问,windows10 / 11与子系统网络互相访问

时间:2022-09-20 19:44:54浏览次数:92  
标签:11 Windows IP 互相 wsl 访问 172.27 WSL2

找出能与WSL2连接的那个IP。
启动WSL2,在子系统Linux键入如下命令:

cat /etc/resolv.conf

如:

nameserver 172.27.160.1

172.27.160.1就是我们要找的Windows的IP Address

找出wsl的ip
启动WSL2,键入如下命令:

$ip a |grep “global eth0”
输出举例:

inet 172.27.170.146/20 brd 172.27.175.255 scope global eth0

172.27.170.146就是我们要找的WSL2的IP Address

防火墙规则
默认情况下Windows的防火墙会阻止WSL2中应用对Windows的网络访问(see: Add “allow” rule to Windows firewall for WSL2 network · Issue #4585 · microsoft/WSL (github.com)),解决办法是添加一条防火墙规则允许WSL2对Windows的访问。请以管理员身份打开PowerShell并键入以下命令:

 PS C:> New-NetFirewallRule -DisplayName WSL -Direction Inbound -InterfaceAlias vEthernet (WSL) -Action Allow


标签:11,Windows,IP,互相,wsl,访问,172.27,WSL2
From: https://www.cnblogs.com/anakin/p/16712230.html

相关文章