virtuallypotato/content/posts/2020/10/fixing-wsl2-connectivity-when-connected-to-a-vpn-with-wsl-vpnkit.md

1.8 KiB

date thumbnail usePageBundles tags title toc
2020-10-07T08:34:30Z images/posts-2020/MnmMuA0HC.png false
windows
linux
wsl
vpn
Fixing WSL2 connectivity when connected to a VPN with wsl-vpnkit false

I was pretty excited to get WSL2 and Docker working on my Windows 10 1909 laptop a few weeks ago, but I quickly encountered a problem: WSL2 had no network connectivity when connected to my work VPN.

Well, that's not entirely true; Docker worked just fine, but nothing else could talk to anything outside of the WSL environment. I found a few open issues for this problem in the WSL2 Github with suggested workarounds including modifying Windows registry entries, adjusting the metrics assigned to various virtual network interfaces within Windows, and manually setting DNS servers in /etc/resolv.conf. None of these worked for me.

I eventually came across a solution here which did the trick. This takes advantage of the fact that Docker for Windows is already utilizing vpnkit for connectivity - so you may also want to be sure Docker Desktop is configured to start at login.

The instructions worked well for me so I won't rehash them all here. When it came time to modify my /etc/resolv.conf file, I added in two of the internal DNS servers followed by the IP for my home router's DNS service. This allows me to use WSL2 both on and off the corporate network without having to reconfigure things.

All I need to do now is execute sudo ./wsl-vpnkit and leave that running in the background when I need to use WSL while connected to the corporate VPN.

Successful connection via wsl-vpnkit

Whew! Okay, back to work.