microsoft / WSL

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

Ethernet Adapter vEthernet (WSL) missing/can not be created (-SwitchType Private) #8111

Open waldyd opened 2 years ago

waldyd commented 2 years ago

Version

Microsoft Windows [Version 10.0.19042.1526]

WSL Version

Kernel Version

Kernel version: 5.4.72

Distro Version

Debian

Other Software

Docker version 20.10.10, build b485636 VS Code: 1.64.2 f80445acd5a3dadef24aa209168452a3d97cc326 x64

Repro Steps

  1. Ethernet Adapter vEthernet (WSL) missing/not found using ipconfig
  2. Try to recreate it via powershell comands:
New-VMSwitch "WSL" -NetAdapterName "Ethernet"
set-vmswitch -name WSL -NetAdapterName Ethernet -AllowManagementOS 1
set-vmswitch 'WSL' -SwitchType Private
  1. Hyper-V Switch created without Ethernet Adapter vEthernet (WSL)

image

NIC C4*-*-*-*-*B4 successfully disconnected from port .
The server could not bind to the transport \Device\NetBT_Tcpip_{D7*-*-*-*-*E8} because another computer on the network has the same name.  The server could not start.
The server could not bind to the transport \Device\NetBT_Tcpip_{79*-*-*-*-*9F} because another computer on the network has the same name.  The server could not start.
The server could not bind to the transport \Device\NetBT_Tcpip_{2A*-*-*-*-*05} because another computer on the network has the same name.  The server could not start.
The operation 'Delete' succeeded on nic C4*-*-*-*-*B4 (Friendly Name: WSL).

WSL logs:

wsl-etl.zip

Expected Behavior

  1. Ethernet Adapter vEthernet (WSL) created
  2. WSL distro Conversion success

Actual Behavior

  1. Error Prompted:

    
    System.InvalidOperationException:
    Failed to deploy distro docker-desktop to C:\Users\NW539AL\AppData\Local\Docker\wsl\distro: exit code: -1
    stdout: The network was not found.
    
    stderr: 
    at Docker.ApiServices.WSL2.WslShortLivedCommandResult.LogAndThrowIfUnexpectedExitCode(String prefix, ILogger log, Int32 expectedExitCode) in C:\workspaces\master-merge\src\github.com\docker\pinata\win\src\Docker.ApiServices\WSL2\WslCommand.cs:line 146
    at Docker.Engines.WSL2.WSL2Provisioning.<DeployDistroAsync>d__17.MoveNext() in C:\workspaces\master-merge\src\github.com\docker\pinata\win\src\Docker.Engines\WSL2\WSL2Provisioning.cs:line 168
    --- End of stack trace from previous location where exception was thrown ---
    at System.Runtime.ExceptionServices.ExceptionDispatchInfo.Throw()
    at System.Runtime.CompilerServices.TaskAwaiter.HandleNonSuccessAndDebuggerNotification(Task task)
    at Docker.Engines.WSL2.WSL2Provisioning.<ProvisionAsync>d__8.MoveNext() in C:\workspaces\master-merge\src\github.com\docker\pinata\win\src\Docker.Engines\WSL2\WSL2Provisioning.cs:line 77
    --- End of stack trace from previous location where exception was thrown ---
    at System.Runtime.ExceptionServices.ExceptionDispatchInfo.Throw()
    at System.Runtime.CompilerServices.TaskAwaiter.HandleNonSuccessAndDebuggerNotification(Task task)
    at Docker.Engines.WSL2.LinuxWSL2Engine.<DoStartAsync>d__29.MoveNext() in C:\workspaces\master-merge\src\github.com\docker\pinata\win\src\Docker.Engines\WSL2\LinuxWSL2Engine.cs:line 190
    --- End of stack trace from previous location where exception was thrown ---
    at System.Runtime.ExceptionServices.ExceptionDispatchInfo.Throw()
    at System.Runtime.CompilerServices.TaskAwaiter.HandleNonSuccessAndDebuggerNotification(Task task)
    at Docker.ApiServices.StateMachines.TaskExtensions.<WrapAsyncInCancellationException>d__0.MoveNext() in C:\workspaces\master-merge\src\github.com\docker\pinata\win\src\Docker.ApiServices\StateMachines\TaskExtensions.cs:line 29
    --- End of stack trace from previous location where exception was thrown ---
    at System.Runtime.ExceptionServices.ExceptionDispatchInfo.Throw()
    at System.Runtime.CompilerServices.TaskAwaiter.HandleNonSuccessAndDebuggerNotification(Task task)
    at Docker.ApiServices.StateMachines.StartTransition.<DoRunAsync>d__5.MoveNext() in C:\workspaces\master-merge\src\github.com\docker\pinata\win\src\Docker.ApiServices\StateMachines\StartTransition.cs:line 67
    --- End of stack trace from previous location where exception was thrown ---
    at System.Runtime.ExceptionServices.ExceptionDispatchInfo.Throw()
    at Docker.ApiServices.StateMachines.StartTransition.<DoRunAsync>d__5.MoveNext() in C:\workspaces\master-merge\src\github.com\docker\pinata\win\src\Docker.ApiServices\StateMachines\StartTransition.cs:line 92
