WSL: [WSL2] Checkpoint VPN breaks network connectivity

(I’ve searched the open issues, and none that I could find were exactly the same)

Windows 10.0.18922.1000

I just installed Windows Insiders, and updated my Ubuntu distro to WSL2. It can no longer access the Internet.

From the Ubuntu bash prompt: ping github.com doesn’t work (100% packet loss); ping 8.8.8.8 is the same.

/etc/resolv.conf gives nameserver 192.168.115.225. ping 192.168.115.225 doesn’t work.

My Ubuntu distro has IP 192.168.115.230; I can ping that from Ubuntu.

The Windows IP address is 192.168.115.225, and I can ping it from PowerShell. Pinging the Ubuntu distro’s IP (192.168.115.230) also works, from PowerShell.

Inside Ubuntu, route -n reports:

Kernel IP routing table
Destination     Gateway         Genmask         Flags Metric Ref    Use Iface
0.0.0.0         192.168.115.225 0.0.0.0         UG    0      0        0 eth0
192.168.115.0   0.0.0.0         255.255.255.0   U     0      0        0 eth0

I’m using a Surface Go, Windows 10 Pro, connected to the Internet over Wifi.

I might have some left-over detritus from when I attempted to get a Hyper-V VM connecting via Wifi. That was prior to upgrading to Windows Insiders. I don’t know how much of that Hyper-V networking infrastructure is shared, and I don’t know how to debug that.

About this issue

  • Original URL
  • State: closed
  • Created 7 years ago
  • Reactions: 32
  • Comments: 133 (5 by maintainers)

Most upvoted comments

I’m using the Cisco AnyConnect VPN and as soon as I connect, I lose all access to the external network. Anything I can do to help debug this further?

When I turn on my VPN (Cisco Anyconnect, non-Windows Store version) not only do I lose internet connection from WSL2, but my VS Code remote connection fails as well. It cannot reconnect again until I turn off the VPN. Similarly to others, I cannot use the Windows Store version due to our corporate requirements, so I hope whatever is making that work gets implemented into a fix on WSL2 soon.

So I just worked with my IT Department on coming up with a fix. Here’s what we found out and how we corrected it.

When you connect to Cisco Anyconnect WSL2 will NAT to the highest priority Ethernet Adapter. A newer version of Cisco Anyconnect from the Windows Store seems to correct this; however, it doesn’t support Dual Factor Authentication. So to correct this we used a script that I saw mentioned elsewhere.

Steps:

  1. Restart Computer (or begin from fresh start)
  2. Login to Computer, Connect via Cisco AnyConnect
  3. Run a script from Powershell that includes the follow (Note: your adapter name may need to be changed on Line 2 in quotes)
Get-NetIPInterface -InterfaceAlias "vEthernet (WSL)" | Set-NetIPInterface -InterfaceMetric 1
$VPNInterfaceName = "Ethernet 3"
Get-NetIPInterface -InterfaceAlias $VPNInterfaceName | Set-NetIPInterface -InterfaceMetric 5001
  1. Once that’s been completed open WSL and you should be good to go, unless there is something else causing further issues that I had not experienced.

I hope this helps, as we spent several days attempting to track down the cause.

Edit: Be sure if you have “Ubunut/WSL” set as your default profile in Windows Terminal, that you run the script prior to starting WSL. So if Ubuntu/WSL is your default, set your default to PowerShell, or switch over to PowerShell, run the command wsl --shutdown, then execute the above script, then reopen Ubuntu/WSL.

@d-ryzhikov solution seem to be working in principle. I have tried the new found WSL boot script support for doing that and it seems to solve the situation as well. All what you need to do is to add

[boot]
command="ip link set dev eth0 mtu 1350"

to /etc/wsl.conf.

After a computer restart, WSL seems to be working fine with VPN on.

I have created a script to simplify the solution above for our corporate machines. I have adapted it to be more generic on

https://github.com/AmmarRahman/wsl-vpn

Please feedback if this work for you.

Same problem with Cisco AnyConnect

I don’t have an update here for this specific VPN: Checkpoint. However, in general we are working in improvements to our WSL networking story that should help this area, so please stay tuned. I’ll be sure to post on this thread when I have news on this! 😃 Thank you for your patience.

