microsoft / WSL

Issues found on WSL
https://docs.microsoft.com/windows/wsl
MIT License
17.47k stars 822 forks source link

No network communication between WSL2 and host / internet #11991

Open adestis-mb opened 2 months ago

adestis-mb commented 2 months ago

Windows Version

Windows 11, Version 23H2, OS Build 22631.4112)

WSL Version

2.2.4.0

Are you using WSL 1 or WSL 2?

Kernel Version

5.15.153.1-2

Distro Version

any

Other Software

No response

Repro Steps

I freshly installed my System in June or July 2024 including WSL2. Everything was fine and working. After some time passed by and I have not used WSL2 and after a bunch of Windows Updates I tried to use WSL2 last week. From an Ubuntu 22.04 distro I was unable to make any network communication. So I rebooted my system because I saw s.th. similar on other Windows systems before.

But also after a fresh reboot no network communication BESIDE DNS resolution is possible. I am also no able to ping the host anymore. This was working when I installed WSL2.

I already also tried the following things without success:

Expected Behavior

Network communication (ICMP, TCP, UDP) is possible from WSL2 to the host and to the Internet

Actual Behavior

Only ARP requests are arriving on the interface "vEthernet (WSL (Hyper-V firewall))" of the host.

Diagnostic Logs

No response

github-actions[bot] commented 2 months ago

Logs are required for review from WSL team

If this a feature request, please reply with '/feature'. If this is a question, reply with '/question'. Otherwise please attach logs by following the instructions below, your issue will not be reviewed unless they are added. These logs will help us understand what is going on in your machine.

