MicrosoftDocs / WSL

Source code behind the Windows Subsystem for Linux documentation.
https://docs.microsoft.com/windows/wsl
Other
1.89k stars 556 forks source link

Accessing a WSL 2 distribution from your local area network (LAN) #1818

Closed kanine closed 8 months ago

kanine commented 10 months ago

Documentation Issue

The instructions on this page appear to be incomplete, and one step is inaccurate. Following these instructions closely I was unable to connect to a docker container running within a Ubuntu WSL image. The suggested improvements made connection possible.

Link to documentation page

https://learn.microsoft.com/en-us/windows/wsl/networking#accessing-a-wsl-2-distribution-from-your-local-area-network-lan

Suggested Improvements

The example shows this command:

netsh interface portproxy add v4tov4 listenport=4000 listenaddress=0.0.0.0 connectport=4000 connectaddress=172.30.187.232

However for this to work given this example, and allow access from other devices on the LAN the following Firewall Rules are required (based on the example of using port 4000):

New-NetFireWallRule -DisplayName 'WSL2' -Direction Outbound -LocalPort "4000" -Action Allow -Protocol TCP New-NetFireWallRule -DisplayName 'WSL2' -Direction Inbound -LocalPort "4000" -Action Allow -Protocol TCP

Also the step to determine the WSL VM IP address is incorrect, it should say:

which can be found by entering the command: wsl.exe hostname -I

note the capital I.

malcolm-dane commented 10 months ago

It's still not working. I don't know what they did but when I updated it killed the ability of wsl to broadcast to other local area computers.

mattwojo commented 8 months ago

Fixed the capital I issue in https://github.com/MicrosoftDocs/WSL/pull/1848

craigloewen-msft commented 8 months ago

We've also helped improve this with Mirrored networking. Please see the updated docs here for more info:

https://learn.microsoft.com/en-us/windows/wsl/networking#mirrored-mode-networking:~:text=Connect%20to%20WSL%20directly%20from%20your%20local%20area%20network%20(LAN)