You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
{{ message }}
Repository navigation
DNS server coming from vpn network is not reflected in WSL #1350
A brief description
I've L2TP/IPsec vpn connection without default gateway set and own DNS server
Expected results
Bash should add VPN DNS IP to /etc/resolv.conf
Actual results (with terminal output if applicable)
No VPN DNS IP in /etc/resolve.conf . It works though if i set "use default gateway on remote network" (generally i don't want) setting in vpn configuration.
Your Windows build number
14965.1001
Reacted by Sergey Ovchinnik, Bohdan Yurov, Juan Enciso, Roman Böhringer, Frederic Charette, rfboykin, Konrad Klockgether, Chris Beckman, Jake Kreider, Euler and 117 more
Reacted by Kevin Robatel, Johannes Sebastian Agilo Müller, Pedro Augusto Sampaio Messias Ribeiro, Jihyuk Bok, Brandon White and DavisGauntUAH
Alexey Svetliakov (@asvetliakov) - Thanks for reporting the issue. Yes, we are aware of issues with VPN, as you can also see in #416. We are actively working on a solution for this. misenesi as FYI.
Thank you Alexey Svetliakov (@asvetliakov) . I have checked in a fix that will address some of the VPN DNS resolving issues, including yours. Currently for DNS resolving we update /etc/resolv.conf from the service. In this fix I added the capability to manually modify the /etc/resolv.conf file if you wish so, disabling its automatic regeneration.
However, due to how DNS resolving works for various VPN solutions, this fix will only work with strict force tunnel VPN that do not hide their DNS servers for privacy or security reasons. I have a proposal for better solution that is currently under discussion that would work for all VPN scenarios.
Reacted by Brian Bezanson, Bohdan Potishuk, Andrew Sund and Arnold Martinez
misenesi With creators update installed, the automic generation cannot be disabled on my system. Even if I remove the first line, it still get regenerated every single time. It's working for /etc/hosts though.
Reacted by Sean G. Wright, L1ttleFlyyy, Matt Jones, gurpreetshanky, Anna Filina and TIG
Here is the background. By default, bash.exe will auto-generate /etc/resolv.conf every time you launch bash.exe. Then it will try to keep it up to date with changes from Windows, when bash is running. It looks like if you remove the first line, we stop auto-update of the file while bash is running, but forgot to disable the logic to auto-generate during bash launch. We do apologize for the inconvenience and as Ben Hillis (@benhillis) mentions in #1908, we are looking to improve the experience here.
In my case, i set VPN network interface metric to 6000 and both vpn and internet within wsl is now working: Get-NetAdapter | Where-Object {$_.InterfaceDescription -Match "Cisco AnyConnect"} | Set-NetIPInterface -InterfaceMetric 6000 Cisco AnyConnect mentioned in command above is my VPN. yours could be different. along with the metric number.
Don't be too sad about it, it is not sure that it will fix the issues anyways. I am currently using Citrix Secure Access and I still have to use wsl-vpnkit to get connectivity when on the VPN.
dnsTunneling=true does help resolve the name to an IP address, but I still can't connect to internal resources. I've tried with and without networkingMode=mirrored.
Hi ! Please try the latest networking features that we've added in WSL. Those should greatly improve compatibility with VPN's.
If the issue still remains, please reopen this issue.
What about WSL 1? Due to the filesystem performance issue in WSL 2, it remains unusable for my needs. If I'm understanding this new feature correctly, it's only available to WSL 2.
This issue is rather frustrating, as it doesn't always not work with a VPN. I was testing earlier connecting and disconnecting VPN (OpenVPN Connect) and the /etc/resolv.conf magically would update whenever I did. In order to get it "stuck" I had to disconnect VPN, put the computer to sleep, wake it back up, and reconnect - at that point connecting or disconnecting the VPN didn't cause the file to update anymore.
Using wsl --shutdown will do the trick of "fixing" it until the next time my computer goes to sleep (hibernate actually, in case it matters). But that's not a solution, and is really annoying if you have multiple terminals open doing stuff and need to reboot WSL which kills them all.
I would be happy with something as simple as a command that just resets the process that's supposed to sync the DNS settings. At least if I could do that, I could automate it and wouldn't need to shut down WSL entirely. If someone knows a way to do this, it would be greatly appreciated.
I certainly shouldn't need to use my own or a third party script to update the file, when it actually does worksome of the time.
Activity
sunilmut commentedon Nov 18, 2016
Alexey Svetliakov (@asvetliakov) - Thanks for reporting the issue. Yes, we are aware of issues with VPN, as you can also see in #416. We are actively working on a solution for this. misenesi as FYI.
misenesi commentedon Nov 28, 2016
Hi Alexey Svetliakov (@asvetliakov), could you please provide output when you do:
ipconfig /all
?
I have a fix prepared for this, but need to verify that your VPN networking interface is reported as point-to-point interface.
asvetliakov commentedon Nov 30, 2016
misenesi
The one with name 'freechat.com' is my VPN
misenesi commentedon Dec 2, 2016
Thank you Alexey Svetliakov (@asvetliakov) . I have checked in a fix that will address some of the VPN DNS resolving issues, including yours. Currently for DNS resolving we update /etc/resolv.conf from the service. In this fix I added the capability to manually modify the /etc/resolv.conf file if you wish so, disabling its automatic regeneration.
However, due to how DNS resolving works for various VPN solutions, this fix will only work with strict force tunnel VPN that do not hide their DNS servers for privacy or security reasons. I have a proposal for better solution that is currently under discussion that would work for all VPN scenarios.
blemasle commentedon Apr 13, 2017
misenesi With creators update installed, the automic generation cannot be disabled on my system. Even if I remove the first line, it still get regenerated every single time. It's working for /etc/hosts though.
sunilmut commentedon Apr 21, 2017
Bertrand Lemasle (@blemasle) - misenesi is no longer with MSFT.
It looks like we screwed up the
/etc/resolv.confauto-generation logic, see Ben Hillis (@benhillis) comment in #1908.Here is the background. By default, bash.exe will auto-generate
/etc/resolv.confevery time you launch bash.exe. Then it will try to keep it up to date with changes from Windows, when bash is running. It looks like if you remove the first line, we stop auto-update of the file while bash is running, but forgot to disable the logic to auto-generate during bash launch. We do apologize for the inconvenience and as Ben Hillis (@benhillis) mentions in #1908, we are looking to improve the experience here.97 remaining items
saraiva82 commentedon Dec 21, 2023
I just went back to my vm after many hours wasted troubleshooting this.

Afterall....
They know and dont care lol
0xCryptoZen commentedon Jan 9, 2024
fu*k
danielwagn3r commentedon Jan 30, 2024
For me the new WSL2dns tunneling feature solved the problem, see https://learn.microsoft.com/en-us/windows/wsl/wsl-config#main-wsl-settings
Add the following to
%UserProfile%\.wslconfigto enable the feature:jaredbrogan commentedon Feb 23, 2024
Thanks for pointing that out. Unfortunately, it's only available in Windows 11. 😢

dendr203 commentedon Mar 8, 2024
This was the only think that have worked for me and resolved the issue.
TuanChauKMS commentedon Mar 22, 2024
Guys, are there any plans to completely fix this issue in the future?
Thanks all :)
OneBlue commentedon May 14, 2024
Hi ! Please try the latest networking features that we've added in WSL. Those should greatly improve compatibility with VPN's.
If the issue still remains, please reopen this issue.
rgmz commentedon May 15, 2024
That link doesn't state it, but the linked page "Advanced settings configuration in WSL" makes it clear that these settings require Windows 11.
Blue (@OneBlue) do you know if there are plans to support
dnsTunnelingandautoProxyon Windows 10?OneBlue commentedon May 15, 2024
Unfortunately, those features won't be backported to Windows 10.
froh commentedon May 16, 2024
terlar commentedon May 17, 2024
Don't be too sad about it, it is not sure that it will fix the issues anyways. I am currently using Citrix Secure Access and I still have to use wsl-vpnkit to get connectivity when on the VPN.
titanofold commentedon Jul 19, 2024
dnsTunneling=truedoes help resolve the name to an IP address, but I still can't connect to internal resources. I've tried with and withoutnetworkingMode=mirrored.zeel01 commentedon Aug 20, 2024
What about WSL 1? Due to the filesystem performance issue in WSL 2, it remains unusable for my needs. If I'm understanding this new feature correctly, it's only available to WSL 2.
This issue is rather frustrating, as it doesn't always not work with a VPN. I was testing earlier connecting and disconnecting VPN (OpenVPN Connect) and the
/etc/resolv.confmagically would update whenever I did. In order to get it "stuck" I had to disconnect VPN, put the computer to sleep, wake it back up, and reconnect - at that point connecting or disconnecting the VPN didn't cause the file to update anymore.Using
wsl --shutdownwill do the trick of "fixing" it until the next time my computer goes to sleep (hibernate actually, in case it matters). But that's not a solution, and is really annoying if you have multiple terminals open doing stuff and need to reboot WSL which kills them all.I would be happy with something as simple as a command that just resets the process that's supposed to sync the DNS settings. At least if I could do that, I could automate it and wouldn't need to shut down WSL entirely. If someone knows a way to do this, it would be greatly appreciated.
I certainly shouldn't need to use my own or a third party script to update the file, when it actually does work some of the time.
jxu commentedon Apr 1, 2025
Networking mode as mirrored and DNS Tunneling enabled works for me.
This is in WSL Settings in the Start Menu, under Networking.