WSL: 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.
About this issue
- Original URL
- State: open
- Created 6 years ago
- Reactions: 38
- Comments: 135 (2 by maintainers)
It seems lounching VSCode daemon messes things up
Setup below helped me, thanks guys:
I’m working with WSL2 and Ubuntu 20.04LTS
Ok try this solution (it works for me) :
Create
/etc/wsl.confas explained before with that :1 . Rename link
/etc/resolv.conf:> sudo mv /etc/resolv.conf /etc/resolv.conf.old2 . Create and edit new resolv.conf file (not a link) :
> sudo vi /etc/resolv.confand just add this line (indicate your livebox gateway address / (orange for me)) :
nameserver 192.168.1.13 . Don’t forget to change authorization :
> sudo chmod 777 /etc/resolv.confYou should see that :

4 . close console and reopen it. just type :
exit5 . Try to update linux (
sudo apt update) to check network connection and … it works well (not before procedure).I hope enjoy for you too !
Edition Windows 10 Professional 20H2 Insider - Canal release preview OS build 19042.844
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.I 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.@PavelSosin-320
You have to change
sudo nano /etc/wsl.conf.After that go to
sudo nano /etc/resolv.confdelete everything there and put your desired nameservers there:After that in Powershell type
wsl --shutdown.Now your resolv.conf will be the same.
For me was everything solved by
C:\Users\%USERPROFILE%or simply open file explorer (WIN + E) and type%USERPROFILE%..wslconfigfile without any extension with VSCode, Sublime, Notepad++, or some other editor.wsl --shutdown.This might not help everyone but it helped me 😊
I tried this unforunately it doesn’t work for me
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.
I just recently updated to Windows 11 beta and setting
generateResolvConf = trueworked for me.This is the only thing that fixed the issue for me:
https://github.com/microsoft/WSL/issues/5420#issuecomment-944909858
Added
to my .wslconfig and DNS is now working. My dns config is custom nameserver and search options in /etc/resolv.conf
@174n Same here. Received a windows update today and DNS resolution stopped working. Nice job.
I didn’t see this reply. I did this and it also fixed my recent issue.
This worked for me
Source: https://askubuntu.com/a/1398053
After Win 11 update WSL2 Ubuntu 20.04 LTS resolver didn’t work anymore. But now it works again with next fixes, using previous hints.
And then on the command prompt:
After open new Wsl Shell , there is /etc/resolv.conf and more important: dns works. How about tomorrow? We’ll see.
But the main question is: why did update from Win 10 To Win 11 generate this WWP?
I’ve documented steps that have worked for me, give these a try.
https://gist.github.com/mandeepsmagh/f1d062fc59e4e6115385c2609b5f0448
Hi folks, we have put out a new update that aims to address networking issues in WSL. In your
.wslconfigfile you can setexperimental.networkingMode=mirrored, as well as some other key settings that should improve your network compatibility! Please try them out and let us know what you think.More info on this release and the changes can be found here in the blog post.
Please note: You need to be on a Windows Insiders version to use the new networking settings (Any channel of Windows Insiders will do, including release preview). If you see the “These are not supported” messages it means that your current Windows version doesn’t have support, and you will need to upgrade. These features will eventually be coming to Windows 11 22H2.
My Avast Antivirus Firewall blocking DNS resolutions from WSL2. 🤦🏻♂️
Added rule for allow.
After
wsl --shutdownnow it’s working. 👍This got it to work for me.
wsl2 dns starts to feel like russian roulette. i’m not behind any vpn. just a super basic WSL2 + ubuntu LTS. after being completely broken pre 20H, i’m now on 20H2 (19042.928) and its broken again. no matter what workaround i try. 😫
my hate for my macbook slowly moves to my surface laptop, every single time I lose a day at work because of these wsl2 issues… i cant believe we still struggle with this after months.
This issue was happening to me since yesterday, after I updated my Windows 11 to the latest version, 22H2.
So what worked for me, this is firstly needed:
Afterwards this is required as well, because of the system/wsl restarts/upgrades, etc:
These steps helped me (the answer by Gamepad.Coder on this question ):
Network Reset, hit enter.You should see this window. Click “Reset now”.
following worked for me:
updating only /etc/resolv.conf to nameserver 8.8.8.8 didn’t work for me. i had to create and update file /run/resolvconf/resolv.conf as well.
-cheers
We were running into this DNS issue with Cisco AnyConnect only while on VPN like some people on this issue mentioned. Solution was really simple: open ‘Advanced Window’ on Cisco AnyConnect Secure Mobile Client and click
"Allow local (LAN) access when VPN (if configured)". Restart VPN and DNS starts working again.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.
We suffer from the same issue.
WSL2 looses network connectivity on certain cases like:
What we found out is that in case where the connectivity is lost, there are additional routes in the routing table in Windows attached to the VPN Adapter with the destination of the WSL Adapter (or more, the IP-Range of the WSL Adapter). If we remove this routes, the connectivity comes back immediately.
Here is a script that lists all relevant routes regarding WSL (adjust the
<your adapter identifer>for your VPN adapter). For us, when there are any routes in the sectionRoutes for the VPN Adapter, WSL is offline. And if we delete all these routes, WSL2 gets connectivity back immediately.McAfee firewall disrupts DNS resolution on WSLv2 on Windows10-Pro (+ workaround)
Ladies and Gents,
Try this as a possible workaround solution if you use McAfee Endpoint Security !
I have had the same problem. The resolv.conf config did work on one laptop but not on another identical laptop. (only difference was : working one uses windows-Home, NOT working one runs Windows-Pro.
I did a downgrade to WSLv1 and it worked again. Upgraded back to WSLv2 and no DNS again.
I found out that the problem is caused (in MY case) by the “McAfee Endpoint Security” FIREWALL. As a quick test, DISABLE the firewall and shutdown and restart the WSL. In my case DNS worked again and I could ping outside webservers.
Further investigation proved that “enabling” the “adaptive” firewall setting (found in the advanced settings) makes all the difference. I now have a working laptop on WSLv2.
Googling on MCAFEE and WSL and DNS, I found out that McAfee does not support WSL at this time : See here: https://kc.mcafee.com/corporate/index?page=content&id=KB91411 and here https://kc.mcafee.com/corporate/index?page=content&id=KB82450
Hopefully, my fix will also work for others following this thread… Good Luck Luc DM
Please, don’t propose workarounds before testing them on animals for avert effects. The name resolution is a very sensitive security issue because DNS providers or man-in-the-middle can collect the Internet access history of any user without accessing cookies, etc. It can be used against users or monetized. This problem has been solved by most OS providers including Microsoft and DNS service providers in the years 2020-2021 via switching to TLS-based DNS protocols. What is written about it: Windows DoT support . Linux and Android went far forward - systemd-resolved does DNS negotiation by default. Who succeeded to activate DNS support in WSL 2 for 5 minutes can install Dig Linux utility to see how the client asks name resolution and how it receives response. Who chooses “Automatic resolv.conf generation” in the wsl.conf does it on own risk.
This worked for me, except I think the more accurate way to do it is to point it to the IP address of your WSL network adapter. That way it’ll use whatever DNS your host PC is using. I switched to that after using the above solution, and all is good.
@PavelSosin-320 I don’t want to say that WSL is bad, but it has some connectivity problems for some months now.
Personally I can’t use WSL2 on the company VPN, but I am seeing people having the exact same problem on their local network.
I tried every possible workaround found here all over the issues without success.
Yes, I also tried changing the resolv.conf and so on, but it doesn’t work for me.
Bad is, WSL2 is my choice when developing and right now there are some ugly ways to fix this problem.
Reverting to WSL1 is a way to fix the connectivity problems. But I loose a way to use docker.
The other solution is using docker’s vpn-kit, but that relys in having a terminal window open all the time, running an app.
I even tried other obscure fixes and they also don’t work at all.
WSL2 is amazing and I don’t want to miss it, but Microsoft seems to not care about these problems at all.
@K2ouMais
I did exactly that. Although WSL2 won’t generate
/etc/resolv.confanymore, 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
Hey, I succeeded to run systemd-resolved service manually and it found 3 critical issues:
@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.
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.
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.
I can confirm. This worked for me as well.
I tried the new mirrored networking mode, but Docker Desktop crashed after its first reboot, though everything else seemed to work properly.
After that, I performed the factory reset encouraged by Docker Desktop and it worked fine until the next engine restart or system reboot instead. Then, the engine startup crashed once again, and so on. Furthermore, the Kubernetes feature did not even initialise for the first time, no matter how many restarts, factory resets or reboots I performed.
Once
.wslconfigbecame saved with the networking mode reverted to NAT, things went back to normal with no restart, factory reset, or reboot at all.Bearing in mind everything seemed to work flawlessly and blazing fast, but Docker Desktop, I’m not really sure whether this was a compatibility issue on the WSL side or on the Docker side instead.
@craigloewen-msft, I’ll be glad to provide any log you esteem necessary to ease the addressing of this issue if it is on the WSL side indeed, though I guess this could be somehow related to both #10494 and Docker#13686
Edit: Everything working flawlessly and blazing fast with Docker Desktop >=4.26.0, which added support for the new mirrored mode! 🥳🚀
These new networking features are now available on the latest version of Win11 22H2!
Please make sure you’re on the latest build to get these features, you can do that by clicking “Check for Updates” in Windows settings. You can check you have the right build by either ensuring you have KB5031354 installed, or run
cmd.exe /c verand ensure that your build number is 22621.2428 or higher (Including the minor build number which is after the.as this was a backport!)This worked for me no problem!
In my case, I’ve disabled Internet Protocol Version 6 (TCP/IPv6) in WLAN Properties of Network Connections Settings.
Configuration Screenshot:
Ping GitHub.com Successfully Screenshot:
Source: https://unix.stackexchange.com/a/628767/338681
Tried this, but
/etc/resolv.confis removed afterwsl --shutdown.sudo ls /etc/resolv.conf ls: cannot access '/etc/resolv.conf': No such file or directoryI’ve been following this issue for what seems like years, and it is very much a moving target as various companies update their products. However, I’ve found some more clues at what might be going on.
First and foremost:
I found a potential hint for this particular issue here: https://superuser.com/questions/1715764/wsl2-has-no-connectivity-when-windows-is-connected-to-vpn
When I run “route print” in powershell, I see the following:
After firing up my VPN, a LOT of new ip routes are added, but this is the only duplicate:
This fits other observations: The VPN is adding a split tunnel route on top of the WSL subnet, and as a result all WSL traffic is talking to the VPN. And because the VPN has no clue how to route that or what to do with it, the messages die. In fact, I can’t even ping the gateway or the interface of the VPN connection.
So with this particular problem, I’m not even getting to the point of the system using the wrong nameservers, like I was a couple years back.
I suspect that this relates to issues with updating either Windows or the Cisco AnyConnect product. These updates may break a link somewhere in the system, requiring a reinstall. However, I do not want to go through the hassle of reinstalling WSL every time a Windows Update is pushed by our corporate Endpoint Support.
Hopefully this provides some clues that others can use to troubleshoot this. I know I’ve seen workarounds that involve changing the metrics, but I am not sure how to target that to just this one route.
Edit: I did find a gist that had a workaround for the AnyConnect specific issues, that also broke down the problem pretty well. However, it does not reference this particular issue. https://gist.github.com/machuu/7663aa653828d81efbc2aaad6e3b1431
Also, linking this post to some coworkers had them find that Cisco did release an update for 4.10 that fixes the issue, BUT it needs to be configured by the firewall admins.
https://www.cisco.com/c/en/us/td/docs/security/vpn_client/anyconnect/anyconnect410/release/notes/release-notes-anyconnect-4-10.html
https://www.cisco.com/c/en/us/td/docs/security/vpn_client/anyconnect/anyconnect410/administration/guide/b-anyconnect-admin-guide-4-10/troubleshoot-anyconnect.html#Cisco_Task_in_List_GUI.dita_3a9a8101-f034-4e9b-b24a-486ee47b5e9f
Disable/enable the hidden WSL interfaces in Windows 11 seems to fix the name resolution for me in WSL OS (Ubuntu 20.04). Try to run these commands in admin PowerShell:
Get-NetAdapter -IncludeHidden | Where-Object {$_.InterfaceDescription.StartsWith('Hyper-V Virtual Ethernet Adapter')} | Disable-NetAdapter -Confirm:$FalseGet-NetAdapter -IncludeHidden | Where-Object {$_.InterfaceDescription.StartsWith('Hyper-V Virtual Switch Extension')} | Disable-NetAdapter -Confirm:$FalseGet-NetAdapter -IncludeHidden | Where-Object {$_.InterfaceDescription.StartsWith('Hyper-V Virtual Switch Extension')} | Enable-NetAdapter -Confirm:$FalseGet-NetAdapter -IncludeHidden | Where-Object {$_.InterfaceDescription.StartsWith('Hyper-V Virtual Ethernet Adapter')} | Enable-NetAdapter -Confirm:$FalseOr, the simplified version, if you don’t have any other Hyper-V related interfaces in the Windows host:
Get-NetAdapter -IncludeHidden | Where-Object {$_.InterfaceDescription.StartsWith('Hyper-V Virtual ')} | Disable-NetAdapter -Confirm:$FalseGet-NetAdapter -IncludeHidden | Where-Object {$_.InterfaceDescription.StartsWith('Hyper-V Virtual ')} | Enable-NetAdapter -Confirm:$FalseI tried every single suggestion from this issue. None of them worked. I can ping 1.1.1.1 no problem, it’s just the DNS that doesn’t work
Another workaround is going to network & internet settings, looking up the IPv4 DNS servers and plugging that into the nameserver at /etc/resolv.conf
they could try
echo "nameserver 8.8.8.8" | sudo tee /etc/resolv.conf > /dev/nullDid somebody check that DNS server is accessible by itself before trying to resolve names? If ping from the Linux distro shell to DNS IP doesn’t work VPN client blocks access to DNS forever and not “Temporary”. The common-sense assumption is that VPN provider has its own DNS service and its IP must be pingable. Never try your ISP DNS - it is certainly insecure. For the more detailed investigation, Linux has dig utility that allows finding the answer : linux-dig-command-examples https://phoenixnap.com/kb/linux-dig-command-examples on the question “Why DNS resolution doesn’t work for me?”
Welcome to the WSL2 mess party. 🎉
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:
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.
In case anyone finds it useful, I’ve had no single issue over several months, and pretty reliable, robust and fast connections while using the following
%HOMEPATH%\.wslconfigfile:Please, kindly check this doc for a description of each property’s behaviour, and other properties or values you may find required for your custom setup.
This solution worked for me. But when I disconnect from the VPN and connect again, I have the same problem again and I have to repeat the whole process again and restart. Has it happened to anyone else?
In my environment, I found a 3rd party security software (e. g.
ESETMcAffe) blocked WSL from working DNS. Only disabling a firewall of a security software works fine.I’ve tried every enlisted here solution - nothing helps. The only solution which is helped me is this one: https://learn.microsoft.com/en-us/windows/wsl/troubleshooting?source=recommendations#wsl-has-no-network-connectivity-once-connected-to-a-vpn
Generally, you just get the list of DNS servers used by your VPN via
ipconfig.exe /all, and then copy-paste all these IPs from the DNS section to the/etc/resolv.conf. Restarting WSL and everything is working!Fix for VPN:
nslookupsudo touch /etc/wsl.confandsudo vim /etc/wsl.confto add:wsl --shutdownrm -f /etc/resolv.confsudo touch /etc/resolv.confandsudo vim /etc/resolv.confwith:wsl --shutdownwget google.comand test some you corporate domain.wsl-vpnkit is the only option that worked for me.
This solved my issue
Doing this and changing permission to 777 worked for me
FWIW, I found that
/etc/resolv.confis a link to/mnt/wsl/resolv.conf. I had failed to note that before, destroyed the link, and creaetd a new/etc/resolv.confthat never worked after restarting wsl. After adding/etc/wsl.confto prevent automatic generation of resolv.conf:and adding
nameserver 1.1.1.1to/mnt/wsl/resov.confdirectly, DNS name resolution is working again (and I left the softlink alone).In case others come here believing they have a DNS problem and it’s actually not. My WSL2’s DNS was broken, but that was a red herring: All network access outside of the WSL2 virtual machine was broken. Didn’t notice at first because firewall blocks pinging things like 8.8.8.8.
The real problem? Hyper-V was not enabled. To enable: in elevated PowerShell, do
Enable-WindowsOptionalFeature -Online -FeatureName Microsoft-Hyper-V -Alland boom, DNS working again. What gave me the idea to check.FWIW I was experiencing the same issue, with generateResolveConf=false and 8.8.8.8, while connected to a VPN, and the issue went away when I disconnected and reconnected.
I am on Windows Insider with Windows 11 WSL2 (and it’s graphical kernel?). None of these steps work.
On my version, after the “wsl --shutdown” step, next time WSL starts up, the /etc/resolv.conf mysteriously is deleted.
In windows powershell I run “ping www.google.com” and get an IP. In WSL2 Ubuntu I do “ping (IP from previous step)”. It never returns a result.
Tried to turn off all of firewalls. Still no reply.
Tried to connect to my phone’s network (to avoid workplace network), same error.
I’m at a loss.
EDIT: Workaround is downgrading to WSL1, works fine.
@mandeepsmagh Thanks for comment. I checked default gateway IP by running ipconfig on windows and copy/paste to /etc/resolv.conf on ubuntu. But, I am still getting the error.
I am having the same issue, I don’t think this has to do with VPN, as I was able to work just last week with WSL2 behind company VPN, everything broke (Network Resolution ) after a recent Windows update, and then I couln’t do a
git pullorgit pushI have tried runnig three different flavos of Linux (Ubuntu, Debian and Pengwin) all to no avail same problem. This is making Windows WSL2 not fit for it’s purpose (Developer-friendly Machine) and it’s a Big Deal!!!