This Fixes: WSL2 Has No Network or DNS After a Windows Update or VPN Connect

You connect the corporate VPN, or a Windows update lands overnight, and suddenly apt update hangs and ping github.com says the name does not resolve. The Linux side is fine; the network under it moved.

This is the single most common WSL2 failure I get asked about, and almost every answer online is the same wrong answer: overwrite /etc/resolv.conf with 8.8.8.8 and move on. It works until the next reboot, because WSL2 regenerates that file and throws your edit away. The reason people keep pasting it is that they never worked out which of three different failures they actually had. Match the symptom to the cause first, then the fix is small and it sticks.

What is actually breaking

WSL2 does not share your Windows network stack the way the old WSL1 did. It runs a lightweight virtual machine behind a NAT, and Windows brokers its traffic and its DNS. Two moving parts cause nearly all the pain.

Free · 4 minutes

Is your engineering team shipping safely, or quietly accumulating risk?

Fourteen questions on how work gets from idea to production — cadence, testing, rollback, and the key-person risk in your delivery. Banded finding on screen, full sheet by email.

First, WSL auto-generates /etc/resolv.conf on every start. By default generateResolvConf is true, so whatever nameserver Windows hands over gets written in for you. When that handover is wrong or stale, DNS dies and your manual edit is erased on the next boot. Second, a corporate VPN client rewrites the host routing table and DNS with its own interface, usually at a low metric so all traffic prefers the tunnel. WSL2’s NAT network does not automatically follow those changes, so packets either leave by the wrong interface or the tunnel’s split-DNS never reaches the Linux side. A Windows feature update can also silently reset your networking mode or re-enable defaults you had turned off.

So there are three distinct failures: a stale generated resolv.conf, a VPN that has captured routing and DNS, and a networking mode that no longer suits your machine. Each has its own fix.

Diagnose before you touch anything

Thirty seconds of diagnosis saves you from applying the wrong fix. Inside WSL:

# Can I reach the internet at all, bypassing DNS?
ping -c 2 1.1.1.1

# Does name resolution work?
ping -c 2 github.com
cat /etc/resolv.conf

# What is WSL using as its default route?
ip route show default

If ping 1.1.1.1 works but ping github.com fails, it is DNS only, so you want the resolv.conf fix. If ping 1.1.1.1 also fails and the failure started when the VPN came up, it is routing, so you want mirrored mode or an interface metric. Reading a broken route table is a skill worth having beyond WSL; our network debugging cheat-sheet covers the same ss, dig and ip commands you will reach for here.

Fix 1: pin your own DNS so it survives a reboot

Use this when connectivity works but names do not resolve. The point is to stop WSL regenerating the file, not just to edit it once. Create /etc/wsl.conf inside the distribution:

# /etc/wsl.conf
[network]
generateResolvConf = false

Then replace the file WSL was managing. It is often a symlink to a run-time copy, so remove it before writing a plain file, or your nameservers will not stick:

sudo rm -f /etc/resolv.conf
sudo tee /etc/resolv.conf > /dev/null <<'EOF'
nameserver 1.1.1.1
nameserver 8.8.8.8
EOF

# Optional: make it immutable so nothing rewrites it
sudo chattr +i /etc/resolv.conf

On a VPN with internal-only hostnames, use your corporate resolver instead of the public ones, or you will resolve the public internet but never reach internal services. Apply it with a full restart of the subsystem from PowerShell:

wsl --shutdown

wsl --shutdown is not optional. Neither wsl.conf nor .wslconfig is re-read until the VM stops completely and starts fresh; restarting the terminal alone does nothing.

Fix 2: mirrored networking mode for the VPN case

When the VPN has captured routing and even ping 1.1.1.1 fails, the durable fix on Windows 11 is to stop using NAT and mirror the host network instead. In mirrored mode WSL presents the same interfaces and routes as Windows, so when the VPN adds a tunnel, WSL sees it too. This is a Windows-side file, %UserProfile%\.wslconfig:

# C:\Users\<you>\.wslconfig
[wsl2]
networkingMode=mirrored
dnsTunneling=true
autoProxy=true
firewall=true

networkingMode defaults to nat; mirrored requires Windows 11 version 22H2 or higher. dnsTunneling, autoProxy and firewall already default to true on current builds, but a feature update sometimes resets them, so setting them explicitly is worth the two lines. dnsTunneling is the setting that makes split-DNS VPNs resolve, because it proxies DNS through Windows rather than over a virtual NIC the tunnel ignores. Run wsl --shutdown again to apply, then re-test with the VPN connected.

Fix 3: an interface metric, if you are stuck on NAT

Mirrored mode is not always available: an older Windows 10 build, or a locked-down corporate image where you cannot change the networking mode. The NAT-mode workaround is to lower the metric of the VPN adapter so Windows shares its route with WSL cleanly. Find the adapter name with Get-NetAdapter, then, in an elevated PowerShell, set its metric to match the physical interface:

# Match the pattern to your VPN client's adapter description
Get-NetAdapter | Where-Object {$_.InterfaceDescription -match 'Cisco AnyConnect'} |
  Set-NetIPInterface -InterfaceMetric 4000

The exact number matters less than making the VPN and physical adapters consistent; the tunnel typically ships with a metric that leaves WSL routing into a dead end. This resets when the VPN reconnects, so it is a per-session patch, not a permanent one. That is precisely why mirrored mode is the better answer when your Windows build supports it.

The rule to remember

DNS resolves but names fail, pin your own resolv.conf. Nothing routes and it started with the VPN, switch to mirrored mode. Stuck on NAT, fix the adapter metric. And after every change, wsl --shutdown or you are testing the old configuration. If you are still setting WSL2 up from scratch, our note on WSL2 setup and Windows interop that actually works gets the interop and mounts right before any of this bites, and the same discipline of matching the symptom to the fix, rather than pasting the first snippet you find, is what keeps a recurring production fix from becoming a recurring production incident.

Free interactive tool

Website compliance checklist

What your site has to do, based on what it actually does

Answer as much or as little as you like — the list builds as you go. Nothing is stored against your name and no email is required.

Most technology problems are not technology problems. They are control problems.

The systems exist. The investment has been made. The question is whether leadership can understand, direct, evidence, and sustain what those systems produce. Find out where control exists — and where it only appears to.