WSL networking in Windows 11: Mirrored mode and DNS tunneling guide

Add networkingMode=mirrored under [wsl2] in %UserProfile%\.wslconfig, run wsl --shutdown, and WSL 2 on Windows 11 22H2 or later mirrors the Windows network interfaces into Linux; DNS tunneling is already on by default.

This guide explains why the default NAT mode trips up VPNs and LAN access, how to switch modes in WSL Settings or by hand, which Hyper-V firewall rules to add, and how to test and roll back the change.

How to turn on WSL mirrored networking mode in Windows 11

These steps need Windows 11 version 22H2 or later and the current WSL from the Microsoft Store.

  1. Open PowerShell and run wsl --update to get the latest WSL release.
  2. Press Windows logo key + R, type notepad %UserProfile%\.wslconfig and press Enter. If the file does not exist yet, accept Notepad's prompt to create it.
  3. Add a [wsl2] line, and under it add networkingMode=mirrored and dnsTunneling=true.
  4. Save the file and close Notepad.
  5. Run wsl --shutdown in PowerShell, wait about 8 seconds, then open your distribution again.
  6. Run ip addr inside Linux. The interfaces and addresses now match the ones Windows shows in ipconfig.

WSL networking background

WSL 1 and WSL 2 reach the network in very different ways, which is why advice written for one often fails on the other.

Version or mode How it connects What you notice
WSL 1 Runs on the Windows network stack through a translation layer Linux apps share the Windows IP address and are reachable on the LAN like Windows apps
WSL 2, NAT (default) A Hyper-V utility VM behind a NAT service with its own virtual Ethernet adapter A separate IP address that changes on restart
WSL 2, mirrored Windows network interfaces mirrored into the Linux VM IPv6, localhost both ways, LAN access and better VPN compatibility
WSL 2, bridged Bridged to a Hyper-V switch Deprecated since WSL 2.4.5
WSL 2, none No network The WSL network is disconnected

Check which version each distribution uses with wsl -l -v. All networking modes in this guide apply to WSL 2 only, the default version for new distributions in a WSL development environment on Windows 11.

Why WSL networking feels broken

Most WSL 2 network complaints trace back to the VM sitting behind its own NAT, separate from the Windows adapters.

What you see Why it happens in NAT mode
Linux has a different IP address from Windows WSL 2 behaves like a virtual machine with a virtualized adapter
localhost from Linux does not reach a Windows server Linux must use the Windows host IP from ip route show
Other PCs on the LAN cannot reach a Linux service The VM address is private to the host, so a netsh interface portproxy rule is needed
The internet drops inside Linux after a VPN connects VPNs change routes and DNS servers that the NAT network does not follow
Names resolve on Windows but not in Linux The DNS packet from the VM to Windows is blocked by the network setup
No network at all on a work PC Enterprise firewall policy with local rule merging set to No blocks WSL

The default NAT model

NAT is still the default, and it works for most single-machine development. These are the rules it follows.

Connection How to make it in NAT mode
Windows app to a Linux server Use localhost:port; localhostForwarding=true handles it by default
Linux app to a Windows server Find the host IP with ip route show | grep -i default | awk '{ print $3}' and connect to that address
Find the Linux VM address from Windows Run wsl.exe hostname -I (capital I)
Another PC on the LAN to a Linux server Add netsh interface portproxy add v4tov4 listenport=4000 listenaddress=0.0.0.0 connectport=4000 connectaddress=<WSL IP> and allow the port
Linux server visible to remote clients Bind the app to 0.0.0.0 instead of 127.0.0.1
DNS inside Linux dnsProxy=true points Linux DNS at the NAT on the host; false copies the Windows DNS servers

The VM IP changes after every restart, so any portproxy rule that names it must be updated each time.

WSL NAT mode: curl from Linux reaches a Windows Node.js server by host IP
In NAT mode, Linux connects to a Windows server through the host IP address rather than localhost, and the request arrives. (Image: Microsoft)

VPNs, DNS, and the “no route” symptom

A VPN on Windows often leaves WSL 2 with no working route or no name resolution, even though Windows itself is online.

