Repository navigation
Closed
Labels
Description
Windows Version
Microsoft Windows [Version 10.0.22631.2500]
WSL Version
2.0.14.0
Are you using WSL 1 or WSL 2?
- WSL 2
- WSL 1
Kernel Version
5.15.133.1-1
Distro Version
Ubuntu 20.04
Other Software
None
Repro Steps
- Set
.wslconfig:
[experimental]
networkingMode=mirrored
dnsTunneling=true
firewall=true
wsl --shutdownto stop WSL- Allow tcp port 8000 in Windows firewall settings
- Restart WSL
Expected 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/) ...
- Execute curl in WSL (WSL curl -> WSL server)
curl http://192.168.3.11:8000succeeded.curl http://localhost:8000failed. Cannot connect. Reason: Timeoutcurl http://127.0.0.1:8000failed. Cannot connect. Reason: Timeout
- Execute curl in Windows (Windows curl -> WSL server)
curl http://192.168.3.11:8000failed. Cannot connect. Reason: Timeoutcurl http://localhost:8000failed. Cannot connect. Reason: Timeoutcurl http://127.0.0.1:8000failed. Cannot connect. Reason: Timeout
2. 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/) ...
- Execute curl in WSL (WSL curl -> Windows server)
curl http://192.168.3.11:8000failed. Cannot connect. Reason: Connection refusedcurl http://localhost:8000failed. Cannot connect. Reason: Timeoutcurl http://127.0.0.1:8000failed. Cannot connect. Reason: Timeout
- Execute curl in Windows (Windows curl -> Windows server)
curl http://192.168.3.11:8000succeeded.curl http://localhost:8000succeeded.curl http://127.0.0.1:8000succeeded.
Diagnostic Logs
/etc/resolv.conf
nameserver 127.0.0.42
ifconfig in WSL
br-d0766515769e: flags=4099<UP,BROADCAST,MULTICAST> mtu 1500
inet 172.18.0.1 netmask 255.255.0.0 broadcast 172.18.255.255
ether 02:42:03:7d:ec:8b txqueuelen 0 (Ethernet)
RX packets 0 bytes 0 (0.0 B)
RX errors 0 dropped 0 overruns 0 frame 0
TX packets 0 bytes 0 (0.0 B)
TX errors 0 dropped 0 overruns 0 carrier 0 collisions 0
docker0: flags=4099<UP,BROADCAST,MULTICAST> mtu 1500
inet 172.17.0.1 netmask 255.255.0.0 broadcast 172.17.255.255
ether 02:42:98:0b:74:7d txqueuelen 0 (Ethernet)
RX packets 0 bytes 0 (0.0 B)
RX errors 0 dropped 0 overruns 0 frame 0
TX packets 0 bytes 0 (0.0 B)
TX errors 0 dropped 0 overruns 0 carrier 0 collisions 0
eth1: flags=4163<UP,BROADCAST,RUNNING,MULTICAST> mtu 1500
inet 192.168.3.11 netmask 255.255.255.0 broadcast 192.168.3.255
inet6 fe80::1c95:c4bd:2c0b:12fd prefixlen 64 scopeid 0x20<link>
ether 40:ec:99:cf:f2:a6 txqueuelen 1000 (Ethernet)
RX packets 280 bytes 21218 (21.2 KB)
RX errors 0 dropped 0 overruns 0 frame 0
TX packets 158 bytes 21856 (21.8 KB)
TX errors 0 dropped 0 overruns 0 carrier 0 collisions 0
lo: flags=73<UP,LOOPBACK,RUNNING> mtu 65536
inet 127.0.0.1 netmask 255.0.0.0
inet6 ::1 prefixlen 128 scopeid 0x10<host>
loop txqueuelen 1000 (Local Loopback)
RX packets 86 bytes 10468 (10.4 KB)
RX errors 0 dropped 0 overruns 0 frame 0
TX packets 86 bytes 10468 (10.4 KB)
TX errors 0 dropped 0 overruns 0 carrier 0 collisions 0
loopback0: flags=4163<UP,BROADCAST,RUNNING,MULTICAST> mtu 1500
ether 00:15:5d:d8:86:a8 txqueuelen 1000 (Ethernet)
RX packets 20 bytes 1416 (1.4 KB)
RX errors 0 dropped 0 overruns 0 frame 0
TX packets 12 bytes 888 (888.0 B)
TX errors 0 dropped 0 overruns 0 carrier 0 collisions 0
Reacted by Miles Buckton
Activity
[-]Networking mirrored can't work on WSL 2.0.4.0[/-][+]Networking mirrored can't work on 127.0.0.1[/+][-]Networking mirrored can't work on 127.0.0.1[/-][+]Networking mirrored can't work on 127.0.0.1, only localhost[/+][-]Networking mirrored can't work on 127.0.0.1, only localhost[/-][+]Networking mirrored can't work on WSL 2.0.4.0[/+]keith-horton commentedon Oct 18, 2023
Hi there.
Are you setting up the server within the Docker container in Linux? Note that Docker has its own IP address on its own network device. How did you configure it in Linux to forward requests to that address within Docker?
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
yqs112358 commentedon Oct 19, 2023
Thanks for your remind😂
But this test is actually done in real WSL, not in a docker container.
I have removed docker-related content in this issue to avoid confusion.
sf467 commentedon Oct 19, 2023
The mirrored network feature of wsl doesn't work on my machine either.


