WSL2 Network connection loft after some times (and sleep I guess)

Marc Al 206 Reputation points
2024-03-06T09:01:29.4+00:00

Hello,

I have installed WSL2 on my Win11 Pro so I can use rsync for backups, and manage my KVM (on linux easier).

Sometimes I have seen that I have a problem accessing my server (local and same network / mask...).

If I do a wsl --shutdown and after that I open bash again all is fine till the next time.

The network is as mirrorred (or bridged) no difference.

My ifconfig is

ifconfig
docker0: flags=4099<UP,BROADCAST,MULTICAST>  mtu 1500
        inet 192.168.1.123  netmask 255.255.255.0  broadcast 192.168.1.255
        inet6 fe80::1  prefixlen 64  scopeid 0x20<link>
        inet6 2a02:XXXXXXX  prefixlen 64  scopeid 0x0<global>
        ether 02:42:f5:dc:f1:5e  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.1.161  netmask 255.255.255.0  broadcast 192.168.1.255
        inet6 2a02:XXXXXXXXXXXX  prefixlen 64  scopeid 0x0<global>
        inet6 fe80::XXXXXXXX  prefixlen 64  scopeid 0x20<link>
        ether 74:56:3c:4a:e7:d1  txqueuelen 1000  (Ethernet)
        RX packets 19345  bytes 2095164 (2.0 MB)
        RX errors 0  dropped 0  overruns 0  frame 0
        TX packets 23403  bytes 2755839 (2.7 MB)
        TX errors 0  dropped 0 overruns 0  carrier 0  collisions 0

eth2: flags=4163<UP,BROADCAST,RUNNING,MULTICAST>  mtu 1500
        inet 10.0.8.15  netmask 255.255.255.0  broadcast 10.0.8.255
        inet6 fe80::f49c:6332:4cd:f54c  prefixlen 64  scopeid 0x20<link>
        ether 00:15:5d:27:14:21  txqueuelen 1000  (Ethernet)
        RX packets 0  bytes 0 (0.0 B)
        RX errors 0  dropped 0  overruns 0  frame 0
        TX packets 1166  bytes 184752 (184.7 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 5  bytes 560 (560.0 B)
        RX errors 0  dropped 0  overruns 0  frame 0
        TX packets 5  bytes 560 (560.0 B)
        TX errors 0  dropped 0 overruns 0  carrier 0  collisions 0

loopback0: flags=4163<UP,BROADCAST,RUNNING,MULTICAST>  mtu 1500
        ether 00:15:5d:97:d8:a8  txqueuelen 1000  (Ethernet)
        RX packets 317  bytes 58661 (58.6 KB)
        RX errors 0  dropped 0  overruns 0  frame 0
        TX packets 2  bytes 220 (220.0 B)
        TX errors 0  dropped 0 overruns 0  carrier 0  collisions 0

My ping result is (192.168.1.14 is the home server)

ping 192.168.1.14
PING 192.168.1.14 (192.168.1.14) 56(84) bytes of data.
From 192.168.1.123 icmp_seq=1 Destination Host Unreachable
From 192.168.1.123 icmp_seq=2 Destination Host Unreachable
From 192.168.1.123 icmp_seq=3 Destination Host Unreachable
From 192.168.1.123 icmp_seq=4 Destination Host Unreachable

Restarting the wsl (or the computer solves the problem) but it would be great to make it work.

I never shut down wsl so it is always ready.

Can you please help me?

Thank you

Windows
Windows
A family of Microsoft operating systems that run across personal computers, tablets, laptops, phones, internet of things devices, self-contained mixed reality headsets, large collaboration screens, and other devices.
5,822 questions
0 comments No comments
{count} votes

3 answers

Sort by: Most helpful
  1. Hania Lian - MSFT 22,706 Reputation points Microsoft External Staff
    2024-03-08T02:59:45.0233333+00:00

    Hello,

    Thank you for posting in Q&A forum.

    You can try below steps to further troubleshoot the issue:

    1.Please run PowerShell command

    Restart-Service LxssManager

    to restart the WSL service and see if it works.

    2.Check if the latest version is available and try to update WSL.

    3.Try to reset the WSL network by below command:

    wsl.exe --shutdown

    netsh winsock reset

    netsh int ip reset

    ipconfig /release

    which will reset the network socket and get a new IP.

    4.Try to capture a network capture by network monitor or wireshark when trying to launch the VPN connection. In the trace you can filter the IP address and TCP.Port and check if there's any insights.

    Best Regards,

    Hania Lian


    If the Answer is helpful, please click "Accept Answer" and upvote it.

    0 comments No comments

  2. Marc Al 206 Reputation points
    2024-03-08T04:46:12.1+00:00

    Hello,

    Restart-Service LxssManager didn't help

    I have the last version (from wsl --update)

    After doing

    wsl.exe --shutdown

    netsh winsock reset

    netsh int ip reset

    ipconfig /release

    And restarting the computer the connexion doesn't work anymore

    Do you have an idea?

    I have no VPN all is local

    Is there a way to restore the network configuration of WSL

    EDIT : If I use bridged instead of mirrored the network works again

    My .wslconfig is

    [wsl2]
    localhostForwarding=true
    kernelCommandLine = "sysctl.vm.max_map_count=262144"
    swap=0
    networkingMode=mirrored
    #networkingMode=bridged
    #vmSwitch=Hyper-V Switch Externe
    ipv6=true
    
    
    0 comments No comments

  3. Stephen Williams 0 Reputation points
    2024-08-07T22:47:22.6633333+00:00

    On Windows 11, WSL2, newest version, with Ubuntu 22.04. I have a problem where WSL2 locks up, networking and/or generally. wsl --shutdown hangs. Sometimes it will come back if I kill off all processes that match 'linux'. No VPN, no firewall. Just more data quickly than most circumstances. I've been using WSL2 + Ubuntu for a year, but just started transferring large amounts of data for a backup. Now I can reliably cause a hang in a few seconds. Transfer a lot of files into the local system using:

    rssh ******@system.com:directory .

    rssh as a script defined as:

    #!/bin/bash
    rsync -HpogDtSxlra --info=progress2 --no-i-r -e 'ssh -p 22' $@

    Separately, at the pure Windows level, we're doing a lot of streaming video+audio data via UDP (user-space HTTP3/QUIC/WebTransport): Periodically, Windows will stop passing any UDP traffic. Rebooting fixes it.

    0 comments No comments

Your answer

Answers can be marked as Accepted Answers by the question author, which helps users to know the answer solved the author's problem.