WSL: Networking mirrored can't work on WSL2

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 --shutdown to 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:8000 succeeded.
    • curl http://localhost:8000 failed. Cannot connect. Reason: Timeout
    • curl http://127.0.0.1:8000 failed. Cannot connect. Reason: Timeout
  • Execute curl in Windows   (Windows curl -> WSL server)
    • curl http://192.168.3.11:8000 failed. Cannot connect. Reason: Timeout
    • curl http://localhost:8000 failed. Cannot connect. Reason: Timeout
    • curl http://127.0.0.1:8000 failed. 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:8000 failed. Cannot connect. Reason: Connection refused
    • curl http://localhost:8000 failed. Cannot connect. Reason: Timeout
    • curl http://127.0.0.1:8000 failed. Cannot connect. Reason: Timeout
  • Execute curl in Windows   (Windows curl -> Windows server)
    • curl 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

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

About this issue

  • Original URL
  • State: closed
  • Created 3 years ago
  • Comments: 40 (11 by maintainers)

Most upvoted comments

vim .wsconfig networking=nat

OK

Try executing the command

sudo systemctl disable network-manager.service

followed by running wsl.exe --shutdown in PowerShell, and then restart WSL again.

Same Issue Here.

I solved it by completely uninstalling the kernel package and reinstalling it.

Anybody faced same issue can try this solution.

image

Only one lo network card: image

update wsl 1.x to 2.0.4 and window to 23H2.

what’s wrong with me ?

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.

@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.

@grscottjo I tried your steps (even including the ignoredPorts part) but it simply doesn’t work. I can connect via 127.0.0.1 but not via the host IP.

@yqs112358 can you try this?

curl --noproxy \* http://127.0.0.1:8000