WSL DNS Quick Fix Guide¶
TL;DR - Fix DNS Now¶
If DNS is broken (ping google.com fails but ping 8.8.8.8 works):
# Run the automated fix
mise run fix:wsl-dns
# Then restart WSL (from PowerShell on Windows)
wsl --shutdown
# Verify
ping google.com
Detection¶
Check if you have DNS issues:¶
# Run health check
mise run doctor
# Or manually test
ping google.com # Fails = DNS broken
ping 8.8.8.8 # Works = Network OK, DNS broken
Two Ways to Fix¶
Option 1: Automated (Recommended)¶
This script: - ✅ Detects current DNS status - ✅ Diagnoses the configuration problem - ✅ Deploys the correct /etc/wsl.conf - ✅ Provides next steps
Then restart WSL:
Option 2: Manual¶
# 1. Copy the correct config
sudo cp ~/repos/dotfiles/dot_config/wsl/wsl.conf /etc/wsl.conf
# 2. Verify it was applied
grep generateResolvConf /etc/wsl.conf
# Should show: generateResolvConf=true
# 3. Restart WSL (from PowerShell)
wsl --shutdown
# 4. Test DNS
ping google.com
Why This Happens¶
Root Cause: Configuration mismatch between WSL's DNS management and systemd-resolved.
When you have: - ✅ systemd=true (systemd enabled) - ❌ generateResolvConf=false (WSL DNS disabled)
Then: 1. systemd-resolved runs but has no upstream DNS servers 2. Network changes (VPN, sleep/wake) cause systemd-resolved to lose DNS config 3. DNS resolution fails until WSL restarts
The Fix: Set generateResolvConf=true to let WSL auto-manage DNS from Windows.
Prevention¶
This repository's dotfiles now have:
- Correct Default:
generateResolvConf=trueindot_config/wsl/wsl.conf - Health Check:
mise run doctordetects DNS issues - Quick Fix:
mise run fix:wsl-dnsautomates recovery
Verification Checklist¶
After applying the fix:
-
/etc/wsl.confhasgenerateResolvConf=true - Restarted WSL with
wsl --shutdown -
ping google.comworks -
cat /etc/resolv.confshows Windows DNS servers (not127.0.0.53) -
mise run doctorpasses DNS checks
Related Issues¶
"DNS works after reboot but fails later"¶
→ This is the exact symptom. Run mise run fix:wsl-dns
"VPN breaks DNS in WSL"¶
→ Fixed by letting WSL manage DNS (generateResolvConf=true)
"systemd-resolved shows 'Current Scopes: none'"¶
→ Means systemd-resolved has no DNS servers. Run the fix.
Advanced: Understanding the Fix¶
Before (Broken)¶
Result: - systemd-resolved runs but has no upstream DNS - /etc/resolv.conf → 127.0.0.53 (systemd stub) - systemd-resolved has nowhere to forward queries - DNS fails
After (Fixed)¶
# /etc/wsl.conf
[boot]
systemd=true
[network]
generateResolvConf=true # ✅ WSL manages DNS from Windows
Result: - WSL auto-generates /etc/resolv.conf from Windows DNS - Syncs automatically with network changes - DNS always works
Troubleshooting¶
If the fix doesn't work:
-
Check Windows DNS:
-
Verify WSL is using mirrored networking:
-
Check for VPN interference:
- Some VPNs block WSL DNS tunneling
- Try disconnecting VPN temporarily
-
Or add
dnsTunneling=trueto.wslconfig -
Full diagnosis:
See Also¶
- Full WSL Guide - Complete WSL setup and troubleshooting
- DNS Fix Summary - Technical deep dive
- Architecture - How dotfiles work