I installed/used Cisco AnyConnect from Windows Store https://www.microsoft.com/store/productId/9WZDNCRDJ8LH and it started working. Credit goes to https://github.com/microsoft/WSL/issues/4277#issuecomment-561649724

Hi guys I’ve developed a simple script that can help you to deal with conection issue from WSL2: https://gist.github.com/bastaramus/3d5f1326835fe111d5ea9684c41a6675 You need to run this script as an Administrator on your Windows machine each time when you was connected to the CheckPoint VPN. And you don’t need to disable any interfaces or reconnect to VPN. Just launch this script I don’t know is there any way in Windows to automatically launch this script after VPN connection was established. It would be great if somebody can help with this

Hi, I exported an internal troubleshooting document from our company to open-source.

The purpose is to create an ordered checklist to move on and find your right problem easily.

https://github.com/baruchiro/BcsStudent/blob/master/content/posts/wsl-troubleshooting.md

(The document hosted in my Blog repo)

Here is the content, but I can’t promise I will update this comment with future doc updates (but I hope I will and you can remind me if I forgot).

Please add your troubleshooting to there. Thanks.

WSL Troubleshooting

Related Resources

Introduction

This document is written in our company in order to solve the issues with WSL2, CheckPoint VPN and other self-hosted services. You’re welcome to suggest more fixes in this subject to make this document more general.

Network and DNS Troubleshooting

Try each command by their order to better find the correct problem.

Try ping 8.8.8.8

If it failed it means that you don’t have an internet connection at all.

See this video and/or [WSL2] Checkpoint VPN breaks network connectivity (comment) to solve this issue.

Probably the base thing is to connect to the VPN before WSL2 Network Adapter.

  1. Open your WSL Terminal.
  2. Disconnect from the VPN (if connected)
  3. Disable the WSL2 Network Adapter by netsh interface set interface "vEthernet (WSL)" disable or by Get-NetAdapter -Name "vEthernet (WSL)" | Disable-NetAdapter
  4. Please make sure it disabled by $(Get-NetAdapter -Name "vEthernet (WSL)").Status is Disabled
  5. Connect to the VPN
  6. Enable the WSL2 Network Adapter by netsh interface set interface "vEthernet (WSL)" enable or Get-NetAdapter -Name "vEthernet (WSL)" | Enable-NetAdapter
  7. Validate the ping 8.8.8.8 in WSL again.

Try ping google.com

If it failed it means that you have a problem with the DNS. You need to update the /etc/resolve.conf with your DNS addresses.

Run this command in PowerShell: Get-DnsClientServerAddress -AddressFamily IPv4 | Select-Object -ExpandPropert ServerAddresses, then take the addresses from that command, clear the resolve.conf file and set the first line search {your domain} and then the next line will be nameserver {ip}.

Source: you can use this script (from Networking issues while using VPN (comment)) to auto-update the resolve.conf.

Try ping {internalIP}

If it failed it means that you have a problem with the VPN.

Try ping {internal hostname}

If it failed it means that you have a problem with the internal DNS.
Make sure you configured the DNS by the instructions in 2.

Other connection issues

Clone a git repo by SSH

If you’re trying to clone a private repo, you need your credentials that usually configured in the Windows system.

My suggestion is to use SSH, here is an instruction to configure the SSH keys in TFS:

  • Create an SSH key in WSL with ssh-keygen -C your.name@company.com, and paste the ~/.ssh/id_rsa.pub in {tfs-host}/tfs/_details/security/keys

  • If you are getting an error with diffie-hellman-group1-sha1,diffie-hellman-group14-sha1 (I don’t remember the original error), create/edit the ~/.ssh/config file with:

    Host tfs2018app
        KexAlgorithms diffie-hellman-group1-sha1,diffie-hellman-group14-sha1
    
  • Get the SSH repository URL.

  • Clone.

You can try to use the Windows Git Credential Manager with/instead of using SSH, and share the consequences in this document.

npm network timeout

If you are getting the next error when you are trying to use npm, please share the solution with us:

npm ERR! network timeout at: https://registry.npmjs.org/@babel/plugin-proposal-optional-catch-binding/-/plugin-proposal-optional-catch-binding-7.10.4.tgz