my win11 is dev channal, build 23570, but......
FlowerBirds commentedon Oct 20, 2023
Only one lo network card:

update wsl 1.x to 2.0.4 and window to 23H2.
what's wrong with me ?
keith-horton commentedon Oct 23, 2023
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
FlowerBirds commentedon Oct 24, 2023
Keith Horton (@keith-horton) https://github.com/FlowerBirds/wsl2/blob/main/WslLogs-2023-10-24_08-49-22.zip
Thanks
shigenobuokamoto commentedon Oct 24, 2023
YQ (@yqs112358)
can you try this?
keith-horton commentedon Oct 24, 2023
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!
FlowerBirds commentedon Oct 25, 2023
Keith Horton (@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!
yqs112358 commentedon Oct 25, 2023
Sorry, but the same: cannot connect. (Both in Windows and WSL)
I think it's not the problem of proxy because I have not set
$http_proxyyqs112358 commentedon Oct 25, 2023
I have upgraded to WSL preview 2.0.6 and tried again, but the problem still exists.
Actual Behaviorsection is updated. I have tested creating server in Windows too and posted the result above.17 remaining items
keith-horton commentedon Mar 26, 2024
YQ (@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.
yunsii commentedon Mar 28, 2024
#11172 May be the same problem
wade6716 commentedon Apr 1, 2024
Try executing the command
followed by running wsl.exe --shutdown in PowerShell, and then restart WSL again.
keith-horton commentedon Apr 1, 2024
Yes. SystemD running its own Network Manager service is highly likely to hit compatibility issues with WSL.
yunsii commentedon Apr 2, 2024
@wangyw6716 Cool, it works like a charm.
keith-horton commentedon Apr 2, 2024
YQ (@yqs112358) , can you see if you have NetworkManager running? that's not going to work well with WSL.
yunsii commentedon Apr 2, 2024
Keith Horton (@keith-horton) Before I disable network-manager.service, I checked status by
systemctl status network-manager.service, and network-manager.service is running. It works after I disabled network-manager.service.keith-horton commentedon Apr 2, 2024
Thanks!
yqs112358 commentedon Apr 3, 2024
Solved:
I have uninstall WSL and Ubuntu thoroughly, and then re-install again.
After a complete reinstall,
networkingMode=mirroredworks well. Both directions are accessiable by curl127.0.0.1orlocalhost.In new Ubuntu, I have found that
network-manager.servicedoes not exist. Maybe this service does have some what of effect, or maybe there was some problem with the network configuration of my old WSL. Anyway, this feature is now fully functional. Thanks for your hard work 😊 Keith Horton (@keith-horton) @wangyw6716Env:
yqs112358 commentedon Apr 3, 2024
By the way, does Docker currently support
network=mirroredwell?Some of my work dependents on this and it would be great if
mirroredcould be supported effectively.keith-horton commentedon Apr 3, 2024
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.
RomanZhakhovTR commentedon Jun 21, 2024
Disabling network-manager.service helped,
Thanks a lot :)
jahanarun commentedon Sep 7, 2024
This works!
Now, how do I use this
noproxymode in other apps?FrankFang commentedon Nov 11, 2024
Roman Zhakhov (@RomanZhakhovTR) How could I disable network-manager.service, I could not find it.