Ir al contenido

Advanced WSL2 Diagnosis and Configuration

Resolving LxssManager hang issues, kernel updates, and advanced mirrored network configuration in WSL2.

0views

This technical guide compiles advanced procedures for diagnosis, repair, and network system configuration for the Windows Subsystem for Linux (WSL2). It focuses on resolving infinite process hangs (LxssManager), transitioning to the modern Store version, and optimizing routing via mirrored network mode (Mirrored).


When trying to run wsl or wsl -d <distro>, the console blinks and enters a continuous suspended state without loading the shell. When trying to force a stop with wsl --shutdown, the terminal freezes indefinitely on the “Stopping…” instruction.

Execute the native subsystem shutdown via Command Prompt (CMD):

Ventana de terminal
wsl --shutdown

Phase 2: Forced Thread and Process Stop (Hard Kill)

Sección titulada «Fase 2: Parada Forzada de Hilos y Procesos (Hard Kill)»

If the soft stop does not respond, it is mandatory to terminate the hypervisor virtual machine subprocesses (vmmem) and the host thread managers. Open PowerShell as Administrator and execute:

Ventana de terminal
taskkill /f /fi "imagename eq wsl*"
taskkill /f /im vmmem
taskkill /f /im wslhost.exe
taskkill /f /im conhost.exe

Phase 3: Releasing the Kernel Hang (LxssManager Hang)

Sección titulada «Fase 3: Liberar el Bloqueo del Kernel (LxssManager Hang)»

If the previous commands return an Access Denied error, a driver-level hang has occurred due to native network port collision (HNS/WinNAT).

The fastest and most efficient solution is to restart the Windows NAT service to unblock the kernel sockets:

Ventana de terminal
# 1. Detener el servicio NAT (Libera instantáneamente el bloqueo de WSL)
net stop winnat
# 2. Iniciar el servicio de nuevo
net start winnat
# 3. Localizar el PID del servicio LxssManager si el cuelgue persiste
tasklist /svc /fi "imagename eq svchost.exe" | findstr LxssManager
# 4. Forzar la finalización del hilo svchost por PID (Ejemplo: PID 36080)
Stop-Process -Id <PID> -Force

To enable advanced virtualization features such as Mirrored mode, it is mandatory to migrate from the version of WSL historically integrated into Windows (Legacy) to the decoupled version distributed via the Microsoft Store.

Ventana de terminal
wsl --version
  • If it returns an error message or incorrect syntax: The system is operating under the obsolete Legacy architecture version.
  • If it prints a table with kernel and WSL versions: The system is operating under the Microsoft Store version.

Forces the direct download of the updated package outside of the store if corporate network restrictions exist:

Ventana de terminal
# Actualizar el kernel a la versión de la Store
wsl --update
# Forzar la descarga por web de existir bloqueos en la Store
wsl --update --web-download
# Consolidar los cambios apagando el hipervisor
wsl --shutdown

To define the topology at the virtual hardware level, create the global configuration file in the root of your Windows user profile:

:: Ruta de destino obligatoria
C:\Users\usuario.demo\.wslconfig

File Extension

Make sure your file explorer does not invisibly add the .txt extension at the end. If it is created as .wslconfig.txt, the WSL engine will ignore the directive completely. You can fix it with PowerShell:

Ventana de terminal
Rename-Item -Path "C:\Users\usuario.demo\.wslconfig.txt" -NewName ".wslconfig" -Force

Copies the interfaces and IP addresses of your Windows machine directly into your Linux virtual machine. It is the standard configuration of excellence for network audits, pentesting, and microservices deployment:

C:\Users\usuario.demo\.wslconfig
[wsl2]
networkingMode=mirrored
dnsTunneling=true
autoProxy=true
firewall=true

Keeps the virtual machine isolated within its own independent virtual subnet (typically 172.x.x.x), routing traffic through the host:

C:\Users\usuario.demo\.wslconfig
[wsl2]
networkingMode=nat

Cause 1: Conflicts with Virtual Network Adapters (VPN / Tailscale)

Sección titulada «Causa 1: Conflictos con Adaptadores de Red Virtuales (VPN / Tailscale)»

The host's VPN networks can intercept the creation of the WSL network mirror bridge.

  • Solution: Temporarily stop the VPN service on Windows. If you use services on your Linux machine, make sure to suspend them before shutting down:
    Ventana de terminal
    sudo systemctl stop tailscaled
    And restart the environment from CMD: wsl --shutdown.

If the network bridge fails to bring up the virtual adapter after a Windows update:

Ventana de terminal
# Ejecutar en PowerShell como Administrador y reiniciar el PC
netsh int ip reset
netsh winsock reset

Windows Defender Firewall by default blocks unrecognized incoming connections from the WSL virtual adapter. Enable a dedicated permissive rule:

Ventana de terminal
New-NetFirewallRule -DisplayName "WSL Permitir Todo" -Direction Inbound -Action Allow -Program "System"

Run from PowerShell / CMD with elevated privileges:

ObjectiveCommand
List distros and verify version (v1 or v2)wsl --list --verbose
Access directly with root privilegeswsl -d kali-linux --user root
Release NAT service hangsnet stop winnat; net start winnat
Force shutdown the hypervisorwsl --shutdown
Audit the routing table in Linuxip a or ip route

  • ✓ Stability: The command wsl initializes the shell in less than 2 seconds.
  • ✓ Active Mirror: ip a within Linux reflects the same physical IP of the Windows WiFi/Ethernet network.
  • ✓ Synchronization: No network collisions after the controlled deactivation of the Tailscale driver.