VPN behavior Effect on WSL Fix
Rewrites routes (Cisco AnyConnect is a documented case) NAT traffic from the VM has no route out Use mirrored mode, or Cisco's WSL 2 workaround in the AnyConnect admin guide
Applies NRPT DNS policies Linux queries skip the corporate DNS rules Turn on DNS tunneling so NRPT applies to WSL queries
Pushes more than three DNS servers /etc/resolv.conf holds only three DNS tunneling lets Linux use every Windows DNS server
Blocks DNS packets from the VM Names fail while IP addresses still work DNS tunneling answers DNS through a virtualization channel instead of a packet
Global Secure Access client returns temporary addresses WSL connections break after name resolution Set dnsTunneling=false or networkingMode=nat

Without tunneling, the manual fallback is to set generateResolvConf=false under [network] in /etc/wsl.conf and put the VPN DNS server first in /etc/resolv.conf.

What changed: DNS tunneling and mirrored networking

Microsoft introduced mirrored mode, DNS tunneling and Hyper-V firewall together in the WSL September 2023 update, and they have since moved into the main [wsl2] settings.

Feature .wslconfig key Default now What it does
Mirrored networking networkingMode=mirrored NAT Mirrors Windows network interfaces into Linux
DNS tunneling dnsTunneling=true On (Windows 11 22H2+) Resolves DNS through a virtualization feature instead of a network packet
Hyper-V firewall firewall=true On with WSL 2.0.9+ on 22H2+ Applies Windows Firewall rules and Hyper-V rules to WSL traffic
Auto proxy autoProxy=true On Copies the Windows HTTP proxy into Linux as HTTP_PROXY, HTTPS_PROXY and NO_PROXY

With DNS tunneling on, Linux /etc/resolv.conf points at 10.255.255.254, Windows answers each query with the DNS servers set in Windows, and the Windows hosts file policies apply without copying the file into Linux.

What mirrored mode gives you (and what it doesn’t)

Mirrored mode gives you Mirrored mode does not give you
IPv6 support IPv6 localhost: ::1 is not supported, only 127.0.0.1
Windows servers reachable from Linux at 127.0.0.1 Inbound UDP 68 and TCP 135, 1900, 2869, 3702, 5004, 5357 and 5358 steered to Linux
Direct LAN access to Linux services Inbound LAN traffic past the Hyper-V firewall without a rule
Better compatibility with VPNs Support for every VPN; some are confirmed incompatible
Multicast support Your own sysctl networking tweaks; WSL sets them and user changes are unsupported
No need to look up peer IP addresses Windows 10 support; it needs Windows 11 22H2 or later

Before you begin: minimum requirements and safety checklist

Requirement How to check it
Windows 11 version 22H2 or later Press Windows logo key + R, type winver and select OK
Store version of WSL, up to date Run wsl --version, then wsl --update
Distribution running as WSL 2 Run wsl -l -v; the VERSION column must show 2
Policy allows custom networking On managed PCs, the Intune policy Allow custom networking configuration must not be disabled
A backup of any existing .wslconfig Copy %UserProfile%\.wslconfig before you edit it
No unsaved work in Linux wsl --shutdown stops every running distribution at once

If WSL is missing, install WSL 2 on Windows 11 first, then change the network mode.

WSL mirrored mode requirement: Windows Subsystem for Linux in the Microsoft Store
Mirrored networking needs the Store version of WSL; run wsl –version, then wsl –update to keep it current. (Image: Microsoft)

How to enable mirrored networking (two ways)

Your situation Use this Why
You prefer a settings screen Method A: WSL Settings app Microsoft recommends WSL Settings over editing the file by hand
You need extra keys such as ignoredPorts or hostAddressLoopback Method B: edit .wslconfig The file accepts every documented key
You script setups across several PCs Method B: edit .wslconfig One text file copies cleanly between machines
Your organization manages WSL Ask IT Intune can set the default networking mode and block local changes

Method A: Use the WSL Settings app (GUI)