You can try this:

  • run Get-NetIPInterface on windows to find MTU value for VPN network adapter (mine was 1350)
  • run sudo ifconfig eth0 mtu 1350 or sudo ip link set dev eth0 mtu 1350 inside WSL to match eth0 MTU value with vpn network adapter value

I also have this problem, using Cisco. Logs here: https://aka.ms/AA6fthe

I just came across this https://github.com/sakai135/wsl-vpnkit. It seems to be working perfectly

@barroudjo Yes for a specific additional customer VPN I had to use a similiar setup. But I use the docker magic for that.

Docker Desktop does a very good job to circumvent the WSL2 quirks by some tun/tap magic, so you can just start a squid proxy in docker. So I came up with the following:

docker run --name squid -d -p 3128:3128 datadog/squid

export http_proxy=http://127.0.0.1:3128
export https_proxy=http://127.0.0.1:3128

Done!

Uninstalling NordVPN does not fix the problem.

The Checkpoint VPN software seems to be responsible for screwing it up. Uninstalling it fixes the problem.

Unfortunately (sigh), I have to have this software installed, so it looks like I’m going to have to uninstall Windows Insiders.

Any chance you could work with Check Point to get this resolved?

The following solution worked for me:

First of all, I want to mantion that my issue was not DNS only related, I had no external connection in WSL2 distribution after connecting to VPN, not even using ips. (no internet connection at all) The error message received on pings was: “temporary failure in name resolution”, but as I said before using, using raw ip instead of hostnames didn’t work as well

Environment:

  • Windows10 2004 (build 19041)
  • vpn client: Checkpoint VPN E83.20
  • WSL2 distro: Ubuntu_20.04

Solution:

I ran the following 2 lines found in this article https://sysblog.dk/?p=254 but addapted for Checkpoint VPN client:

Get-NetIPInterface -InterfaceAlias "vEthernet (WSL)" | Set-NetIPInterface -InterfaceMetric 1
Get-NetAdapter | Where-Object {$_.InterfaceDescription -Match "Check Point"} | Set-NetIPInterface -InterfaceMetric 6000

and rebooted the pc. Those two lines change the Interface Metric so that the WSL interface has a higher priority than the VPN connection. After restart everything started to work as expected (vpn connection, working DNS, internet connection) inside WSL2 without the need to run the mentioned commands again, even though in the article it says that the lines need to be run each time before connecting to VPN. After restart the metric for WSL interface was restored to 5000 (as expected because wsl2 networking is restored to defaults after each restart), but the metric for VPN interface remained as set before to 6000 (5000 still < 6000). I used Get-NetIPInterface command to check the metrics after restart.

Also found almost the same solution explained above: https://github.com/microsoft/WSL/issues/4246#issuecomment-649145305

Edit: added new demo record https://youtu.be/fkXWaVAi6KY

Edit 2: I found out that running docker with windows containers and wsl2 backend broke everything , and couldn’t get it to work as before even if I uninstalled docker. No ideea what happened or how to debug the issue

But I found another solution that works without the need to reboot the PC or shutdown WSL2:

  • whenever you want to connect to vpn, before connecting to VPN, make sure you disable WSL2 network and reenable it afterwards

you dont need any prerequisites and as I said before, no reboot required for PC or WSL2 environment

Here is an youtube demonstration I recorded: https://www.youtube.com/watch?v=yR2NsssY7z8

I have a similar problem with Citrix Netscaler VPN at work, which only tunnels some networks. Internet access is fine with wsl2 but connecting to a host inside a VPN tunneled network, the name can be resolved to an IP but then timeouts (wireshark says tcp retransmission). Citrix Netscaler says, that it has tunneled that connection in the “tunneled application” window. Also disabled the firewall completely, but that didn’t work either…

No combination of mirrored mode networking and dns tunnelling is fully helping. Mirrored mode makes the internet work when connected via checkpoint, but WSL2 can’t access the vpn subnets. Dns tunneling doesn’t seem to change anything.

I have stumbled upon a solution on another issue. https://github.com/microsoft/WSL/issues/4698#issuecomment-628682785. sudo ifconfig eth0 mtu 1350 did the trick for me.

I am seeing the same behavior using Cisco AnyConnect VPN. Any updates on this issue?

Same issues also with Checkpoint VPN

