If you're encountering ping github.com failing inside WSL with a Temporary failure in name resolution, you're not alone β this has been a long-standing issue, especially when using VPNs or corporate networks.
This issue is now fixed robustly with DNS tunneling, which preserves dynamic DNS behavior and avoids limitations like WSLβs former hard cap of 3 DNS servers in /etc/resolv.conf.
DNS tunneling is enabled by default in WSL version 2.2.1 and later, meaning that if you're still seeing DNS resolution issues, the first and most effective fix is simply to upgrade WSL. Upgrading WSL updates the WSL platform itself, but does not affect your installed Linux distributions, apps, or files.
To upgrade WSL, follow these steps,
# Run all of the following in a Windows terminal (PowerShell, Command Prompt, etc.)
# 1. Check your current WSL version
wsl --version
# 2. Close all open *WSL windows* β any Linux terminals running via WSL (Ubuntu, Debian, etc.)
# 3. Shut down the WSL subsystem
wsl --shutdown
# 4. Upgrade WSL
wsl --upgrade
# 5. Verify the upgrade was successful (version should now be >= 2.2.1)
wsl --version
# 6. Open your WSL terminal and test
ping github.com
# π If it works, drop a comment on this Gist and tell us how happy you are.If needed, explicitly enable tunneling by creating (source):
# C:\Users\<YourUsername>\.wslconfig
[wsl2]
dnsTunneling=trueThatβs it. No more messing with /etc/resolv.conf. No more weird hacks!
Preserved for historical transparency and for users unable to upgrade WSL.
# In WSL
cd /etc
echo "[network]" | sudo tee wsl.conf
echo "generateResolvConf = false" | sudo tee -a wsl.conf
# Back in Windows
wsl --terminate <DistroName> # or use wsl --shutdown
# Back in WSL
sudo rm -f /etc/resolv.conf
echo "nameserver 1.1.1.1" | sudo tee /etc/resolv.conf
echo "nameserver 8.8.8.8" | sudo tee -a /etc/resolv.conf
sudo chattr +i /etc/resolv.confIf you're using a VPN like Cisco AnyConnect:
Get-NetAdapter | Where-Object { $_.InterfaceDescription -Match "Cisco AnyConnect" } | Set-NetIPInterface -InterfaceMetric 6000Big thanks to,
- @ThePlenkov/(comment) β the first to publicly document the DNS tunneling fix in
.wslconfig(WSL 2.2.1+) - @skudbucket β for confirming and spreading awareness
- @MartinCaccia, @yukosgiti, @machuu, @AlbesK β for documenting earlier workarounds
- GitHub Issue #4277
- GitHub Issue #4246
- Legacy fix from #4285
- WSL DNS Tunneling Docs
- WSL Config Docs
- WSL 2.2.1 Release Notes
If you're still using manual resolv.conf hacks in 2024+, you're solving a problem that's already been solved.
Hi everyone,
I have used v2rayN and that worked
Test code:
$ git ls-remote https://github.com/nvm-sh/nvm.git | head
Result:
a6ec73943099a86fba98bde3b04a1c60944a4549 HEAD
df9ac58f8b73f7cdddad67396f1992acb0706b02 refs/heads/awk
edb47ffdea6567480fa93c4f196597489818a44d refs/heads/bionic
663c9968cbdad59b7b3d1dc38bec1db9535a02f0 refs/heads/block_iojs
d2f31a21f37e3c0ebf5365ac635af2e2e070fbe0 refs/heads/colors
4f91e99415484257b4678090c052f307d157e24e refs/heads/fix-3474
26066c10f42afdef9085a30f522b4e73cc2a4e59 refs/heads/fix-nvmrc-comment-hash
a6ec73943099a86fba98bde3b04a1c60944a4549 refs/heads/master
da5baa005b9f59f8f9f86002c85a2053f09494ba refs/heads/npm8
4a7275a0c60a5633b3924577ba5d048febd008b2 refs/heads/nvmrc
WSL Config:
Networking mode: NAT
DNS Tunneling enabled: checked
v2rayN config: Enable Tun: checked
or
Networking mode: Mirrored
DNS Tunneling enabled: not important
v2rayN config: Enable Tun: not important
v2rayN config:
System proxy: Set system proxy
Config:
vmess://ew0KICAidiI6ICIyIiwNCiAgInBzIjogIkBTT05JQ18yNTI0INqp2KfZhtin2YQg2LHZiNio24zaqdinINmIINiq2YTar9ix2KfZhSBcdUQ4M0RcdURENEHirZDvuI8iLA0KICAiYWRkIjogIjEwNC4xOC4xOS45OSIsDQogICJwb3J0IjogIjQ0MyIsDQogICJpZCI6ICJiNGE2NTYxMS00OTY5LTQyYjItYmM3NC01NzY4Yjk0MGJkOWUiLA0KICAiYWlkIjogIjAiLA0KICAic2N5IjogImF1dG8iLA0KICAibmV0IjogIndzIiwNCiAgInR5cGUiOiAiLS0tIiwNCiAgImhvc3QiOiAidnl2enloZ3ouY29tIiwNCiAgInBhdGgiOiAiLyIsDQogICJ0bHMiOiAidGxzIiwNCiAgInNuaSI6ICJ2eXZ6eWhnei5jb20iLA0KICAiYWxwbiI6ICIiLA0KICAiZnAiOiAiIg0KfQ==
OS Name: Microsoft Windows 11 Enterprise
OS Version: 10.0.26200 N/A Build 26200
WSL version: 2.7.8.0
Kernel version: 6.18.33.1-1
Windows version: 10.0.26200.8655
Virtualization: wsl
Operating System: Ubuntu 26.04 LTS
Kernel: Linux 6.18.33.1-microsoft-standard-WSL2
Architecture: x86-64