WSL Settings sits in the Start menu, and Microsoft recommends it over editing .wslconfig by hand.

  1. Select Start, type WSL Settings and open the app.
  2. Open the networking settings page in the app's left pane.
  3. Set the networking mode to Mirrored.
  4. Leave DNS tunneling, firewall and auto proxy switched on unless a known conflict applies to you.
  5. Close WSL Settings.
  6. Run wsl --shutdown in PowerShell and reopen your distribution so the new mode loads.
WSL networking in Windows 11: Mirrored mode and DNS tunneling guide
Search Start for WSL Settings, then select Networking in the left pane to change the networking mode. (Image: Microsoft)

Method B: Edit .wslconfig (manual)

.wslconfig does not exist by default. If it is missing or malformed, WSL starts normally and ignores it.

  1. Open File Explorer, type %UserProfile% in the address bar and press Enter.
  2. Create or open .wslconfig in Notepad; the path looks like C:\Users\<UserName>\.wslconfig.
  3. Add [wsl2] on its own line, followed by networkingMode=mirrored, dnsTunneling=true, firewall=true and autoProxy=true, one per line.
  4. For Docker or other Linux-only listeners, add ignoredPorts=3000,9000 (your ports) under [experimental].
  5. To reach WSL from Windows by the host's own IPv4 address, add hostAddressLoopback=true under [experimental].
  6. Save the file, run wsl --shutdown, and wait about 8 seconds before you start Linux again.

localhostForwarding is ignored once networkingMode=mirrored is set, so you can leave it out.

WSL .wslconfig networking settings reference

Key Section Default Notes
networkingMode [wsl2] nat none, nat, mirrored, consomme; bridged is deprecated
dnsTunneling [wsl2] true Windows 11 22H2 or later
firewall [wsl2] true Hyper-V firewall filtering of WSL traffic
autoProxy [wsl2] true Uses the Windows HTTP proxy in Linux
dnsProxy [wsl2] true NAT mode only
localhostForwarding [wsl2] true NAT mode only
ignoredPorts [experimental] none Mirrored only; comma-separated ports Linux may bind even if Windows uses them
hostAddressLoopback [experimental] false Mirrored only; allows host IPv4 addresses besides 127.0.0.1
dnsTunnelingIpAddress [experimental] 10.255.255.254 Nameserver written to /etc/resolv.conf
bestEffortDnsParsing [experimental] false Resolves the question and ignores unknown DNS records

Post‑change checklist: firewall and port rules

In mirrored mode, inbound LAN traffic to Linux passes through the Hyper-V firewall. Open only the ports you serve, from an elevated PowerShell window.

  1. Open PowerShell as administrator: search for PowerShell, then select Run as administrator.
  2. Run Get-NetFirewallHyperVVMCreator and confirm the WSL entry has VMCreatorId {40E0AC32-46A5-438A-A0B2-2B479E8F2E90}.
  3. Check the current policy with Get-NetFirewallHyperVVMSetting -PolicyStore ActiveStore -Name '{40E0AC32-46A5-438A-A0B2-2B479E8F2E90}'.
  4. Allow one port, for example a web server on 80: New-NetFirewallHyperVRule -Name MyWebServer -DisplayName "My Web Server" -Direction Inbound -VMCreatorId '{40E0AC32-46A5-438A-A0B2-2B479E8F2E90}' -Protocol TCP -LocalPorts 80.
  5. List the WSL rules with Get-NetFirewallHyperVRule -VMCreatorId '{40E0AC32-46A5-438A-A0B2-2B479E8F2E90}'.
  6. Bind the Linux app to 0.0.0.0 so it accepts LAN connections, then test from another PC.

LoopbackEnabled in that output shows whether host-to-WSL loopback traffic is allowed without rules; WSL turns it on by default.

