The Windows Subsystem for Linux (WSL2) has long utilized Network Address Translation (NAT) by default to manage network traffic between the Linux virtual machine and the Windows host. While NAT works well for basic internet access, it creates complications when connecting via corporate VPNs, accessing Linux servers from local network (LAN) devices, or handling IPv6 traffic. Windows 11 introduced Mirrored Networking Mode, which mirrors the host network interfaces directly into Linux, resolving cross-network constraints.
Benefits of WSL2 Mirrored Networking Mode
Switching from default NAT to Mirrored Networking provides significant technical improvements:
- VPN Compatibility: Mirrored mode automatically routes traffic through active host VPN connections without requiring custom DNS or routing scripts.
- Local Area Network (LAN) Accessibility: Linux services listening on a port (such as
localhost:8080) become accessible directly via the Windows host’s physical LAN IP address. - IPv6 Support: Seamlessly enables full IPv6 connectivity inside Linux instances.
- Simplified Loopback: Windows can connect to Linux using
localhost, and Linux can connect to Windows usinglocalhostnatively.
Prerequisites for Mirrored Mode
To enable Mirrored Networking Mode, ensure your system meets these requirements:
- Windows 11 version 22H2 or higher (Build 22621 or newer).
- WSL version 2.0.0 or higher. You can check your version in PowerShell by running
wsl --version.
Configuring .wslconfig for Mirrored Networking
WSL global settings are managed through a configuration file in your Windows user profile directory:
- Press
Win + Xand launch Terminal or PowerShell. - Open or create the global
.wslconfigfile using Notepad:notepad "$env:USERPROFILE\.wslconfig" - Add the following configuration block:
[wsl2] networkingMode=mirrored dnsTunneling=true firewall=true autoProxy=true - In this configuration:
networkingMode=mirrored: Activates interface mirroring.dnsTunneling=true: Routes DNS queries through Windows virtualization proxy to improve VPN DNS resolution.firewall=true: Applies Windows Defender Firewall rules to WSL traffic.autoProxy=true: Automatically synchronises Windows HTTP proxy settings with Linux.
- Save the file and close Notepad.
Restarting WSL to Apply Configuration
To apply the new network architecture, restart the WSL subsystem completely:
# Shut down all active WSL instances:
wsl --shutdown
Launch your Linux distribution from the Start menu or by executing wsl in PowerShell.
Verifying Mirrored Interfaces and Connectivity
Once inside your Linux distribution, verify that network interfaces mirror your Windows host:
# Inspect active network interfaces:
ip addr show
Instead of the traditional virtual eth0 NAT adapter, you will see your physical Wi-Fi or Ethernet adapter names and IP addresses mirrored directly into Linux. Test outbound connectivity through an active corporate VPN to confirm seamless end-to-end communication.
Configuring Mirrored Networking in WSL2 delivers a transparent, enterprise-ready networking experience for developers on Windows 11.