microsoft / WSL

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

WSL2 Failed to configure network (networkingMode Nat) Error code 0x80070422 after Upgrading Windows Server 2019 to 2022 #12074

Open willi-neu9 opened 1 month ago

willi-neu9 commented 1 month ago

Windows Version

Microsoft Windows [Version 10.0.20348.2700] Windows Server 2022

WSL Version

2.2.4.0

Are you using WSL 1 or WSL 2?

Kernel Version

5.15.153.1-2

Distro Version

Debian

Other Software

Nothing special

Repro Steps

command: wsl --set-version debian 2 to convert Debian from WSL Version 1 to Version 2

Expected Behavior

Normal startup with network available.

Actual Behavior

Response: For information on key differences with WSL 2 please visit https://aka.ms/wsl2 Conversion in progress, this may take a few minutes. Failed to configure network (networkingMode Nat). To disable networking, set wsl2.networkingMode=None in C:\Users\admin.wslconfig Error code: Wsl/Service/CreateVm/ConfigureNetworking/HNS/0x80070422

Diagnostic Logs

WslLogs-2024-09-24_16-32-11.zip

github-actions[bot] commented 1 month ago

The logs show that the VM failed to start because the HNS network couldn't be created. Adding network tag

Diagnostic information ``` Detected appx version: 2.2.4.0 Detected user visible error: Wsl/Service/CreateVm/ConfigureNetworking/HNS/0x80070422 Found evidence of HcnCreateNetwork failure: HcnCreateNetwork {"Success":false,"Error":"The service cannot be started, either because it is disabled or because it has no enabled devices associated with it. ","ErrorCode":2147943458}. HResult: 0x80070422 ```
OneBlue commented 1 month ago

@keith-horton: This looks like a new error. Can you help us root cause this issue ?

willi-neu9 commented 1 month ago

What can I try to resolve that problem?

keith-horton commented 1 month ago

Hi there. From the traces it looks like HNS (the service WSL uses to create virtual networks) cannot start the SharedAccess service.

I don't have traces for the shared access service, but this can occur when there is another process listening on port 53. Can you see if this is what you're experiencing?

willi-neu9 commented 1 month ago

OK here are some additional steps I've tried: The server with the WSL 2 network problem is an upgrade from server 2019 to 2022. Not a new installation. I've tried a fresh installation of windows server 2022 and install all roles and features that are enabled on the old server, but without configur them. On fresh installed server 2022 WSL 2 runs without problem.

It seems that this is an upgrade error.

What I've tried on the upgraded server:

With "netstat -ano | findstr :53" I have found that dns server occupies Port 53. But stopping dns server does not remove the WSL error. So the WSL network error seems to be NOT a conflict between open Port 53.

Here is the list of installed applications, maybe It helps for a hint to resolve that problem.

installed_applications

Has anyone another idea what I can try without do a completely reinstall and reconfigure a new windows server 2022?

github-actions[bot] commented 1 month ago

The logs show that the VM failed to start because the HNS network couldn't be created. Adding network tag

Diagnostic information ``` Detected appx version: 2.2.4.0 Detected user visible error: Wsl/Service/CreateVm/ConfigureNetworking/HNS/0x80070422 Found evidence of HcnCreateNetwork failure: HcnCreateNetwork {"Success":false,"Error":"The service cannot be started, either because it is disabled or because it has no enabled devices associated with it. ","ErrorCode":2147943458}. HResult: 0x80070422 ```
keith-horton commented 1 month ago

It looks like this is Shared Access. if you can take a trace using this command, I can look to see what specifically is failing:

netsh trace start wireless_dbg globallevel=0xff maxSize=1000 report=disabled

netsh trace stop ---> this generates an ETL file.
willi-neu9 commented 1 month ago

Hi Keith,

thank you very much for your offer. What I will try tomorrow is a reupgrade from Server 2019 to 2022 with the change that I upgrade server 2019 to last patches and remove WSL and network driver before upgrading. If this still does not help, I send you a trace for analyzing.

/Willi/

willi-neu9 commented 1 month ago

@keith-horton Hi Keith,

as expected my idea to remove WSL before upgrading to server 2022 did not resolve the problem. So attached you will find the trace file for analyzing.

It would be great if this results in a helpful hint

/Willi/ NetTrace.zip

github-actions[bot] commented 1 month ago

Failed to parse logs. Unexpected file: NetTrace.etl The log file doesn't contain any WSL traces. Please make sure that you reproduced the issue while the log collection was running.

Diagnostic information ``` Found no WSL traces in the logs ```
keith-horton commented 1 month ago

@willi-neu9 , thanks for the trace. the shared access service is running, but it's failing when it tries to start winnat. The error is ERROR_SERVICE_DISABLED. Can you see if something has force disabled winnat from running? (winnat is a driver - it should be present in c:\windows\system32\drivers\winnat.sys)

willi-neu9 commented 1 month ago

@keith-horton, that was it! WINNAT driver was disabled because I've configured RAS only for VPN. Ok Enable WINNAT is the first step. It removes the error message. But WSL does not get an internet connection. There is more service missing. Maybe a NAT Service? If yes how to configure?

Do you have another hint?

/Willi/

keith-horton commented 1 month ago

Cool - progress! Can you get new traces using https://github.com/microsoft/WSL/blob/master/diagnostics/collect-networking-logs.ps1 with -RestartWslReproMode $true?

willi-neu9 commented 1 month ago

@keith-horton, thanks to your help I got WSL2 including network support up and running on updated windows Server 2022. Asking Perplexity says I have to install RAS NAT service to make WSL2 run with NAT. But that was not OK. WSL2 comes with its own NAT Service. What also confused me, that after starting WSL2 with Network NAT Service enabled, I could not find the virtual vEthernet (WSL) Adapter in "Control Panel\Network and Internet\Network Connections", like on windows 10, thinking, it has not be started. But "Get-NetAdapter" called in Powershell list also the vEthernet (WSL) Adapter.

I'm happy WSL2 is OK now on Windows Server 2022, let me go to the next step!

Thanks again!

/Willi/