Here is how you setup an alternative DNS server (like. Google DNS) on WSL2 and persist it between WSL restart:
- Create the WSL config file (if it does not already exist):
/etc/wsl.conf
- Enter the following lines to preserve the DNS config between restarts:
[network]
generateResolvConf = false
- Shutdown WSL and start again by running the following command in Windows terminal:
wsl --shutdown
- Edit (or, create) the file
/etc/resolv.conf
:- Comment any other line that starts with “nameserver”.
- Enter the following lines:
nameserver 8.8.4.4
nameserver 8.8.8.8
- Restart WSL again after running the following command in Windows terminal:
wsl --shutdown
Top comments (0)