How it worked for me, maybe someone understands whats happening with this infos:

  1. Reboot
  2. Check “Control Panel\Network and Internet\Network Connections”, that it does not show "vEthernet (WSL)
  3. Connect VPN (in my Case Checkpoint)
  4. Start WSL2 -> in Windows the Network Adapter “vEthernet (WSL)” is created image

-> at this point i had basic connectivity (can ping VPN internal ips, wget / curl with http, but no https)

  1. set MTU inside WSL to the value of your VPN, (1350 for me) -> now https is working, but still i cannot apt update (“temporary errror in resolving…”)
  2. lookup company nameservers in windows (details of VPN Connection under DNS-Servers)
  3. add those DNS servers to /etc/resolve.conf image

I had the same issue as above quote. only https not working through VPN. For the changing the MTU to 1350 solved. I also use Checkpoing VPN, so it’s the same MTU value.

On Ubuntu 20.04

sudo ifconfig eth0 mtu 1350

Same issus occurs with Cisco OpenConnect VPN. Here are the logs https://aka.ms/AA6jmg1

I know this is closed, but for others who end up here, I’ll post my answer, because for me, it was a combination of things that got this working for me.

Like many of you, my company switched to Checkpoint VPN, and after that, my WSL connectivity was broken. Here’s how I fixed it. Note that I did not need to shutdown WSL, uninstall/reinstall anything. I just needed to update a text file and a NIC configuration. That’s all.

First, I edited the /etc/resolv.conf file. Now this is a symlink to a file that is automatically generated by WSL. ~Since I just got this to work, I have not yet turned off auto-generation of this file. (I’m waiting to see if this will be necessary before turning off auto-generation.) For now,~ I have now turned off auto-generation of this file because I found that upon restart of the underyling VM, the file is reset and the changes I made below are necessary for me to have internet access from Ubuntu on WSL. YMMV depending on your environment and how your networking staff have configured the VPN. I simply changed the file to have the following contents:

# 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 <VPN Nameserver 1>
nameserver <VPN Nameserver 2>
nameserver <Home Router Nameserver>

The first two lines I snagged from ipconfig /all for the adapter associated with the Checkpoint VPN connection. The last one is my home router’s nameserver (or, your preferred nameserver, e.g. Mozilla, Google, Cloudflare, etc.). Originally, I put my home router nameserver first because I wanted to prioritize most requests through my ISP. BUT, apparently, WSL stops querying nameservers at the first “successful” response even if the result is “I couldn’t find what you’re looking for.” So, I switched them around. Oddly enough, when I later did a nslookup for a company resource, the VPN nameservers failed to resolve the company resource, but my home router entry resolved the name 😕 Whatever, it worked.

OK, so at that point, I could ping the company resource I wanted access to—in this case, an Azure DevOps on-prem server. BUT, when attempting to git fetch origin, I received the following message: Recv failure: Connection reset by peer. Hmm, is this a firewall issue? It doesn’t seem like it—that would usually be Connection forcefully reset by peer… Then I remembered the above references to the MTU size. So I did a ip link set eth0 mtu 1350, because that’s what the Checkpoint VPN is configured to use as the MTU (by default?). Once that was done, I was able to access the Azure DevOps server and fetch my repository.

So, to summarize the required steps:

  1. Update /etc/resolv.conf, potentially turning off auto-generation of the file
  2. Set your WSL adapter’s MTU (from within WSL) to the same MTU as your VPN ethernet adapter’s MTU.
  3. Profit.

Hope this helps somebody. At least this will help my future self. 😆

Hi folks, we have put out a new update that aims to address networking issues in WSL. In your .wslconfig file you can set experimental.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.

How it worked for me, maybe someone understands whats happening with this infos:

  1. Reboot
  2. Check “Control Panel\Network and Internet\Network Connections”, that it does not show "vEthernet (WSL)
  3. Connect VPN (in my Case Checkpoint)
  4. Start WSL2 -> in Windows the Network Adapter “vEthernet (WSL)” is created image

-> at this point i had basic connectivity (can ping VPN internal ips, wget / curl with http, but no https)

  1. set MTU inside WSL to the value of your VPN, (1350 for me) -> now https is working, but still i cannot apt update (“temporary errror in resolving…”)

  2. lookup company nameservers in windows (details of VPN Connection under DNS-Servers)

  3. add those DNS servers to /etc/resolve.conf image