3. Ethernet Adapter vEthernet (WSL) not created
4. WSL distro Conversion failed

```powershell
 wsl  --set-version kali-linux 2
Conversion in progress, this may take a few minutes...
For information on key differences with WSL 2 please visit https://aka.ms/wsl2
The network was not found.
  1. Already tried this: https://docs.microsoft.com/en-us/troubleshoot/windows-client/virtualization/cannot-create-hyper-v-virtual-switch
  2. Duplicated ticket: https://github.com/microsoft/WSL/issues/6775

Diagnostic Logs

> wsl --list --online
The following is a list of valid distributions that can be installed.
Install using 'wsl --install -d <Distro>'.

NAME            FRIENDLY NAME
Ubuntu          Ubuntu
Debian          Debian GNU/Linux
kali-linux      Kali Linux Rolling
openSUSE-42     openSUSE Leap 42
SLES-12         SUSE Linux Enterprise Server v12
Ubuntu-16.04    Ubuntu 16.04 LTS
Ubuntu-18.04    Ubuntu 18.04 LTS
Ubuntu-20.04    Ubuntu 20.04 LTS

> wsl --list --verbose
  NAME            STATE           VERSION
* Ubuntu-18.04    Stopped         1
  kali-linux      Stopped         1

> wsl --install -d Debian
Downloading: Debian GNU/Linux
Installing: Debian GNU/Linux
Launching Debian GNU/Linux...
* Ubuntu-18.04    Stopped         1
  Debian          Running         1

> wsl --set-default Debian

> wsl --list --verbose
  NAME            STATE           VERSION
* Debian          Running         1
  kali-linux      Stopped         1
  Ubuntu-18.04    Stopped         1

> git clone https://github.com/microsoft/WSL --depth=1 $env:TMP\WSL
Cloning into 'C:\Users\NW539AL\AppData\Local\Temp\WSL'...
remote: Enumerating objects: 23, done.
remote: Counting objects: 100% (23/23), done.
remote: Compressing objects: 100% (22/22), done.
remote: Total 23 (delta 0), reused 13 (delta 0), pack-reused 0
Receiving objects: 100% (23/23), 7.17 MiB | 10.20 MiB/s, done.

> cd $env:TMP\WSL\diagnostics\

> .\networking.bat
... output added as attachment ...

wsl.zip

penguinpages commented 2 years ago

I think I am seeing similar / related bug / issue with WSL

I posted this in Windows forum here: https://docs.microsoft.com/en-us/answers/questions/756612/windows-11-hyperv-bridge-binding-to-nic-hidden-for.html?childToView=765392#answer-765392

Command line or GUI launch shows same error on launch

>wsl
The network was not found.

Ubuntu_WSL_Error

Question: 1) Where is the WSL configuration file stored for network configuration? 2) How can we list details of bridge that WSL links to?

Post also notes to collect diagnostics to go to cd $env:TMP\WSL\diagnostics\

PS C:\> cd $env:TMP\WSL\diagnostics\
cd : Cannot find path 'C:\Users\nerd\AppData\Local\Temp\WSL\diagnostics\' because it does not exist.
At line:1 char:1
+ cd $env:TMP\WSL\diagnostics\
+ ~~~~~~~~~~~~~~~~~~~~~~~~~~~~
    + CategoryInfo          : ObjectNotFound: (C:\Users\nerd\...SL\diagnostics\:String) [Set-Location], ItemNotFoundException
    + FullyQualifiedErrorId : PathNotFound,Microsoft.PowerShell.Commands.SetLocationCommand

How can we pull diagnostic logs?

penguinpages commented 2 years ago

Update: Removing Ubuntu / Ubuntu 20 and doing fresh installation does not fix this. So until their is update as to where this "network" is defined and cleaned up... WSL is broken

mszcool commented 2 years ago

Hey, I found a solution that worked in my case, a least:

After that, networking got fixed on my machine and I was able to re-use WSL2, again.

penguinpages commented 2 years ago

I updated Posting... but I tried remove / reboot / re-add WSL and no change. https://github.com/microsoft/WSL/discussions/8224 MS moved my question to a "dicussion" but no progress. But thanks for responding. I did glean a bit from above.

`PS C:\GitHub\penguinpages_cluster_devops\cluster_devops> wsl --list --verbose
NAME STATE VERSION

