Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

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

Closed
kanine opened this issue Sep 20, 2023 · 3 comments
Closed

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

kanine opened this issue Sep 20, 2023 · 3 comments
Assignees

Comments

@kanine
Copy link

kanine commented Sep 20, 2023

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
Copy link

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
Copy link
Collaborator

Fixed the capital I issue in #1848

@craigloewen-msft
Copy link
Collaborator

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)

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

4 participants