How to collect WSL logs Download and execute [collect-wsl-logs.ps1](https://github.com/Microsoft/WSL/blob/master/diagnostics/collect-wsl-logs.ps1) in an **administrative powershell prompt**: ``` Invoke-WebRequest -UseBasicParsing "https://raw.githubusercontent.com/microsoft/WSL/master/diagnostics/collect-wsl-logs.ps1" -OutFile collect-wsl-logs.ps1 Set-ExecutionPolicy Bypass -Scope Process -Force .\collect-wsl-logs.ps1 ``` The script will output the path of the log file once done. If this is a networking issue, please use [collect-networking-logs.ps1](https://github.com/Microsoft/WSL/blob/master/diagnostics/collect-networking-logs.ps1), following the instructions [here](https://github.com/microsoft/WSL/blob/master/CONTRIBUTING.md#collect-wsl-logs-for-networking-issues) Once completed please upload the output files to this Github issue. [Click here for more info on logging](https://github.com/microsoft/WSL/blob/master/CONTRIBUTING.md#8-collect-wsl-logs-recommended-method) If you choose to email these logs instead of attaching to the bug, please send them to wsl-gh-logs@microsoft.com with the number of the github issue in the subject, and in the message a link to your comment in the github issue and reply with '/emailed-logs'.

View similar issues

Please 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:

Note: You can give me feedback by thumbs upping or thumbs downing this comment.

adestis-mb commented 2 months ago

/emailed-logs

github-actions[bot] commented 2 months ago
Diagnostic information ``` Found '/emailed-logs', adding tag 'emailed-logs' ```
adestis-mb commented 2 months ago

My problem is similar to https://github.com/microsoft/WSL/issues/6831 But in my case I don't have any external anti-virus SW running.

The solution in https://github.com/microsoft/WSL/issues/10774 does not work for me at all.

adestis-mb commented 2 months ago

BTW: I forgot to mention that I have tested the mirror modus as well. The result is the same, only ARP protocol is working but none of the IP protocols.

CatalinFetoiu commented 2 months ago

thanks for reporting the issue - can you please collect networking logs using this script? https://github.com/microsoft/WSL/blob/master/diagnostics/collect-networking-logs.ps1

it will create a zip with name starting with "WslNetworkingLogs"

please feel free to email those logs as well

adestis-mb commented 2 months ago

Log sent via email to wsl-gh-logs@microsoft.com

adestis-mb commented 2 months ago

Seems like your email servers are rejecting the created log file. I will upload it to onedrive and share the link via email.

adestis-mb commented 2 months ago

I also found out that there seems to be Hyper-V networking issues. So the test VM cannot ping the host though the firewall rules allows it.

When I create a new hyper-V network (internal) DHCP seems not to work.

I am really frustrated because I have installed Windows 11 only a few weeks ago.

zcobol commented 2 months ago

@adestis-mb there's hnsdiag command and few pwsh cmdlets that help troubleshooting your setup. From an elevated prompt try running hdsdiag list networks. Also get-hnsendpoint to see the settings of your WSL interface.

hnsdiag reset all will reset your networks, namespaces, endpoints and loadbalancers. Use hnsdiag --help for more info.

Cmdlets from the HostNetworkingService module:

CommandType     Name                                               Version    Source
-----------     ----                                               -------    ------
Function        Get-HnsEndpoint                                    1.0        HostNetworkingService
Function        Get-HnsNamespace                                   1.0        HostNetworkingService
Function        Get-HnsNetwork                                     1.0        HostNetworkingService
Function        Get-HnsPolicyList                                  1.0        HostNetworkingService
adestis-mb commented 2 months ago

Hi zcobol,

hnsdiag list networks does not list the WSL network:

> hnsdiag list networks
Network : F2FACF81-07FB-4F62-8C43-71ECE60D157A
    Name             : _TEST_PRIVATE
    Type             : Private
    Subnet Address   : 172.24.112.0/20
    Gateway          : 172.24.112.1

Network : 1DEC157D-4E96-4611-80B4-1330AC956C24
    Name             : _TEST_INTERNAL
    Type             : Internal
    Subnet Address   : 172.27.48.0/20
    Gateway          : 172.27.48.1

Network : C08CB7B8-9B3C-408E-8E30-5E16A3AEB444
    Name             : Default Switch
    Type             : ICS
    Subnet Address   : 172.19.96.0/20
    Gateway          : 172.19.96.1

While the Virtual Switch Manager shows the WSL network: image

get-hnsendpoint does not show anything even s.th. is running within WSL2

Unfortunately, there is no difference when I execute the hnsdiag reset all. The only thing which has changed is that the WSL network is now a private network where it was an internal network before (I think so).

Regards Markus

AlMar-Devel commented 1 month ago

Had similar issues, after many attempts this has been my solution (Windows 10 host machine, Ubuntu WSL guest):

https://stephenreescarter.net/wsl2-network-issues-and-win-10-fast-start-up/

tomeks666 commented 1 month ago

Same for me. This started on Sep 6th. I managed to clone some git repos in the WSL without any issue. But minutes later I needed to download something with apt and it showed all kinds of errors, which suggested some IP6 problem. I tried all kinds of fixes, workarounds, related to apt, then IP6, virtual switches, uninstalling WSL, reinstalling, downloading new distros, tweaking the firewall etc. In my case ICMP works, I can ping everything. But nothing TCP based seems to connect. Currently it is in "mirrored" network mode sharing IP with the host apparently.

adestis-mb commented 1 month ago

I think that MS messed up Hyper-V because I can see similar issues there. The only workaround for me was switching to WSL1. Not a solution for everything but in my case it helps me continuing my work.

wooksys commented 1 month ago

I'm doing something similar. If I choose mirrored, there is a problem that the IP address is connected to the host side. I do what I read from somewhere, so the network works.

  1. run "services.msc"
  2. stop "host network service"
  3. run "host network service"
adestis-mb commented 1 month ago

The restart of the HNS does not change anything for me. Even the reboot of the system has no positive impact. IMHO Microsoft has f***ed up Hyper-V with an update..

wooksys commented 1 month ago

Hello, Here's a batch file I use in admin mode every time I boot.

wsl --shutdown net stop hns net start hns pause

serbanghita commented 1 month ago

WSL networking stopped working for me after the last update to Windows 11, version 24H2

Microsoft Windows [Version 10.0.26100.2033]
(c) Microsoft Corporation. All rights reserved.

C:\Users\serba>wsl -l
  NAME                   STATE           VERSION
* Ubuntu                 Running         2
  docker-desktop-data    Stopped         2
  docker-desktop         Stopped         2

C:\Users\serba>wsl -v
WSL version: 2.3.24.0
Kernel version: 5.15.153.1-2
WSLg version: 1.0.65
MSRDC version: 1.2.5620
Direct3D version: 1.611.1-81528511
DXCore version: 10.0.26100.1-240331-1435.ge-release
Windows version: 10.0.26100.2033

@wooksys solution works for me, created a wsl-fix.bat file that I'm running as an Administrator.

jtnord commented 1 week ago

The above script works (mostly) for me. When it does work when I then start ubuntu I am greeted with the following WSL warning:

❯ bash
wsl: Failed to create network endpoint with address: '172.21.2.10', assigned new address: '172.28.4.141'