I can confirm the comment of @AmmarRahman. After installing Docker Desktop on my Windows machine and switch to the WSL2 backend, I noticed that this docker daemon is able to access resources in the vpn (downloads an image from a docker registry there). I can also confirm it by running a container accessing resources on the vpn docker run alpine sh -c 'wget -O- https://some-vpn-internal.resource.com'. Eventhough the communication to vpn resources don’t work in wsl2, ex. by running the docker wsl2 “machine” (wsl.exe -d docker-desktop). So I think something is actively preventing this to work

The workaround I have at the moment is to work within a container. Even though Docker uses WSL2 as it’s backend, they seem to have got a better network setup that would work through the VPN.

Similar issue with Citrix VPN. I can ping the server, but can not open tcp port 80 and curl is timeout.

I have created a script to simplify the solution above for our corporate machines. I have adapted it to be more generic on

https://github.com/AmmarRahman/wsl-vpn

Please feedback if this work for you.

Works like a charm, thank you

Thank you @sakai135 and @AmmarRahman! This is exactly what I’ve been looking for. Thank you vpnkit for showing Microsoft how to fix their product

I can confirm this works with Sonicwall using NetExtender (10.2.309, but I doubt the version matters). I no longer have to use the broken MobileConnect.

Just dropping by to say that with socat and a local proxy you can circumvent altogether this problem, at least for http calls:

  1. set your WSL http_proxy env var to point to a socat TCP listening process: http_proxy=http://localhost:8118

  2. launch socat to listen and forward (through binary communication) to a socat (socat cygwin) in windows the tcp calls: socat tcp-listen:8118,fork,reuseaddr exec:"/mnt/c/Workspace/socat/socat.exe - tcp\:localhost\:8118"

  3. run a proxy server (for example privoxy, or winfoom / px if you need to go through a corporate proxy with cntlm authentification) on your windows host, at the same 8118 port

  4. you also need to configure the http proxy for apt-get to http://localhost:8118 in /etc/apt/apt.conf.d/proxy.conf: Acquire::http::Proxy "http://127.0.0.1:8118";

It’s a workaround, but it’s robust, and it should work for all cases. Doesn’t matter which vpn, if you have connectivity in windows you will have it in WSL. To make it clean obviously you should autostart the socat process. I have a solution but it’s not the cleanest and I’m sure people here more competent than I can propose something better !

The solution provided by @agalbenus worked perfectly for me using Check Point Endpoint Security VPN. I’ve made a small batch script to automate disabling the network interface, connecting/disconnecting from the VPN and then enabling it again.

Here’s the link if anyone is interested: https://gist.github.com/thiagoarruda/7cb0ffb6617f9df9fa7f08b328dfbaf8

image

For me, nameserver modification is not needed. Only the MTU 1350 is required to make my WSL2 work with https access via AWS Private Endpoints.

@baruchiro I also had problems with TLS while pulling a docker image from VPN network inside WSL2. I fixed it by setting the MTU inside WSL2 to be the same as VPN network MTU on windows host :

so the fix was: -run Get-NetIPInterface on windows to find MTU value for vpn network adapter (mine was 1350) -run sudo ifconfig eth0 mtu 1350 inside WSL to match eth0 MTU value with vpn network adapter value

you should be good to go

That’s strange. From within docker I have full access to internal resources without changing anything in docker network.

So, interestingly enough, uninstalling and reinstalling the Checkpoint VPN software appears to fix the problem.

I have the same problem, but this did not seem to help in my case.

I lose internet connectivity in WSL2 when using SonicWall VPN in full-tunnel mode. If I switch to partial-tunnel, then WSL2 internet connectivity is fine.

Using also Zscaler proxy running on Windows on http://localhost:9000. and having the same problem than @aderuelle Any idea how to solve this

Hi @wesleymusgrove,

In addition to using Cisco AnyConnect VPN on my Windows 10 host, all my traffic also goes through a Zscaler proxy running on Windows on http://localhost:9000. That means that while I’m connected to my VPN, in Windows I also have to specify HTTP_PROXY=http://localhost:9000 pretty much everywhere you can imagine so that things can access the internet. Inside of WSL, […] . However I’m getting this error: curl: (56) Recv failure: Connection reset by peer and I don’t know at what layer it’s failing…

