Virtualization

Fix WSL 2 Networking Problems on Windows 11 and Server 2025: DNS, VPN, Proxy, and Port Forwarding

Aseem Kishore
15 min read

The Back Room Tech is reader-supported. We may earn a commission when you buy through links on our site. Learn more.

WSL 2 runs a real Linux kernel in a lightweight VM with its own virtual network adapter. That adapter is where DNS failures, VPN drops, and unreachable services usually start. This playbook is for managed Windows machines: find your networking mode, then apply targeted fixes without reinstalling anything.

The short answer: Most WSL 2 networking breakage comes from the default NAT mode clashing with VPN clients, corporate DNS, or the Hyper-V firewall. On Windows 11 22H2 or later, set networkingMode=mirrored and dnsTunneling=true in %UserProfile%\.wslconfig, then run wsl --shutdown. Microsoft describes mirrored mode as improving VPN compatibility and DNS tunneling as aimed at VPN and complex network setups, so it’s the first thing to try. Confirm the cause first, though, so you’re not guessing.

Prerequisites

  • Windows 10 version 2004 (Build 19041) or later, Windows 11, or Windows Server 2025
  • WSL 2 installed with at least one distribution registered. Installation is out of scope; see Microsoft’s install guide if you need it.
  • Administrator rights for firewall rules, netsh, and some wsl --update operations
  • Ubuntu 24.04 LTS for the Linux-side commands. The ip, getent, and cat commands work the same on Debian.
  • Windows only. WSL doesn’t exist on macOS.

Version-sensitive behavior below comes from Microsoft’s WSL networking documentation and the WSL GitHub releases, checked on 2026-10-11. Defaults vary by WSL release, so check the release notes for your installed version.

How WSL 2 Networking Works: NAT vs Mirrored Mode

NAT mode is the default. The WSL VM sits on a private virtual subnet, usually 172.x.x.x, behind a Hyper-V virtual switch. Windows translates traffic out to the real network. Windows reaches WSL through automatic localhost forwarding. Other LAN devices can’t reach WSL without a manual port proxy. VPN clients often don’t know the virtual subnet exists, so they route it into a black hole.

Mirrored mode copies the Windows network interfaces into Linux. WSL then shares the host’s IP addresses, routes, and DNS. Per Microsoft, it improves VPN compatibility, adds IPv6 support, and allows direct LAN access. It needs Windows 11 22H2 or later. The catch: it’s newer, so edge cases still turn up in GitHub issues. Windows and Linux services can also fight over ports, since both share the same address.

BehaviorNAT (default)Mirrored
WSL IP addressPrivate 172.x.x.xSame as Windows host
Windows → WSL via localhostYes (localhost forwarding)Yes
WSL → Windows via localhostNo (use the Windows host IP)Yes, 127.0.0.1 (IPv4 only; ::1 isn’t supported)
LAN → WSLNeeds netsh portproxyDirect, subject to Windows and Hyper-V firewall policy
VPN compatibilityOften poorMuch better
Minimum OSWindows 10 2004Windows 11 22H2

Quick Diagnosis

Run these checks before you change anything. They tell you which issue section applies.

Step 1: Check the WSL version and distro state

In PowerShell, run:

wsl --version
wsl --list --verbose

Example output (illustrative; your version numbers will differ):

WSL version: 3.0.1.0
Kernel version: 6.18.40.1-1
WSLg version: 1.0.66
Windows version: 10.0.26100.4652

NAME STATE VERSION
* Ubuntu-24.04 Running 2

If wsl --version returns an error, you’re on the old inbox WSL component. Run wsl --update before going further. If VERSION shows 1, none of the WSL 2 networking settings apply.

PowerShell window showing wsl --version output with WSL version 3.0.1.0 highlighted, followed by wsl --list --verbose showing Ubuntu-24.04 with VERSION 2

Step 2: Confirm the networking mode

WSL 2.0.4 and later ship wslinfo. The 2.0.4 release notes added its --networking-mode argument, which reports the active mode from inside the distro:

wslinfo --networking-mode

It prints the active mode, such as nat or mirrored. If the command isn’t found, run wsl --update from PowerShell and try again, or use the heuristic below:

ip addr show eth0

This is a heuristic, not an authoritative check. In NAT mode, eth0 typically holds a private address (often 172.x.x.x) that doesn’t appear in Windows ipconfig. In mirrored mode, Linux shows the same addresses as the Windows adapters. Confirm with wslinfo or your .wslconfig whenever you can.

