-
Notifications
You must be signed in to change notification settings - Fork 821
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
WSL steals UDP Ports from Windows #12228
Comments
Logs are required for review from WSL teamIf this a feature request, please reply with '/feature'. If this is a question, reply with '/question'. How to collect WSL logsDownload and execute collect-wsl-logs.ps1 in an administrative powershell prompt:
The script will output the path of the log file once done. If this is a networking issue, please use collect-networking-logs.ps1, following the instructions here Once completed please upload the output files to this Github issue. Click here for more info on logging View similar issuesPlease view the issues below to see if they solve your problem, and if the issue describes your problem please consider closing this one and thumbs upping the other issue to help us prioritize it! Open similar issues:
Closed similar issues:
|
/question |
Diagnostic information
|
@avlec please specify what |
Sorry I meant to put that in the post. I'm using mirrored networking |
This is probably due to the fact that mirrored networking pre-reserves ports when starting WSL. assigning to @keith-horton |
Right - this is by design with Mirrored mode. Because Windows uses a global port pool, and mirrored mode forwards packets so the container has the same MAC and IP addressing as the host, we must give the WSL container a unique range of TCP+UDP ports that Linux can use as its ephemeral ports. |
Thanks for the response. I assumed it was something intentional. The problem I am running into is that the port ranges seem to for some reason now be consistently overlapping with ports an application in Windows needs to use which cause that application to not be able to function properly. Workaround is OK but not ideal. However, there is no indication in Windows explaining that WSL is using these ports. That makes identifying this as the issue challenging. |
Yeah, sorry about the confusion. If you launch the apps before starting WSL, we'll keep moving to find a different contiguous port range to configure in Linux. If you need to know what was configured, you can run something like the following in Linux to read the programmed ephemeral port range: sysctl net.ipv4.ip_local_port_range. |
if it's cool with you, I'll go ahead and close this. |
Yeah that's the workaround I got to anyways. Or shutting down WSL then opening the app that uses the ports. However, I did notice that sometimes after closing WSL that some ports were still unbind-able, that might be worth looking into. The workaround seems fine, as this is buried in internals it might change spontaneously one day and work better. Thanks for the help, and for pointing out the sysctl endpoint |
Windows Version
Microsoft Windows [Version 10.0.22621.3880]
WSL Version
2.3.24.0
Are you using WSL 1 or WSL 2?
Kernel Version
5.15.153.1-2
Distro Version
Ubuntu 24.04
Other Software
Using python to check for a basic UDP socket connection to rule out application specific quirks.
Repro Steps
Launch WSL. Try opening UDP ports until you get the following error message and that doesn't correspond to a port a real application is using in WSL or Windows (checked via netstat).
I was seeing a large range of ports that were unusable after starting WSL. I was seeing this range [44619, 48715] (4097 ports) being made un-bindable. If I start WSL with some application using a port in that range the range would shift. I was seeing this shift down to [37794, 41890] (4097 ports)
Expected Behavior
Launching WSL doesn't cause a blanket range of ports to be made unavailable in Windows but are still available in WSL. The ports shouldn't be
Actual Behavior
Launching WSL causes a blanket range of ports to be made available only inside WSL.
That is I can open UDP sockets on those ports within WSL but not in Windows.
Diagnostic Logs
No response
The text was updated successfully, but these errors were encountered: