WSL 开放外部访问
需要开启Windows防火墙
在开启端口转发
后记,这个不固定IP,还需要固定IP
wsl -d Ubuntu-22.04 -u root ifconfig wsl -d Ubuntu-22.04 -u root
ifconfig eth0 172.20.0.2/24 wsl -d Ubuntu-22.04 -u root route add
default gw 172.20.0.1 wsl -d Ubuntu-22.04 -u root service ssh start
powershell -c "Get-NetAdapter -IncludeHidden 'vEthernet (WSL)' |
Get-NetIPAddress | Remove-NetIPAddress -Confirm:$False;
New-NetIPAddress -IPAddress 172.20.0.1 -PrefixLength 24
-InterfaceAlias 'vEthernet (WSL)'; Get-NetNat | ? Name -Eq WSLNat | Remove-NetNat -Confirm:$False; New-NetNat -Name WSLNat
-InternalIPInterfaceAddressPrefix 172.20.0.0/24;"