Ubuntu terminal inside WSL showing ip addr output with the eth0 interface and its inet address highlighted

Step 3: Test each layer separately

ping -c 3 1.1.1.1              # raw IP connectivity
getent hosts learn.microsoft.com   # DNS through the system resolver
curl -I https://github.com     # -I fetches headers only; tests HTTPS and proxy

If ping works but getent fails, it’s DNS. If everything fails only while the VPN is up, it’s the VPN.

Step 4: Confirm Virtual Machine Platform is enabled

If WSL won’t start at all, check that Virtual Machine Platform is enabled under Turn Windows features on or off.

Windows Features dialog ('Turn Windows features on or off') with the Virtual Machine Platform and Windows Subsystem for Linux checkboxes highlighted

Configure .wslconfig Networking Options

.wslconfig lives at %UserProfile%\.wslconfig, for example C:\Users\jdoe\.wslconfig. It applies to every WSL 2 distro for that user. Create it in Notepad if it doesn’t exist.

# File: C:\Users\YOUR_USERNAME\.wslconfig
[wsl2]
networkingMode=mirrored    # NAT (default) or mirrored; mirrored needs Win 11 22H2+
dnsTunneling=true          # resolve DNS via Windows instead of a VM-side resolver
firewall=true              # apply Hyper-V firewall rules to WSL traffic
autoProxy=true             # copy the Windows proxy settings into WSL

[experimental]
hostAddressLoopback=true   # optional, mirrored only: also allow host-assigned IPv4 addresses (127.0.0.1 already works)
SettingValuesDefaultNotes
networkingModeNAT, mirroredNATUnsupported OS falls back to NAT with a warning
dnsTunnelingtrue/falsetrueWindows 11 22H2+
firewalltrue/falsetrueWindows 11 22H2+; applies Windows Firewall and Hyper-V rules to WSL traffic
autoProxytrue/falsetrueWindows 11 only
localhostForwardingtrue/falsetrueIgnored when networkingMode=mirrored
hostAddressLoopback ([experimental])true/falsefalseMirrored only; not needed for 127.0.0.1

Defaults and OS requirements come from Microsoft’s .wslconfig reference, which can change between WSL releases. Microsoft notes the Hyper-V firewall is on by default with Windows 11 22H2+ and WSL 2.0.9+.

Notepad showing C:\Users\USERNAME\.wslconfig with the [wsl2] section header and networkingMode, dnsTunneling, firewall, and autoProxy keys highlighted

Apply changes with a full VM restart:

wsl --shutdown   # stops ALL running distros; changes apply on next launch

Warning: wsl --shutdown kills every running distro, including Docker Desktop’s backend. Save your work in open WSL sessions first. Closing the terminal won’t do it, because the VM keeps running for several seconds after the last session exits.

Common Issues and Solutions

Problem: DNS Resolution Fails Inside WSL

Symptoms:

  • Temporary failure in name resolution from apt, curl, or git
  • ping 1.1.1.1 works but ping github.com doesn’t
  • Internal hostnames like jira.corp.local resolve on Windows but not in WSL

Why it happens: In NAT mode without DNS tunneling, WSL points /etc/resolv.conf at the host’s virtual adapter. A VPN may push its own DNS servers. A security agent may block DNS on that adapter. Either way, queries go nowhere.

Fix:

  • Check what WSL is using:
cat /etc/resolv.conf

With DNS tunneling active, the nameserver is usually the dnsTunnelingIpAddress value, which defaults to 10.255.255.254 per Microsoft’s .wslconfig reference. A 172.x.x.1 address usually points to plain NAT DNS. Treat both as diagnostic hints, not guarantees.

Ubuntu terminal inside WSL showing cat /etc/resolv.conf output with the nameserver 10.255.255.254 line highlighted
  • Compare it with Windows, in PowerShell:
Get-DnsClientServerAddress -AddressFamily IPv4
  • Enable dnsTunneling=true in .wslconfig and run wsl --shutdown. This is the cleanest fix. Windows resolves on WSL’s behalf and follows the VPN’s DNS automatically.
  • On Windows 10, or anywhere tunneling isn’t an option, pin the resolvers by hand. generateResolvConf goes in the per-distro /etc/wsl.conf file:
# File: /etc/wsl.conf (inside the distro)
[network]
generateResolvConf = false

Then run wsl --shutdown from PowerShell, reopen the distro, and replace the file:

sudo rm /etc/resolv.conf    # it's a symlink to a generated file; remove it first
printf "nameserver 10.0.0.53\nnameserver 1.1.1.1\nsearch corp.example.com\n" | sudo tee /etc/resolv.conf

