-
Notifications
You must be signed in to change notification settings - Fork 822
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
Networking mirrored can't work on WSL2 #10632
Comments
Hi there. If you setup a listener within Docker within Linux, you'll want to let WSL know that the port is reserved and used by the WSL container by adding this to the .wslconfig file under experimental: ignoredPorts=8000 |
Thanks for your remind😂 |
If you are seeing issues, please collect traces so we can investigate what is going on: https://github.com/microsoft/WSL/blob/master/diagnostics/collect-wsl-logs.ps1 |
@yqs112358
|
Thank you. I tried 4 different tools to open the trace, but all were able to only resolve a couple of lines of a trace. Sorry. Could we try again and see if we get a more usable trace? We have a new script to collect networking logs, could you run this? https://github.com/microsoft/WSL/blob/master/diagnostics/collect-networking-logs.ps1 Thanks! |
@keith-horton use collect-networking-logs.ps1 script and upload logs at https://github.com/FlowerBirds/wsl2/blob/main/WslNetworkingLogs-2023-10-25_08-29-04.zip. Thanks! |
Sorry, but the same: cannot connect. (Both in Windows and WSL) |
I have upgraded to WSL preview 2.0.6 and tried again, but the problem still exists. |
@FlowerBirds , thank you for the trace. I'm seeing multiple errors unfortunately. Can you verify that WPA is installed and accessible from where you're running your script? e.g. it doesn't seem to be able to find wpr.exe:
Also, trying to run the shell script in Linux also failed. Can you run this from an administrator command prompt? Maybe that was the issue. wsl.exe : <3>WSL (17) ERROR: CreateProcessEntryCommon:511: execvpe ./networking.sh failed 2
<3>WSL (17) ERROR: CreateProcessEntryCommon:514: Create process not expected to return Thanks! |
Updated to WSL pre-release 2.0.9.0, the situation above has not changed. Some discovery attached:
So I think the port-sharing works well. The problem is only about why the network traffic cannot arrive the target port. |
@keith-horton In this record, I have done these actions step by step:
|
Thank you. I'll look at the trace. |
@keith-horton In this record, I have done these actions step by step:
These two tests are still all failed, just the same as the behavior in |
I was facing this same issue but seem to have worked around it. What I did that seems to have fixed it: I added
This page says Caveats:
|
@grscottjo Thanks for testing. However, according to Microsoft's documentation, the ability to connect from a LAN IP with
I have tried |
@grscottjo Thank you for you sharing! It seems work for me now, I have tried a lot of times. |
Update 2024.03.27: According to https://learn.microsoft.com/en-us/windows/wsl/wsl-config#wslconfig, when set But I have tested
|
@yqs112358 , you can connect to WSL from the host with mirrored mode, but you need allow loopback traffic through Hyper-V Firewall, and you need to create a Hyper-V Firewall rule to allow the port you want into the WSL container. See https://learn.microsoft.com/en-us/windows/security/operating-system-security/network-security/windows-firewall/hyper-v-firewall - look for LoopbackEnabled and New-NetFirewallHyperVRule. |
#11172 May be the same problem |
Try executing the command
followed by running wsl.exe --shutdown in PowerShell, and then restart WSL again. |
Yes. SystemD running its own Network Manager service is highly likely to hit compatibility issues with WSL. |
@wangyw6716 Cool, it works like a charm. |
@yqs112358 , can you see if you have NetworkManager running? that's not going to work well with WSL. |
@keith-horton Before I disable network-manager.service, I checked status by |
Thanks! |
Solved: Env:
|
By the way, does Docker currently support |
We have been working closely with Docker - they have made positive changes for new WSL features such as mirrored mode and DNS tunneling :) I would recommend using their latest updates. |
Disabling network-manager.service helped, |
This works! |
Windows Version
Microsoft Windows [Version 10.0.22631.2500]
WSL Version
2.0.14.0
Are you using WSL 1 or WSL 2?
Kernel Version
5.15.133.1-1
Distro Version
Ubuntu 20.04
Other Software
None
Repro Steps
.wslconfig
:wsl --shutdown
to stop WSLExpected Behavior
Both WSL and Windows can successfully access 127.0.0.1:8000 by
curl
Actual Behavior
My laptop's IP is 192.168.3.11 in WLAN
1. Test HTTP server on port 8000 in WSL
Execute
python -m http.server
in WSL. Output:Serving HTTP on 0.0.0.0 port 8000 (http://0.0.0.0:8000/) ...
curl http://192.168.3.11:8000
succeeded.curl http://localhost:8000
failed. Cannot connect. Reason: Timeoutcurl http://127.0.0.1:8000
failed. Cannot connect. Reason: Timeoutcurl http://192.168.3.11:8000
failed. Cannot connect. Reason: Timeoutcurl http://localhost:8000
failed. Cannot connect. Reason: Timeoutcurl http://127.0.0.1:8000
failed. Cannot connect. Reason: Timeout2. Test HTTP server on port 8000 in Windows
Execute
python -m http.server --bind 0.0.0.0
in Windows. Output:Serving HTTP on 0.0.0.0 port 8000 (http://0.0.0.0:8000/) ...
curl http://192.168.3.11:8000
failed. Cannot connect. Reason: Connection refusedcurl http://localhost:8000
failed. Cannot connect. Reason: Timeoutcurl http://127.0.0.1:8000
failed. Cannot connect. Reason: Timeoutcurl http://192.168.3.11:8000
succeeded.curl http://localhost:8000
succeeded.curl http://127.0.0.1:8000
succeeded.Diagnostic Logs
/etc/resolv.conf
ifconfig in WSL
The text was updated successfully, but these errors were encountered: