WSL2 - No internet connectivity. DNS Issues(Temporary failure in name resolution)
Environment
Windows build number: Version 10.0.18363.1256
Your Distribution version: Both Ubuntu 18.04 and Ubuntu 20.04
Whether the issue is on WSL 2 and/or WSL 1: WSL 2
Steps to reproduce
Install WSL2 with any Ubuntu distro(1804/2004) .Ping google.com or any other website. Tried on with/without VPN(Big Edge IP client).
WSL logs: ping google.com Temporary failure in name resolution
For sudo apt update
Err:1 http://archive.ubuntu.com/ubuntu bionic InRelease Temporary failure resolving 'archive.ubuntu.com' Err:2 http://security.ubuntu.com/ubuntu bionic-security InRelease Temporary failure resolving 'security.ubuntu.com' Err:3 http://archive.ubuntu.com/ubuntu bionic-updates InRelease Temporary failure resolving 'archive.ubuntu.com' Err:4 http://archive.ubuntu.com/ubuntu bionic-backports InRelease Temporary failure resolving 'archive.ubuntu.com' Reading package lists... Done Building dependency tree Reading state information... Done All packages are up to date. W: Failed to fetch http://archive.ubuntu.com/ubuntu/dists/bionic/InRelease Temporary failure resolving 'archive.ubuntu.com' W: Failed to fetch http://archive.ubuntu.com/ubuntu/dists/bionic-updates/InRelease Temporary failure resolving 'archive.ubuntu.com' W: Failed to fetch http://archive.ubuntu.com/ubuntu/dists/bionic-backports/InRelease Temporary failure resolving 'archive.ubuntu.com' W: Failed to fetch http://security.ubuntu.com/ubuntu/dists/bionic-security/InRelease Temporary failure resolving 'security.ubuntu.com' W: Some index files failed to download. They have been ignored, or old ones used instead.
Expected behavior
I should get reply to the ping. And Internet should be easily accessible from within WSL.
WSL 1 has no problem. I am able to connect to internet. When I try to use docker on WSL , it asks to upgrade to WSL2. So now i have no option. Just have to use WSL2 for docker where there is no internet connectivity
Actual behavior