Replace 10.0.0.53 and corp.example.com with your organization’s DNS server and search domain.

Warning: Hard-coded resolvers don’t follow the VPN. If you hop between office, home, and VPN, internal names will break again. Use dnsTunneling wherever you can.

Verify:

getent hosts github.com

Expected output: an IP address next to github.com.

Problem: WSL Loses Connectivity When the Corporate VPN Connects

Symptoms:

  • Everything works until the VPN client connects, then all WSL traffic times out
  • Small requests work, but git clone or apt downloads hang partway
  • Disconnecting the VPN restores access

Why it happens: Full-tunnel VPN clients rewrite the routing table and adapter metrics. In NAT mode, the WSL subnet often gets routed into the tunnel or dropped. Some VPNs also lower the MTU (maximum transmission unit). Large packets from WSL then get silently discarded.

Windows Settings app open to Network & Internet > VPN showing the list of configured VPN connections

Fix:

  • Switch to mirrored mode with DNS tunneling, as shown in the .wslconfig section above. Run wsl --shutdown, reconnect the VPN, and retest. Microsoft lists improved VPN compatibility as a goal of mirrored mode, so try this before anything else.
  • Stuck on NAT mode? Inspect routing before you change anything. In PowerShell, with the VPN connected:
Get-NetIPInterface -AddressFamily IPv4 | Sort-Object InterfaceMetric | Format-Table ifIndex, InterfaceAlias, InterfaceMetric
Get-NetRoute -AddressFamily IPv4 | Sort-Object RouteMetric | Select-Object -First 15

Then run ip route inside WSL. If the VPN adapter’s routes are clearly capturing WSL traffic, some admins lower that adapter’s priority as a last resort. Replace VPN_ADAPTER_NAME with the alias from the output above, in elevated PowerShell:

Set-NetIPInterface -InterfaceAlias "VPN_ADAPTER_NAME" -InterfaceMetric 6000
# Roll back:
Set-NetIPInterface -InterfaceAlias "VPN_ADAPTER_NAME" -AutomaticMetric Enabled

Warning: This is a community workaround that Microsoft doesn’t document, and it can break routing for other traffic. Many enterprise VPN clients reset metrics on every reconnect or enforce their own policy, so it may not stick. Get IT’s approval on managed machines.

  • If only large transfers hang, check the path MTU before changing anything. Replace INTERNAL_HOST with a host behind the VPN that answers ping:
ip link show eth0                          # note the current mtu value
ping -c 3 -M do -s 1322 INTERNAL_HOST      # 1322 + 28 header bytes = 1350

If larger sizes fail but this one succeeds, lower the MTU to the largest size that worked:

sudo ip link set dev eth0 mtu 1350   # temporary; resets after wsl --shutdown

To restore it without restarting, set the value back to the one ip link show reported.

Verify: With the VPN connected, curl -I https://github.com returns HTTP/2 200, and an internal hostname resolves with getent hosts.

Tip: If your VPN policy forbids local subnet access, no WSL setting will override it. Ask IT whether split tunneling or a WSL exception is allowed.

Problem: Can’t Reach a WSL Service from Windows or the LAN

Symptoms:

  • curl: (7) Failed to connect to localhost port 8080 from Windows
  • Windows works, but other devices on the LAN time out
  • The service worked yesterday, but the WSL IP changed after a reboot

Why it happens: The service may be bound only to 127.0.0.1. In NAT mode, LAN traffic has no path to the private WSL subnet. In mirrored mode, inbound LAN traffic is subject to Windows and Hyper-V firewall policy, which can block it until you allow it.

Fix:

  • Confirm the service is listening, and on which address:
ss -tlnp   # -t TCP, -l listening, -n numeric, -p show process

Look for 0.0.0.0:8080 or *:8080. If you only see 127.0.0.1:8080, set the app to bind to 0.0.0.0.

  • NAT mode, LAN access: forward a Windows port to the current WSL IP. Run this in elevated PowerShell:
$wslIp = (wsl hostname -I).Trim().Split(" ")[0]
netsh interface portproxy add v4tov4 listenport=8080 listenaddress=0.0.0.0 connectport=8080 connectaddress=$wslIp
# Create the firewall rule only once
if (-not (Get-NetFirewallRule -DisplayName "WSL 8080" -ErrorAction SilentlyContinue)) {
  New-NetFirewallRule -DisplayName "WSL 8080" -Direction Inbound -Protocol TCP -LocalPort 8080 -Action Allow
}