Practical troubleshooting and validation commands

  1. wsl --version: shows the WSL, kernel and Windows versions. Use it before reporting a bug.
  2. wsl -l -v: lists each distribution with its WSL version and state.
  3. wsl --status: shows the default distribution and kernel version.
  4. wsl hostname -I: prints the Linux VM IP. In mirrored mode it matches a Windows adapter address.
  5. ip route show | grep -i default | awk '{ print $3}' (inside Linux): prints the default gateway, which is the Windows host in NAT mode.
  6. cat /etc/resolv.conf (inside Linux): shows nameserver 10.255.255.254 when DNS tunneling is on.
  7. env | grep -i proxy (inside Linux): lists the proxy variables autoProxy copied from Windows.
  8. wsl --shutdown: restarts the VM so .wslconfig changes apply.

How to check if WSL mirrored mode and DNS tunneling are on

  1. Run ipconfig in Windows and note the IPv4 address of your active adapter.
  2. Open your distribution and run ip addr. Mirrored mode shows that same address; NAT mode shows a separate private address.
  3. Run cat /etc/resolv.conf. nameserver 10.255.255.254 confirms DNS tunneling.
  4. Start a test server in Windows on a free port and run curl http://127.0.0.1:<port> from Linux. A reply confirms localhost works from Linux to Windows.

Known limitations and compatibility warnings

Limitation Effect Workaround
Docker Desktop containers with published ports (-p) Containers fail to be created in the default network namespace Use --network host, or list the port in ignoredPorts
Network Manager running in a container Loopback connections to the host fail Run sudo systemctl disable network-manager.service
Bitdefender 26.0.2.1, OpenVPN 2.6.501, McAfee Safe Connect 2.16.1.124 Confirmed incompatible VPNs with mirrored mode Use NAT mode with that VPN
Docker Desktop DNS Container DNS queries bypass DNS tunneling Docker applies host DNS settings its own way
DoH or DoT inside Linux Not possible while tunneling is on Windows DNS encryption already covers WSL; turn tunneling off only to run your own
generateResolvConf=false in wsl.conf DNS tunneling cannot turn on Leave generateResolvConf enabled
IPv6 disabled in the Windows registry WSL loses network connectivity Re-enable IPv6 components in Windows

Security considerations — don’t open the house

Open single ports with New-NetFirewallHyperVRule instead of setting DefaultInboundAction to Allow. Setting the Hyper-V default inbound action to Allow exposes every Linux listener to your LAN, and binding apps to 0.0.0.0 accepts connections from any address. Keep firewall=true, scope rules to the ports you need, and remember that Windows Firewall rules now apply inside WSL too. Hyper-V firewall rules can also be limited to the Public, Private or Domain profile.

Why this should be the default (and why it’s not)

For making mirrored the default Against it, today
Microsoft's own networking page recommends trying mirrored mode Microsoft's troubleshooting page still lists it as an experimental setting
Fixes VPN, IPv6, LAN and localhost gaps in one setting Some VPNs are confirmed incompatible
No more IP lookups or portproxy rules Docker Desktop published ports need a workaround
Applies Windows firewall and proxy policy consistently Enterprise policies can block custom networking modes

How to switch WSL back to NAT networking

  1. Open %UserProfile%\.wslconfig in Notepad.
  2. Change networkingMode=mirrored to networkingMode=nat, or delete the line.
  3. Keep dnsTunneling=true unless the Global Secure Access client or a DoH setup inside Linux needs it off.
  4. Save the file and run wsl --shutdown.
  5. Reopen the distribution and run ip addr; a separate private address confirms NAT mode.

A compact troubleshooting checklist (quick reference)

Mirrored mode setting has no effect

WSL was still running, the PC is older than Windows 11 22H2, or policy blocks custom networking.

  1. Run wsl --shutdown and wait 8 seconds.
  2. Check winver for version 22H2 or later.
  3. Confirm the line sits under [wsl2], not [experimental].
  4. Ask IT whether Allow custom networking configuration is disabled.

WSL has no network connectivity once connected to a VPN

The VPN changes routes or DNS that NAT mode does not follow.

  1. Set dnsTunneling=true and networkingMode=mirrored.
  2. Restart WSL with wsl --shutdown.
  3. If the VPN is on the incompatible list, return to NAT and put the VPN DNS server first in /etc/resolv.conf.

Other PCs cannot reach a Linux server

