Historically, Windows Subsystem for Linux (WSL 2) operated under a virtual Network Address Translation (NAT) architecture. While NAT isolated Linux guest containers cleanly, it created persistent networking friction for software engineers: accessing web services running inside WSL from local area networks required manual port forwarding rules, corporate VPN tunnels frequently severed internet connectivity inside Linux shells, and IPv6 traffic was unsupported. In modern Windows 11 updates, Microsoft introduced Mirrored Network Mode in WSL 2. Mirrored networking mirrors the host Windows network stack directly into the Linux guest, enabling shared IP addresses and seamless loopback connectivity.
Key Advantages of Mirrored Networking Over NAT
Switching from legacy NAT to Mirrored mode resolves core developer hurdles:
- Unified Localhost: Services bound to
127.0.0.1orlocalhostinside Linux are immediately reachable from Windows and vice versa without port proxy configurations. - Full IPv6 Support: Linux distributions inherit the host’s native IPv6 address assignments.
- VPN Compatibility: Enterprise VPN clients (such as Cisco AnyConnect, GlobalProtect, or OpenVPN) routing host traffic automatically route WSL 2 network packets without routing breakage.
- Direct LAN Access: Devices on your local Wi-Fi or Ethernet network can connect directly to server processes hosted in WSL 2 using the Windows machine’s physical LAN IP address.
Configuring Mirrored Mode via .wslconfig
Mirrored networking is controlled through the global .wslconfig file located in your Windows user profile directory:
- Press Win + R, type
notepad %UserProfile%\.wslconfig, and press Enter. (Click Yes if prompted to create a new file). - Insert the following configuration directives under the
[wsl2]section:[wsl2] networkingMode=mirrored dnsTunneling=true firewall=true autoProxy=true - Directive explanations:
networkingMode=mirrored: Activates the mirrored networking stack.dnsTunneling=true: Routes Linux DNS requests through the Windows DNS virtualization proxy, ensuring corporate VPN domain names resolve cleanly.firewall=true: Applies Windows Defender Firewall rules to incoming and outgoing WSL 2 traffic.autoProxy=true: Automatically maps HTTP/HTTPS proxy settings from Windows into Linux environment variables.
- Save and close the file.
Restarting WSL 2 and Verifying Network Mirroring
To apply global hypervisor changes, restart the WSL subsystem completely:
- Open PowerShell and shut down all active Linux instances:
wsl --shutdown - Relaunch your preferred Linux distribution (e.g., Ubuntu).
- Inside the Linux shell, inspect assigned network interfaces:
ip addr show - Notice that the legacy virtual
eth0NAT interface has been replaced by mirrored representations of your physical Ethernet and Wi-Fi adapters. - Start a test web server in Linux (e.g.,
python3 -m http.server 8080) and accesshttp://localhost:8080inside Windows Edge to verify instantaneous loopback routing.