DEV Community

Kumar Abhishek
Kumar Abhishek

Posted on • Originally published at abhi.page on

Set & persist Google DNS server in WSL2 | Notes

Here is how you setup an alternative DNS server (like. Google DNS) on WSL2 and persist it between WSL restart:

  1. Create the WSL config file (if it does not already exist): /etc/wsl.conf
  2. Enter the following lines to preserve the DNS config between restarts:
[network]
generateResolvConf = false

Enter fullscreen mode Exit fullscreen mode
  1. Shutdown WSL and start again by running the following command in Windows terminal: wsl --shutdown
  2. Edit (or, create) the file /etc/resolv.conf:
    1. Comment any other line that starts with “nameserver”.
    2. Enter the following lines:
nameserver 8.8.4.4
nameserver 8.8.8.8

Enter fullscreen mode Exit fullscreen mode
  1. Restart WSL again after running the following command in Windows terminal: wsl --shutdown

Read on abhi.page

Top comments (0)