The Hyper-V firewall blocks inbound traffic or the app listens on 127.0.0.1 only.

  1. Add a New-NetFirewallHyperVRule for the port.
  2. Bind the app to 0.0.0.0.
  3. Check that the port is not one of the ports mirrored mode never steers to Linux.

WSL has no network connection on a work machine

Firewall policy sets local rule merging to No.

  1. Open Windows Defender Firewall with Advanced Security.
  2. Right-click Windows Defender Firewall with Advanced Security on Local Computer and select Properties.
  3. On the Public Profile tab, select Customize under Settings and check Rule merging.
  4. If it shows No, ask your administrator to add a rule for WSL.

Docker containers with published ports fail

Known issue with mirrored mode in the default network namespace.

  1. Run the container with --network host.
  2. Or add the port to ignoredPorts under [experimental] and restart WSL.
WSL no network on a work machine: check Rule merging in firewall properties
Open Properties, choose Customize under Settings and check Apply local firewall rules; No means your administrator must add a WSL rule. (Image: Microsoft)

WSL mirrored networking FAQ

What is mirrored mode in WSL?

Mirrored mode is a WSL 2 networking mode that copies the network interfaces you have on Windows into Linux. It adds IPv6, multicast, LAN access and localhost connections in both directions, and it improves compatibility with VPNs compared with the default NAT mode.

Does WSL mirrored mode work on Windows 10?

No. Mirrored networking, DNS tunneling and the Hyper-V firewall settings require Windows 11 version 22H2 or later. On Windows 10, WSL 2 uses NAT networking, and LAN access needs a netsh portproxy rule.

What does DNS tunneling do in WSL?

DNS tunneling answers DNS requests from Linux through a virtualization feature instead of sending a network packet to Windows. That keeps name resolution working behind VPNs and strict firewalls, applies NRPT policies and lets Linux use every Windows DNS server.

Is DNS tunneling on by default?

Yes. On Windows 11 22H2 and later, dnsTunneling defaults to true in the [wsl2] section of .wslconfig. You only need to add it if you turned it off earlier or want the setting written down explicitly.

Where is the .wslconfig file?

It lives in your user profile folder at %UserProfile%\.wslconfig, usually C:\Users\<UserName>\.wslconfig. The file does not exist until you create it, and its settings apply to every WSL 2 distribution after a restart.

Why can I not use ::1 to reach Windows from WSL?

Mirrored mode supports the IPv4 loopback address 127.0.0.1 only. The IPv6 localhost address ::1 is not supported, so point Linux clients at 127.0.0.1 when they connect to servers running on Windows.

How do I apply .wslconfig changes?

Run wsl --shutdown in PowerShell, wait about 8 seconds for the VM to stop, and open your distribution again. Closing the terminal window alone is not enough if any distribution is still running in the background.

Final analysis — strengths, risks, and recommended defaults

On Windows 11 22H2 or later, use networkingMode=mirrored with dnsTunneling, firewall and autoProxy left on, and open inbound ports one rule at a time. That combination fixes the common NAT problems with VPNs, IPv6, LAN access and localhost while keeping Windows firewall policy in force. Stay on NAT if your VPN is on the incompatible list, you rely on Docker published ports without a workaround, or your organization's policy sets the mode for you.

Philip Celasco

Philip is a Texas-based technology writer and IT administrator at Techdows.com with more than 10 years of experience creating practical content for everyday users and professionals. He specializes in web browsers, particularly Chromium-based platforms such as Google Chrome, Microsoft Edge, Brave, and Opera. Through his work as an IT administrator, Philip has hands-on experience managing devices, configuring browser policies, troubleshooting software and network issues, and helping people resolve problems that affect productivity and security. His articles are based on practical testing and real-world technical experience. He covers browser settings, extensions, performance problems, privacy controls, security features, and Windows troubleshooting. Outside work, Philip enjoys the quieter side of life in Texas and stepping away from the screen when he can. He has two kids, two cats and loves to play golf with his mother during the weekends.

Leave a Reply

Your email address will not be published. Required fields are marked *