curl: (56) Recv failure: Connection reset by peer


I’m facing the same issue here (win10 20H2 + WSL2 + Zscaler client connector 3.1.0.96)

  • added firewall rules to allow WSL access port 9001 on host
  • added netsh interface portproxy to proxy on host address 10.90.161.68
  • changed interface metrics
  • set http_proxy/https_proxy in WSL guest

curl on host through proxy => OK curl on WSL guest =>

$ curl  -v https://www.google.com/
* Uses proxy env variable https_proxy == '10.90.161.68:9001'
*   Trying 10.90.161.68:9001...
* Connected to 10.90.161.68 (10.90.161.68) port 9001 (#0)
* allocate connect buffer!
* Establish HTTP proxy tunnel to www.google.com:443
> CONNECT www.google.com:443 HTTP/1.1
> Host: www.google.com:443
> User-Agent: curl/7.78.0
> Proxy-Connection: Keep-Alive
> 
* Recv failure: Connection reset by peer
* Received HTTP code 0 from proxy after CONNECT
* CONNECT phase completed!
* Closing connection 0
curl: (56) Recv failure: Connection reset by peer

Were you able to solve it ?

Do we have to run this after every reboot?

Many VPN clients have the ability to run a post connection script, https://docs.paloaltonetworks.com/globalprotect/9-1/globalprotect-admin/globalprotect-apps/deploy-app-settings-transparently/customizable-app-settings/script-deployment-options.html, however I’m not sure if that will be able to run with the rights you need (I supposed that depends on how GlobalProtect works)

If your Admins are willing to setup this up for you, they can

  1. As an admin, Create a task in “Task Scheduler” that will do what you need. Make sure it’s configured to run with admin privileges. Usually this means "Run as SYSTEM user, and check the “Run with highest privileges”, but they may have another user account designed for this purpose.
  2. “Allow task to be run on demand” must be on
  3. No trigger needs to be setup
  4. Action would run a command (or script) to set your settings.
  5. Have the admin give you permission to run the task (I think this is automatic, I don’t remember)

Now this means you’ll have permission to run an “elevated” task. This is the closest to a “windows sudo” list I know of.

There’s a command. As a user, you can create a shortcut to run SCHTASKS.EXE /RUN /TN "task name", and now you can run that task that needs admin, as a non-admin any time you want.


I used to think this would help, but on second glance, it will not, it’s kind of solves an opposite problem ~https://docs.microsoft.com/en-us/powershell/module/vpnclient/add-vpnconnectiontriggerapplication?view=windowsserver2019-ps~

Do we have to run this after every reboot?

Actually you need to run every time you connect the VPN. I haven’t been able to find a way to keep the values permanent or without the need of elevated rights

Before I forget: today I restarted my PC and I connected to Cisco VPN before login to Windows (it is possible in the windows logon page). Then, even applying what I decribed in my previous post, it didn’t worked.

Then, what I did to fix it was:

1 - Disconect from VPN 2 - Connect to the VPN again 3 - Change the interface metric (with admin rights):

Get-NetAdapter | Where-Object {$_.InterfaceDescription -Match "Cisco AnyConnect"} | Set-NetIPInterface -InterfaceMetric 5001
Get-NetIPInterface -InterfaceAlias "vEthernet (WSL)" | Set-NetIPInterface -InterfaceMetric 1

4 - Run this tool within the WSL.

@idsergiu provided the best and most simpler solution. Nevertheless, I had to use this tool from the comment of @baruchiro about the DNS resolution problem.

Thank you very much guys!

@barroudjo & @smerschjohann many thanks for your proxy ideas!

We (@tkalmar and I) also added a dante socks proxy so that we can SSH to other machines in our corporate network. So we now have a docker-compose setup that starts both dante and tinyproxy in containers. We might share the entire setup later but we want to give it more “baking time” first.

Alright, so I’ve been wanting to use WSL 2 for a while now and the only thing stopping me is the VPN connectivity issue. I found something that I’m not sure if others have because I haven’t found any posts in the issues I’ve been looking through and figured I should throw this in here as a possible reason for the issue with VPN connectivity issues.

I have tried a lot of the workarounds except for the metric modification because I don’t want my system to “disable/ignore” my VPN. From what I understand of the metric value is that it is a priority system and if you increase the metric on a VPN to higher than your outgoing internet nic you are basically routing 0 traffic through the VPN. (If I am misunderstanding this, please let me know).

So, I’ve been looking into the Hyper-V Virtual Switch and while trying to create an external switch /(or modifying the WSL one) the external network interfaces list does not show the VPN interface image. I am using Private Internet Access as my VPN connection and as shown in the image is not in the selection list.

I hope this helps with figuring out if there might be an issue with the Virtual Switch instead of with the WSL networking in general.

Just some extra info showing that DNS resolving is working fine (for some reason)[this is a fresh Ubuntu 20.04 WSL 2 install].

> curl -L ip.me -v
*   Trying 134.209.78.99:80...
* TCP_NODELAY set
* connect to 134.209.78.99 port 80 failed: Connection timed out
* Failed to connect to ip.me port 80: Connection timed out
* Closing connection 0
curl: (28) Failed to connect to ip.me port 80: Connection timed out

> ip route
default via 172.17.40.145 dev eth0
172.17.40.144/28 dev eth0 proto kernel scope link src 172.17.40.147

> ping 172.17.40.145
PING 172.17.40.145 (172.17.40.145) 56(84) bytes of data.
64 bytes from 172.17.40.145: icmp_seq=1 ttl=128 time=0.317 ms
64 bytes from 172.17.40.145: icmp_seq=2 ttl=128 time=0.441 ms
64 bytes from 172.17.40.145: icmp_seq=3 ttl=128 time=0.292 ms
^C
--- 172.17.40.145 ping statistics ---
3 packets transmitted, 3 received, 0% packet loss, time 2113ms
rtt min/avg/max/mdev = 0.292/0.350/0.441/0.065 ms

> ping 1.1.1.1
PING 1.1.1.1 (1.1.1.1) 56(84) bytes of data.
^C
--- 1.1.1.1 ping statistics ---
5 packets transmitted, 0 received, 100% packet loss, time 4185ms

I had the same behavior - connection via https/443 didn’t work on WSL2, giving:

>wget https://github.com/kubeflow/manifests/archive/ebeb4c285a0cf49750c4f07015b58cc27ca4c3a1.tar.gz --2021-03-01 20:24:44-- https://github.com/kubeflow/manifests/archive/ebeb4c285a0cf49750c4f07015b58cc27ca4c3a1.tar.gz Resolving github.com (github.com)... 140.82.112.3 Connecting to github.com (github.com)|140.82.112.3|:443... failed: Connection timed out. Retrying.

However it worked on WSL1. Windows 10 Pro: Version 10.0.19042 Build 19042 (latest till now on my laptop - Dell XPS 17). I have OpenVPN installed as well, however behavior didn’t change whether I have VPN connection established or not. All above methods (including thread in https://github.com/microsoft/WSL/issues/4246, except latest one in this thread - around proxy) didn’t help.

Interestingly enough - for me it turned out to be the Symantec Endpoint Protection antivirus… Not sure yet what exactly it blocks - will try to find. When protection was disabled - things started to work as expected…

@baruchiro /etc/resolv.conf not /etc/resolve.conf

I came up with a different solution, as I seem to have a different problem than the other posts here.

In my situation the endpoint firewall was in the way, For virtualbox etc. the company excluded some ip addresses from these rules exactly for such internal purposes. So I had to use one of these ip addresses to allow internet access.

I do that with the following scripts (e.g. 192.168.123.100/32 is your excluded IP address)

Windows / Powershell

A small powershell script which adds a route to the vSwitch to route traffic to the ip range/single IP excluded in the checkpoint firewall.

$wslIfdx = (Get-NetAdapter -Name "vEthernet (WSL)").ifIndex
$wslIfAddr = $(Write-Output (Get-NetIPAddress -InterfaceIndex $wslIfdx).IPv4Address)[1]
New-NetRoute -DestinationPrefix "192.168.123.100/32" -InterfaceIndex $wslIfdx -NextHop $wslIfAddr

Linux / WSL2

A script that switches the activate IP address of the system, it turned out that I didn’t need to change the /etc/resolv.conf (DNS resolution) that may vary in your setup.

#!/bin/bash

ip=$(hostname -I)

sudo ip addr add 192.168.123.100/32 dev eth0
sudo ip addr delete $ip dev eth0;
sudo ip link set mtu 1350 dev eth0 # needed to connect to IPs behind VPN

Until a proper fix arrives from microsoft, here is a workaround that I use, to change the mtu size on startup.

  1. Create a script that would change the mtu size:
echo<<EOF | sudo tee /etc/init.d/eth0-mtu
#!/bin/sh
ip link set dev eth0 mtu 1350
EOF
sudo chmod 755 /etc/init.d/eth0-mtu
sudo chown root:root /etc/init.d/eth0-mtu
  1. Allow the script to be executed by sudo without password. Run sudo visudo and add the following line:
%sudo   ALL=NOPASSWD:   /etc/init.d/eth0-mtu
  1. Create a startup shortcut. Press Win + R, enter shell:startup, in the open directory create a short cut with the following command:
"C:\path\to\your\distro.exe" run sudo /etc/init.d/eth0-mtu

To find path to your distro:

  1. Run your wsl terminal.
  2. Start “Task Manager” and select “More details” at the bottom of task manager window.
  3. In the process tree find your distro, right-click on it and select “Open file location”.

Inspired by https://adrianstoll.com/tips-and-tricks/running-services-at-startup-windows-subsystem-for-linux.html

@drewtech https://github.com/microsoft/WSL/issues/4246#issuecomment-705925065

Didn’t work for me! 😦

WSL2 - Ubuntu 20.04, Citrix Gateway 13.0.64.35 on Win10 64 bit, Build 18363

image

@craigloewen-msft, any update on vpn issues? Is there something on the way to make it work? What it makes a strange problem is that Docker Desktop with WSL2 engine works perfectly while we are on a VPN, but not WSL2 itself!

Can someone smarter than myself confirm if this issue is the same as the recently resolved WSL vEthernet issue, fixed in Windows 10 preview build 20231?

https://github.com/microsoft/WSL/issues/5821#issuecomment-705075529

I think this info might help understanding the Problem better:

I compared the Windows routing tables of a working network in wsl with a non working.

There are some additional entries generated for the WSL Network Adapter, after Connecting via Checkpoing VPN, where especially one is responsible for the failing network inside WSL. (Not able to ping), at least it seems so

When192.168.243.241 is the IP of vEthernet (WSL) Adapter in Windows:

**route PRINT 192.168.243***

Active Routes:
Network Destination        Netmask             Gateway       Interface                   Metric
  192.168.243.240      255.255.255.240         On-link        192.168.243.241        5001
  192.168.243.240      255.255.255.248         172.xxx.xxx.yyy  172.xxx.xxx.xxx     1             <--- this points to VPN Interface
....
....

Then i did in CMD:

route delete 192.168.243.240 mask 255.255.255.248 172.xxx.xxx.yyy

After that i can ping the nameserver from inside wsl. (after setting MTU)

–

The MTU and resolv.conf still need modifying…

–

that aligns with @daveomcd and @Irenaud s post, because changing the Adapter Metrics will priorize the working route, that has metric 5001 by default, before the route that i deleted

Hey Glenn @testworksau , just enable the Local LAN access can fix this issue. image

But still, you can not access the internal network

I haven’t changed anything on the host configuration. However, I did run netsh.exe interface ipv4 show interfaces to verify that 1350 is the mtu that my VPN is operating at.

@AmmarRahman, I can observe the same behavior here. I’m using a VPN and a proxy and it works perfect only in a docker container (using Docker Desktop with WSL2).

I tried @andyneff workaround but didn’t work unfortunately…

For now, my workaround will be using a container in WSL2 to be able to connect to network.

same issue using Cisco AnyConnect (connected)

FWIW I’ve experienced what sounds like a similar issue, and I don’t use Checkpoint VPN. I notice that when this happens, seemingly all socket-level operations seem to fail in Windows. Even my Android emulator becomes inaccessible to Android Studio, and all Chrome tabs indicate no internet connectivity. Closing all Ubuntu windows resolved the issue for me today, and this consistently happens when I leave a local server running in Ubuntu overnight and come back to my workstation 24 hours later.