Windows Subsystem for Linux was last updated on 3/25/2022 WSL automatic updates are on.

Kernel version: 5.10.102.1 PS C:\GitHub\penguinpages_cluster_devops\cluster_devops>

`

Then I used windows to "launch ubuntu" and get this error:

image

. Installing, this may take a few minutes... WslRegisterDistribution failed with error: 0x803b0001 Error: 0x803b0001 The network was not found.

Press any key to continue.. ' image

Which lead to this thread: https://github.com/microsoft/WSL/issues/4959

So no fix.. but I think Windows sticks some virtual bridge interface ID / number into the WSL instance for the NIC... and when that gets orphaned / broken, their is no means to repair.

advra commented 1 year ago

@mszcool thanks for the suggestion. I had same error as OP.

  1. uncheck WSL from app & feature then restart
  2. check WSL from app & feature then restart
  3. reinstall from microsoft store and restart

Sadly I lost all my data but aside from that I finally have WSL working again

Mingquan-cloud commented 1 year ago

I updated Posting... but I tried remove / reboot / re-add WSL and no change. #8224 MS moved my question to a "dicussion" but no progress. But thanks for responding. I did glean a bit from above.

`PS C:\GitHub\penguinpages_cluster_devops\cluster_devops> wsl --list --verbose NAME STATE VERSION

  • Ubuntu Stopped 2 PS C:\GitHub\penguinpages_cluster_devops\cluster_devops> wsl --unregister Ubuntu Unregistering... PS C:\GitHub\penguinpages_cluster_devops\cluster_devops> wsl Windows Subsystem for Linux has no installed distributions. Distributions can be installed by visiting the Microsoft Store: https://aka.ms/wslstore PS C:\GitHub\penguinpages_cluster_devops\cluster_devops> wsl --install -d ubuntu Ubuntu is already installed. Launching Ubuntu... PS C:\GitHub\penguinpages_cluster_devops\cluster_devops> wsl --status Default Version: 2

Windows Subsystem for Linux was last updated on 3/25/2022 WSL automatic updates are on.

Kernel version: 5.10.102.1 PS C:\GitHub\penguinpages_cluster_devops\cluster_devops>

`

Then I used windows to "launch ubuntu" and get this error:

image

. Installing, this may take a few minutes... WslRegisterDistribution failed with error: 0x803b0001 Error: 0x803b0001 The network was not found.

Press any key to continue.. ' image

Which lead to this thread: #4959

So no fix.. but I think Windows sticks some virtual bridge interface ID / number into the WSL instance for the NIC... and when that gets orphaned / broken, their is no means to repair.

Hey Bro, I just resolved this error:0x803b0001. Hope here after comment will help for you.

  1. Execute Get-VMSwitch command in Windows Powershell,If it has clean enviroment there should just one "default switch" show up in the list which install after turn on Hyper-V.
  2. If there is more than one "default switch" show up after Get-VMSwitch command execute.you can open regedit and go to the path: HKEY_LOCAL_MACHINE\SYSTEM\CurrentControlSet\Services\vmsmp\parameters\SwitchList\{yada yada}
  3. Just delete the unnecessary visual switch and reboot your PC

Anyway, It is work for me.

Kadafi-Hub commented 6 months ago

Uninstall.

Then disable AV/Firewall

Then Reinstall.

Faaiq-84 commented 5 months ago

How to Re-install vEthernet, i Tried re-enableling Hyper -V but it wont install Ethernet again