To review or clean up later:

netsh interface portproxy show v4tov4
netsh interface portproxy delete v4tov4 listenport=8080 listenaddress=0.0.0.0
Remove-NetFirewallRule -DisplayName "WSL 8080"

The WSL IP changes on every restart. Re-run the portproxy line each time, or schedule it as a logon task. It’s clunky, and it stays clunky.

  • Mirrored mode: skip the port proxy. Microsoft’s networking docs give two ways to allow inbound connections through the Hyper-V firewall, both in elevated PowerShell. {40E0AC32-46A5-438A-A0B2-2B479E8F2E90} is the VMCreatorId that identifies WSL. The narrow option opens one port:
New-NetFirewallHyperVRule -Name "WSL-Web-8080" -DisplayName "WSL Web 8080" -Direction Inbound -VMCreatorId '{40E0AC32-46A5-438A-A0B2-2B479E8F2E90}' -Protocol TCP -LocalPorts 8080

The broad option allows all inbound traffic to WSL. Avoid it on managed laptops:

Set-NetFirewallHyperVVMSetting -Name '{40E0AC32-46A5-438A-A0B2-2B479E8F2E90}' -DefaultInboundAction Allow

The Hyper-V firewall applies on Windows 11 22H2+ with WSL 2.0.9+. Windows Firewall rules and Group Policy still apply, so a single rule isn’t guaranteed to be enough.

Windows Defender Firewall with Advanced Security console showing the Inbound Rules list with the New Rule action highlighted in the Actions pane

Warning: Opening inbound ports on a managed laptop may violate policy, and Group Policy can override local rules. Check with your security team before exposing services to the LAN.

Verify: From another machine on the LAN, run curl -I http://WINDOWS_HOST_IP:8080. For a homelab jump box, a wired link through a 2.5GbE switch with Cat6 cable avoids Wi-Fi client isolation. That problem can look exactly like a firewall block.

Problem: Proxy Settings Not Picked Up Inside WSL

Symptoms:

  • curl works but apt update fails with Could not connect
  • The warning A localhost proxy configuration was detected but not mirrored into WSL appears at startup
  • echo $HTTPS_PROXY prints nothing

Why it happens: Per Microsoft, autoProxy (Windows 11 22H2 and later) makes WSL use the Windows HTTP proxy information. How that reaches individual tools varies by WSL version. A PAC-based setup may surface only a PAC URL (current releases expose it as WSL_PAC_URL) rather than a usable proxy address, and most CLI tools can’t evaluate PAC files. sudo doesn’t keep your shell’s proxy variables by default, and apt uses its own configuration. In NAT mode, WSL can’t use a proxy that listens on Windows’ 127.0.0.1.

Fix:

  • Check what WSL received:
echo "$HTTP_PROXY $HTTPS_PROXY $WSL_PAC_URL"
  • If the output is empty, set the variables by hand in ~/.bashrc:
# File: ~/.bashrc
export HTTP_PROXY="http://proxy.corp.example.com:8080"
export HTTPS_PROXY="http://proxy.corp.example.com:8080"
export NO_PROXY="localhost,127.0.0.1,.corp.example.com"
  • Configure apt separately:
printf 'Acquire::http::Proxy "http://proxy.corp.example.com:8080";\nAcquire::https::Proxy "http://proxy.corp.example.com:8080";\n' | sudo tee /etc/apt/apt.conf.d/95proxy
  • For a proxy listening on Windows localhost, mirrored mode lets WSL reach it at 127.0.0.1. That doesn’t guarantee every proxy (for example, one requiring Windows-integrated authentication) works with Linux CLI tools.

Verify: sudo apt update completes, and curl -I https://github.com returns 200.

Error Messages Quick Reference

ErrorMeaningFix
Temporary failure in name resolutionDNS unreachable from the VMEnable dnsTunneling or pin resolv.conf
Mirrored networking mode is not supported, falling back to NAT networkingOS is older than Windows 11 22H2Use NAT fixes or upgrade the OS
Unknown key 'wsl2.xxx' in ...\.wslconfigTypo or setting not supported by this WSL versionFix the spelling and run wsl --update
A localhost proxy configuration was detected but not mirrored into WSLNAT can’t reach a proxy on 127.0.0.1Use mirrored mode or a non-loopback proxy
curl: (7) Failed to connect to localhost port XService not listening or bound only to loopbackCheck with ss -tlnp and bind to 0.0.0.0
Network is unreachableNo default route, often caused by the VPNUse mirrored mode or adjust the VPN metric

