-
Notifications
You must be signed in to change notification settings - Fork 574
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
Netsh portproxy snippet unclear when forwarding traffic into WSL 2 #1890
Comments
THANK YOU! I no joke spent about four hours on this. I could not for the life of me figure out why none of the traffic on my port was being forwarded to WSL2 (I checked in Wireshark) and googled a million irrelevant things before I found this. The worst thing is that the rule looks identical when I do "netsh interface portproxy show all" the only difference is IT WORKS. |
I know, it's maddening. I'm glad opening this issue could help someone else. |
OMGGGGGGG TYSM!!!!!!! I thought that syntax was weird at first, but I ignored it. It turns out that the syntax for command substitution in Powershell is also |
Documentation Issue
Currently on WSL 2 it's necessary to add a port proxy with PowerShell in order to access servers running on it in your LAN. This relevant section on the docs has the following snippet
Suppose I'm running a Vite server and want to have access to it on my LAN. If I substitute the ports in this snippet with 5173 and run it, checking afterward said rule with
netsh interface portproxy show v4tov4
will show it was created successfully, with the connectaddress variable being resolved to my WSL 2 network adapter IP.But it won't work. If I first run
wsl hostname -I
and then substitute this IP into the snippet too, the traffic will be forwarded as expected.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
What I personally think is confusing is that executing the snippet substituting only the ports won't fail. Even checking said rule afterwards will show the WSL machine IP as if the command was successful, even if it won't actually work. This may lead users to think this step was done correctly and the reason they can't connect to their server by their LAN was because of something else, incorrect firewall rules for example.
Maybe if the connect value was between <> as well as the ports and
wsl hostname -I
was introduced before, it would make it clearer to the user that they are supposed to first to get the machine IP and then substitute it into the snippet, as they did with the ports.The text was updated successfully, but these errors were encountered: