$ sudo apt-get update
Err:1 http://archive.ubuntu.com/ubuntu focal InRelease
Temporary failure in name rerolution
$ host google.com
;; connection timed out; no servers could be reached
The /etc/resolv.conf is the main configuration file for the DNS name resolver library. It was automatically generated by WSL. Some time there was a problem with that DNS.
- To stop automatic generation of resolv.conf, add the following entry to /etc/wsl.conf:
$ sudo cat << EOF > /etc/wsl.conf
[network]
generateResolvConf = false
EOF
- In a cmd/powershell window, run:
> wsl --shutdown
or:
> wsl --terminate <Distro>
- Restart WSL
- Create a file: /etc/resolv.conf. If it exists (even a link), replace existing one with new file.
sudo cat << EOF > /etc/resolv.conf
# Use one or many DNS servers you like
# nameserver 192.168.1.1
nameserver 8.8.8.8
nameserver 1.1.1.1
EOF
- Shutdown and restart WSL again.
cmd/powershell as admin:
> wsl --shutdown
> netsh winsock reset
> netsh int ip reset all
> netsh winhttp reset proxy
> ipconfig /flushdns
Restart Windows.
- Colten Krauter: Fix DNS resolution in WSL2
- RedHat: Chapter 27. Manually configuring the /etc/resolv.conf file
- StackExchange: How do I set my DNS when resolv.conf is being overwritten?
- TechMint: How To Set Permanent DNS Nameservers in Ubuntu and Debian
- rescenic: No network connection in any distribution under WSL 2
Maybe, I'm missing something but I don't see how it can work at all. I suppose that VPN providers offer not only HTTP traffic but also DNS traffic using one of the secured DNS protocols (DOH). When I'm looking at the standard Linux DNS service config file I see parameters selecting the type of the DNS protocol per network link. VPN client works as a proxy for both DNS and HTTP traffic. Google Chrome and Microsoft Edge have such configurations too and select the protocol during DNS negotiation.
The VPN client installed on the routers serves name resolution requests from LAN insecure but delegates them to the DNS services secured or unsecured.
If VPN doesn't encode name resolution requests everybody can intercept them and resolve them to some hacker's machine IP. It is called DNS leak.
I think that everybody can look at the VPN portal to see what is written about DNS service. I found it by 1st hit for NotdVPN DNS.