fix_wsl2_networking

Permanently fix DNS connectivity issues in WSL2

Installation // bash script
fix_wsl2_networking.sh
1 — Or download from PowerShell
PS> Invoke-WebRequest -Uri "https://github.com/franckferman/fix_wsl2_networking/releases/latest/download/fix_wsl2_networking.sh" -OutFile "$env:USERPROFILE\fix_wsl2_networking.sh"
2 — Copy into WSL2 and run
$ cp /mnt/c/Users/<YourWindowsUsername>/fix_wsl2_networking.sh ~/
$ chmod +x ~/fix_wsl2_networking.sh
$ sudo ~/fix_wsl2_networking.sh
Replace <YourWindowsUsername> with your actual Windows username. The Windows filesystem is accessible from WSL2 under /mnt/c/.
How it works
/etc/wsl.conf Sets generateResolvConf=false to stop WSL2 from overwriting DNS on restart
/etc/resolv.conf Replaces with static nameservers of your choice, marked immutable via chattr +i
Backup Existing files backed up with timestamp before any modification
Revert Run with --undo to remove immutable flags and restore automatic DNS
Supported DNS providers
ProviderPrimarySecondary
Cloudflare1.1.1.11.0.0.1
Google8.8.8.88.8.4.4
Quad99.9.9.9149.112.112.112
Mullvad194.242.2.9194.242.2.2
OpenDNS208.67.222.222208.67.220.220
Comodo8.26.56.268.20.247.20
DNSWatch84.200.69.8084.200.70.40
Digitalcourage85.214.20.14146.182.19.48
FDN80.67.169.1280.67.169.40