Platform-Specific Notes

Windows 10 (2004 and later)

Mirrored mode, dnsTunneling, and the firewall setting require Windows 11 22H2 or later, and autoProxy is Windows 11 only, according to Microsoft’s .wslconfig reference. Those limits come from the OS, so updating the WSL package doesn’t lift them. You’re left with NAT mode, manual resolv.conf, proxy variables, and netsh portproxy.

Windows 11 22H2 and later

All the settings above are supported here, assuming a current WSL package (wsl --update). Some depend on the WSL release, such as the Hyper-V firewall on WSL 2.0.9+. Behind a corporate VPN, start with mirrored mode and DNS tunneling.

Windows Server 2025

Current WSL releases install on Server 2025, but Microsoft’s networking docs state Windows 11 22H2 as the requirement for mirrored mode and don’t list Server 2025 separately. Check that mirrored mode actually engaged with wslinfo --networking-mode. Don’t assume. Put jump boxes on a UPS-backed rack, too. After a power event, a dirty shutdown can leave the VM in a state that needs wsl --shutdown.

Configuration Mistakes to Avoid

  • Wrong file location. .wslconfig must sit directly in %UserProfile%. Notepad likes to save it as .wslconfig.txt. Run dir $env:USERPROFILE\.wslconfig to confirm the name.
  • Settings outside [wsl2]. Keys placed above the section header are ignored.
  • generateResolvConf in the wrong file. It belongs in /etc/wsl.conf under [network]. .wslconfig ignores it.
  • Closing the terminal instead of shutting down. Changes only apply after wsl --shutdown.

Getting Help: What to Collect Before Escalating

Gather this before opening a ticket with IT or on GitHub:

  • Output of wsl --version and wsl --list --verbose
  • Your .wslconfig contents and the distro’s /etc/wsl.conf
  • Output of ip addr, ip route, and cat /etc/resolv.conf from inside the distro
  • Output of ipconfig /all from Windows, plus the VPN client name and version
  • Microsoft’s networking log script, run in elevated PowerShell:
Invoke-WebRequest -UseBasicParsing "https://raw.githubusercontent.com/microsoft/WSL/master/diagnostics/collect-networking-logs.ps1" -OutFile collect-networking-logs.ps1
Set-ExecutionPolicy Bypass -Scope Process -Force   # this session only
.\collect-networking-logs.ps1

Reproduce the problem while the script runs. It produces a .zip file you can attach to the issue. Read through it before sharing, since it contains hostnames and IP addresses.

PowerShell window showing wsl --shutdown followed by wsl --update with its update-complete output highlighted

Prevention Tips

  • Update WSL regularly. wsl --update ships networking fixes on its own schedule, separate from Windows Update.
  • Standardize .wslconfig. Push a known-good file to managed machines through your config tooling.
  • Prefer mirrored mode with DNS tunneling on Windows 11 22H2 and later. It can replace many manual VPN and DNS workarounds.
  • Avoid hard-coded IPs. WSL’s NAT address changes on every restart.
  • Retest after VPN client upgrades. New VPN versions often change routing behavior.
Help & Answers

FAQ

2 questions

Do I need to reinstall WSL to fix networking?

Rarely. Start with editing .wslconfig, running wsl --shutdown, and running wsl --update, which are the fixes Microsoft’s documentation points to. If those don’t help, collect logs and escalate before reinstalling.

Does mirrored mode break Docker Desktop?

It shouldn’t, but port conflicts become possible because Windows and Linux share addresses. Check Docker Desktop’s release notes for your version.

Wrapping Up

Mirrored mode plus DNS tunneling is the best first fix to try on Windows 11 and Server 2025. It won’t beat a VPN policy that blocks local traffic, and it can still trip over port conflicts. NAT-only systems, mainly Windows 10, are stuck with the manual workarounds above. You’ll be re-running portproxy after every restart.

StepActionApplies To
1wsl --version, wslinfo --networking-modeAll
2Set networkingMode=mirrored, dnsTunneling=trueWin 11 22H2+, Server 2025
3Pin resolv.conf via /etc/wsl.confWindows 10 / NAT
4netsh portproxy or a Hyper-V firewall ruleLAN access
5Set proxy variables and apt proxy configProxy environments
6Run collect-networking-logs.ps1Escalation

Last updated: 2026-10-11 | Applies to WSL 2 on Windows 10 (2004+), Windows 11, and Windows Server 2025