Have looked at the solutions from other issues. None seems to works. Follows some that I have tried but it seems not to work.
-
Added ([network]generateResolvConf = false) to wsl.conf And add nameserver 8.8.8.8 in resolv.conf
-
Run the following powershell script
`echo "Restarting WSL Service"
Restart-Service LxssManager
echo "Restarting Host Network Service"
Stop-Service -name "hns"
Start-Service -name "hns"
echo "Restarting Hyper-V adapters"
Get-NetAdapter -IncludeHidden | Where-Object `
{$_.InterfaceD```
escription.StartsWith('Hyper-V Virtual Switch Extension Adapter')} `
| Disable-NetAdapter -Confirm:$False
Get-NetAdapter -IncludeHidden | Where-Object `
{$_.InterfaceDescription.StartsWith('Hyper-V Virtual Switch Extension Adapter')} `
| Enable-NetAdapter -Confirm:$False`
Please let me know how can i fix this issue, so i can connect to internet from my WSL
FYI Antivirus - McAffe and Windows Defender is enabled.
Elementary Watson! All WSL distro are derived from the corresponding Cloud VM distros. These distros are systemd based Linux distros. The Network Manager is responsible for network configuration and every infrastructure provides the hook that configures the resolv.conf: cat /etc/NetworkManager/dispatcher.d/hook-network-manager #!/bin/sh
This file is part of cloud-init. See LICENSE file for license information.
This script hooks into NetworkManager(8) via its scripts
arguments are 'interface-name' and 'action'
is_azure() { local dmi_path="/sys/class/dmi/id/board_vendor" vendor="" if [ -e "$dmi_path" ] && read vendor < "$dmi_path"; then [ "$vendor" = "Microsoft Corporation" ] && return 0 fi return 1 }
is_enabled() { # only execute hooks if cloud-init is enabled and on azure [ -e /run/cloud-init/enabled ] || return 1 is_azure }
if is_enabled; then case "$1:$2" in *:up) exec cloud-init dhclient-hook up "$1";; *:down) exec cloud-init dhclient-hook down "$1";; esac fi
All this mechanism heavily relies on systemd-resolved daemon.
Without this initialization process /etc/resolv.conf is only a symbolic link pointing to /run/systemd/resolve/stub-resolv.conf created during distro installation:
No DNS servers known.
This file was automatically generated by WSL. To stop automatic generation of this file, add the following entry to /etc/wsl.conf:
[network]
generateResolvConf = false
nameserver 172.20.160.1
With generateResolvConf = false your nameserver is always 172.20.160.1 With generateResolvConf = true your nameserver can't be correctly detected without systemd-resolved daemon. You can either add GoogleDNS 88.8.8 as a nameserver in the 1st position or if you use "smart" WiFi router or team router with built-in DNS and DNS forwarding feature IP address of your router, 192.168.1.1 for example.
With generateResolvConf = false your nameserver is always 172.20.160.1
With generateResolvConf = true your nameserver can't be correctly detected without systemd-resolved daemon.
You can either add GoogleDNS 88.8.8 as a nameserver in the 1st position
or if you use "smart" WiFi router or team router with built-in DNS and DNS forwarding feature IP address of your router, 192.168.1.1 for example.
I have tried all this but no luck. I still see the same issue
Every time when WSL terminal is opened WSL generates the resolv.conf regardless of how it is configured in wsl.conf. The wsl.conf is only the link to the "real" resolv.conf file generated normally bi the systemd-resolved daemon. This is documented for such Linux distro as Ubuntu. Suse, CentOS, Debian. See for example systemd-resolved Suse and systemd-resolved Debian. What does it mean "# Enable DNS – even though these are turned on by default, we'll specify here just to be explicit. [network] generateResolvConf = false" in wsl.conf if in WSL2 VM this is not a file but a symbolic link pointing to the file generated by the dedicated daemon? Is it a rudiment of WSL 1? Why WSL 2 tries to generate the resolv.conf file if it can't do it correctly due to lack of "official" systemd? I run WSL2 Ubuntu distro with genie and use systemd. But WSL revenges me and destroys Linux networking.
After the last update of windows few days ago (Insider Preview build 21292.1010 ) I got the dns issue inside wsl.
a long time ago (more than 1 year ago), for the same kind of issue, I had to update the content of /etc/wsl.conf with the following.
[network]
generateResolvConf = false
I Just tried to put it at true, and it fixed the issue.
But not sure it's really something we want, to have a resolv.conf generated.
Also got this issue from the recent 1010 update.
I run Windows 10 Pro Insider preview build 212921010 I am afraid that resolv.conf generation for WSL is too much simplified to work in the complex networking environment. I looked into the Linux log what Linux resolve daemon does in Linux: it checks Network interface statuses and route ability before pushing something into the file on which /etc/resolv link points. It is not helpful to use DNS that is not reachable itself. DNS itself must be functional. It allows multiple nameservers via multiple interfaces. etc. It doesn't assume that the computer is attached to the Internet Laptop can be connected to the different WiFi networks managed by different providers. Also, preferable DNS is different. Every time when Driver emits a status event daemon has to manipulate with DNS list. In my default distro Ubuntu 20.10 I use the "static" DNS address 192.168.1.1 because if I can't reach my router I can't reach DNS and any other site. Inside my router, I have both Dynamic DNS and DNS forwarding enabled. It helps because the router has its own IPV6 DHCP WAN address gotten from ISP My preferable DNS is ping dns9.quad9.net PING dns9.quad9.net (9.9.9.9) 56(84) bytes of data. 64 bytes from dns9.quad9.net (9.9.9.9): icmp_seq=1 ttl=54 time=20.5 ms 64 bytes from dns9.quad9.net (9.9.9.9): icmp_seq=2 ttl=54 time=13.1 ms and not my ISP or Google: ping dns.google PING dns.google (8.8.8.8) 56(84) bytes of data. 64 bytes from dns.google (8.8.8.8): icmp_seq=1 ttl=113 time=72.3 ms and not DNS got from my ISP ping 172.28.80.1 PING 172.28.80.1 (172.28.80.1) 56(84) bytes of data. --- 172.28.80.1 ping statistics --- 14 packets transmitted, 0 received, 100% packet loss, time 13558ms It works stably because I trust in the Router's OpenWRT DNS logic and bypass all suspicious or unstable DNS addresses.
After the last update of windows few days ago (Insider Preview build 21292.1010 ) I got the dns issue inside wsl.
a long time ago (more than 1 year ago), for the same kind of issue, I had to update the content of
/etc/wsl.confwith the following.[network] generateResolvConf = falseI Just tried to put it at
true, and it fixed the issue. But not sure it's really something we want, to have aresolv.confgenerated.
I didn't see this reply. I did this and it also fixed my recent issue.
Resolv.conf generation in the current implementation is a useless and harmful feature in the most cases. Even Chrome knows to test DNS availability 1st according to "DNS PROBE ERROR" appears in the case of connectivity issues. Google shows a long list of The "best DNS determination" tools. The correct DNS selection depends on the status of network interfaces and how the host is connected to the global internet infrastructure. Also, DNS protocol can vary from UDP to DOH The best choice is always the DNS that is connected to the LAN itself. IT is 99.9% available and can be easily rebooted. Its status can be easily tested using nslookup 8.8.8.8 - must return name = dns.google .
Thanks for reporting the issue @devshashankb .
Can you please follow these instructions and share the script output, and both wsl.etl and packets.etl ?
I have this issue happened recently too .
Edit /etc/wsl.conf with
[network]
generateResolvConf = false
and change /etc/resolve.conf doesn't solve my problem .
ifconfig show nothing.
"Temporary failure in name resolution" looks like a message coming from DNS client or server. If ifconfig -a, ip -a in Ubuntu shows nothing then the networking doesn't work at all and configured in resolv.conf DNS is not reachable. But if you can look at ls a- /etc/resolv.conf - and cat /etc/resolv.conf output and check that the /etc/resolv.conf is a link and you can ping the 1st nameserver in the resolv.conf you can save your time. The DNS must be accessible via VM's eth0 interface and be usable. To test the DNS you can try nsllookup your-site-url your-configured-DNS from the Windows command line. P.S. There is no reason to trust in your ISP DNS. There are many alternative DynDNS providers with better maintenance, performance, and security starting from 8.8..8.8.
@devshashankb I am afraid you are 100% correct and WSL team is 100% not :(. In the recent and most useful Linux distros DNS resolution is so tightly coupled with systemd mechanism, resolved service, and dbus service that any alternative solution is not possible. The provided by Debian, Ubuntu, and Fedora distro lines services are perfectly tuned to the modern networking and cloud computing environment. The old Windows-like solution has stopped working without mitigation using Router configuration that enables DynDNS and other than UDP protocols usage. I start my most useful distros Ubuntu 20.10 and Fedora 33 with systemd support and have In Ubuntu: $ systemd-resolve 9.9.9.9 9.9.9.9: dns9.quad9.net In Fedora - similar systemd-resolve 9.9.9.9 9.9.9.9: dns9.quad9.net -- link: eth0
-- Information acquired via protocol DNS in 12.8ms. -- Data is authenticated: no
But my /etc/resolv.conf link is overridden every wsl "login". I have to re-create it manually every time. Otherwise, these systemd based Linux distros can't access the internet, i.e cloud services, repositories,etc. deployed globally Every attempt to resolve DNS names using "old static DNS servers" results in a "temporary" DNS resolution error, as expected.
Hey, I succeeded to run systemd-resolved service manually and it found 3 critical issues:
- Not all protocols used in DNS resolution are passed from WSL VM to the probed DNS server. But this is OK. resolved knows how to recover.
- Generated /etc/hosts file contained invalid character in the line 7 - it affects local routers communication for the address starting from 192.
- /etc/resolv.conf is re-created every distro start. Since /etc/resolv.conf "created manually" has the highest priority I have to remove it every time. Everything else works OK and provides optimized DNS resolution.
After a few weeks of experience with the real-world Linux distro used as a WSL image that managed by systemd, I found that if the original distro was systemd-based then all games with /etc/resolv.conf affect nothing. Every program built with the networking libraries for these distro establishes IPC connection with systemd-resolve using D-Bus and the DNS resolver daemon solves for the "client" program all issues related to DNS using its own configuration: interface to communicate with DNS, protocol, possible delegation to the globally deployed dDNS service, etc. Everything works because the modern Internet infrastructure is virtually unbreakable. When I run OCI containers in my distro the running container gets the correct resolv.conf content as magic.
I didn't even know we could run other distrib than the one given by the store. I will try it. a bit out of the subject, @PavelSosin-320 did you find some pro and con (apart of the network ) to use a real-world Linux distro
All WSL distros published in the Microsoft store are plain so-called initrd distros, i.e. distros with read-only compressed into single file root fs that is used for 1st-time boot. There is nothing new in it. I think all Linux distro can be started from USB, CD, or Network. To install any Linux distro you need either some rootfs ext4 file of the corresponding distro or tar file of some existing distro exported by another developer to be imported and registered as in Export and import WSL distro https://docs.microsoft.com/en-us/windows/wsl/reference Both things are no so rare asset - use google or Linux community sites. If you use the 1st method you have to open regedit and copy/paste/edit the set of entries like for already existing distro. under Computer\HKEY_CURRENT_USER\Software\Microsoft\Windows\CurrentVersion\Lxss . If you use the 2nd method you can simply use wsl --import to create distro FS in the desired location with the desired name from the tar file. Pros:
- Both methods work unlike installation from Microsoft store that results in died distro fo 20$.
- You have more freedom in the Distro name and rootfs location.
- You have the real support from the Software house maintaining the distro instead of opening issues for WSL and waiting 6 months until somebody will read it. 4 You can upgrade your distro from the original distro repositories whenever you want without saying "Sorry, I need to upgrade and change the initialization method of my distro to systemd. Why I have the same issues as in the original distro from MS Store and nobody care to correct the image in the MS Store.
Is there a chance that you are getting the DNS resolution error, while on a VPN?
Because this is exactly the same problem I am having for some months now and because I dont have admin rights on my working maschine I am not able to make it work.
It have been 4-5 months now without using my WSL2 on a VPN.
Some reaction from Microsoft? WSL ignores [network] generateResolvConf = false and generates resolv.conf containing wrong nameserver IP address. The generated IP is that the ISP provides via Network bridge ( modem or combo ). If the local network is managed by a router the correct primary nameserver must be the IP of the Router's nameserver that configured in the router, VPN-provided DNS or Corporate DNS depends on Networking scenario in the LAN .In many cases, this DNS is the least stable of all available. My luck is that I run WSL distros with systemd and resolve daemon and in this scenario /etc/resolv.conf is only a link to the generated by resolve daemon stub. In systemd-based Linux distros /etc/resolv.conf is not the primary nameserver source. The nameserver value in the WSL generated resolv.conf is silently ignored and everything works like swiss watch.
@PavelSosin-320
You have to change sudo nano /etc/wsl.conf.
[network]
generateResolvConf = false
After that go to sudo nano /etc/resolv.conf delete everything there and put your desired nameservers there:
nameserver 1.1.1.1
After that in Powershell type wsl --shutdown.
Now your resolv.conf will be the same.
@K2ouMais
I did exactly that. Although WSL2 won't generate /etc/resolv.conf anymore, WSL2 deletes the file every time when I restart it (so no nameserver at all). Do you happen to know what is happening? Thanks in advance.
Edition Windows 10 Home Insider Preview Version Dev OS build 21322.1000