WSL icon indicating copy to clipboard operation
WSL copied to clipboard

WSL2 fails to make HTTPS connection if Windows is using VPN

Open emrahkaya opened this issue 7 years ago • 135 comments

  • Your Windows build number: Microsoft Windows [Version 10.0.19013.1122]

  • What you're doing and what's happening:

  1. Open WSL 2 terminal (Ubuntu) and type: wget --timeout=30 http://packages.microsoft.com/ubuntu/18.04/prod, which succeeds.
  2. In WSL 2, type: wget --timeout=30 https://packages.microsoft.com/ubuntu/18.04/prod, which also succeeds.
  3. Connect through a VPN on Windows using the built-in VPN client.
  4. In WSL 2, type: wget --timeout=30 http://packages.microsoft.com/ubuntu/18.04/prod, which still succeeds.
  5. In WSL 2, type: wget --timeout=30 https://packages.microsoft.com/ubuntu/18.04/prod, which fails with message "Unable to establish SSL connection".
  6. (control) In Powershell, type wget -TimeoutSec 30 https://packages.microsoft.com/ubuntu/18.04/prod, which still succeeds.
  • What's wrong / what should be happening instead: The 5th step should also have been succeeded.

  • Notes:

  • To be sure that it's not a firewall issue, I've included all network connections, including the VPN connection to the Private group
  • The date command in WSL shows correct date-time.
  • I've also tried with --no-hsts and --no-check-certificate options, but result is the same
  • I've also tested from firefox (in WSL) and it also waited for "Performing a TSL handshake to packages.microsoft.com", couldn't finish connection and gave "The connection has timed out" error after a while.
  • To be sure that it's not an network adapter issue, I've tested it by using both Wireless and Ethernet connections, which also connects to different ISPs.

emrahkaya avatar Nov 19 '19 12:11 emrahkaya

Unable to reproduce on 19025.1 with OpenVPN GUI. (am aware it was explicitly mentioned using the built-in VPN client, but just providing this for reference)

libre-x avatar Nov 19 '19 13:11 libre-x

Unable to reproduce on 19025.1 with OpenVPN GUI. (am aware it was explicitly mentioned using the built-in VPN client, but just providing this for reference)

Thank you for your attention. However, the VPN server I'm using do not support OpenVPN. It supports IPSec IKEv2 (which built-in VPN uses) and Wireguard. I've also tested the issue with Wireguard (running on Windows, not WSL) but unfortunately the result was the same.

emrahkaya avatar Nov 19 '19 16:11 emrahkaya

For what it's worth- I'm having a similar issue with VPN functionality and current insider builds. I'm using Viscosity (1.8.2) and once I connect the VPN, my vEthernet connection for WSL somehow becomes 'unplugged' until I reboot the machine. Shutting down the VM doesn't resolve the issue. My current insider build is 19028.vb_release.191115-1325

Einlanzerous avatar Nov 25 '19 20:11 Einlanzerous

I'm having a similar issue using Pritunl client. Even if I don't activate it, if my computer sleeps, any connectivity is lost in WSL2. like @Einlanzerous, shutting down the VM doesn't help, logging out doesn't help. I have to restart it. 🤷🏻‍♂️

After uninstalling the Pritunl client, it seems I don't get the intermittent any connection on WSL2.

chiefjester avatar Nov 26 '19 14:11 chiefjester

Same. Using Windows10's built-in VPN with type L2TP/IPsec. WSL 2 unable to connect to the internet.

Example: apt update fails with:

Temporary failure resolving 'deb.debian.org'

What works:

  • Turning off VPN
  • Switching back to WSL 1

ukhwaja avatar Dec 25 '19 12:12 ukhwaja

Thank you for the support. It still fails with the newest Windows build (19041.1). I did some tests using Wireshark and it looks like, the TLS Handshake fails in the beginning. The ClientHello packet looks intact, while the ClientServer packet looks broken.

emrahkaya avatar Jan 01 '20 10:01 emrahkaya

I'm having this same issue using Wireguard / Firefox Private Network, both of which use Mullvad over the Wireguard protocol.

I'm using Windows insider build 19041.1.

I'm not sure if this is relevant, but it looks like Wireguard is changing the route table in WSL. It looks like Wireguard replaces all routes that point to the IP address in /etc/resolv.conf with the Wireguard address:

# no Wireguard:
cat /etc/resolv.conf
# 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.22.0.1


netstat.exe -rn

...
IPv4 Route Table
===========================================================================
Active Routes:
Network Destination        Netmask          Gateway       Interface  Metric
          0.0.0.0          0.0.0.0      192.168.0.1      192.168.0.3     35
        127.0.0.0        255.0.0.0         On-link         127.0.0.1    331
        127.0.0.1  255.255.255.255         On-link         127.0.0.1    331
  127.255.255.255  255.255.255.255         On-link         127.0.0.1    331
       172.22.0.0    255.255.240.0         On-link        172.22.0.1   5256
       172.22.0.1  255.255.255.255         On-link        172.22.0.1   5256
    172.22.15.255  255.255.255.255         On-link        172.22.0.1   5256
     172.27.192.0    255.255.240.0         On-link      172.27.192.1   5256
     172.27.192.1  255.255.255.255         On-link      172.27.192.1   5256
...

# with wireguard (10.99.72.157)
IPv4 Route Table
===========================================================================
Active Routes:
Network Destination        Netmask          Gateway       Interface  Metric
          0.0.0.0          0.0.0.0      192.168.0.1      192.168.0.3     35
          0.0.0.0        128.0.0.0         On-link      10.99.72.157      5
     10.99.72.157 255.255.255.255         On-link      10.99.72.157    261
        127.0.0.0        255.0.0.0         On-link         127.0.0.1    331
        127.0.0.1  255.255.255.255         On-link         127.0.0.1    331
  127.255.255.255  255.255.255.255         On-link         127.0.0.1    331
  127.255.255.255  255.255.255.255         On-link      10.99.72.157    261

dmerand avatar Jan 07 '20 13:01 dmerand

I also have issue that when Pritunl is connected, I have no connectivity from WSL2. It's important to note that if the VPN profile only forwards private traffic, WSL2 is blocked only for private IPs, but if the profile is forwarding everything, WSL2 can't reach anything.

I have the same issue that as @thisguychris mentioned that WSL2 completely loses connectivity after my laptop sleeps.

dsmaher avatar Jan 16 '20 19:01 dsmaher

Today, (coincidentally) I've tested to install an Ubuntu Server VM using the Hyper-V. Then, I thought that might be the Hyper-V and it's networking that's causing trouble. I made it use the Default Hyper-V switch to make it more distinctive (WSL uses it's own Hyper-V switch). It turned out that when the VPN is up, the https connections from the VM also ceased. So, that's most likely about how Windows' networking works and it's the one that's causing problem. When I look at the Network adapters page, the VPN is setup as a WAN Miniport, and the Hyper-V adapters are setup as virtual ethernet adapters: explorer_2020-01-20_01-12-26

When I look at the properties page of the VPN, one thing I've noticed is that the Security is maintained by using machine certificates, which might be a case, because the VM doesn't have those certificates (Just thinking :) ): image

I'll investigate further, but I'll be grateful if some of you can also check both the VPN configuration (if it's similar to mine) and the connectivity from a VM. Thanks.

emrahkaya avatar Jan 19 '20 22:01 emrahkaya

I can reproduce the VPN issue with Cisco AnyConnect 4.5.04029, impossible to ping or get data from any domain or IP when active, but works again the moment the VPN connection is disabled.

NiklasBr avatar Mar 22 '20 21:03 NiklasBr

same issue, and the workaround is switch back to WSL1.

sunlin7 avatar Mar 23 '20 01:03 sunlin7

I would be cool is we don't have to switch back to wsl 1

gradinarot avatar Mar 26 '20 10:03 gradinarot

I am having the same issue with Cisco AnyConnect and windows build 19564

pipplo avatar Apr 13 '20 03:04 pipplo

Any updates to this? I've found WSL1's filesystem increasingly unstable, so am trying to switch to WSL2, but the network does not work with Pulse Secure, either. Same behaviour as described here and elsewhere - the network completely fails to connect, and after activating the VPN, a full shutdown and restart of WSL is required to restore network access.

blaine avatar Apr 22 '20 00:04 blaine

This issue was finally fixed for me a week ago. Not sure what did it but my combination of usage was as follows:

  • Windows inside slow ring (now off) after 19041.xxx
  • WSL 2 using Pengwin (Wlinux)
  • Windows terminal
  • Cyberghost VPN

ukhwaja avatar Apr 22 '20 05:04 ukhwaja

@blaine, unfortunately, no updates on the problem. But I'm getting the impression that the problem might be about the VPN protocol (i.e. IKEv2) and the authentication method (machine certificates). @numbfall, I think your problem is solved, because Cyberghost is using a different VPN protocol. It says Cyberghost is supporting "OpenVPN, L2TP-IPsec and PPTP protocols" on their webpage. @numbfall, can you check your VPN settings and tell which type of protocol (OpenVPN, PPTP, etc.) and authentication method (username/password or machine certificate) is used? image Thank you.

emrahkaya avatar Apr 22 '20 09:04 emrahkaya

@blaine @emrahkaya It's set to use OpenVPN. I have never been able to get IKEv2 to work with my Windows, using the windows built-in VPN settings or Cyberghost client.

However, note that I had the issue described in the title with same VPN protocols (OpenVPN) since WSL 2 came out last year on the slow ring. I had to turn off VPN every time I needed to run apt update or yarn upgrade etc. This was only solved a week ago.

This could very well be a solution from the distro side, maybe... I skimmed the release notes of Pengwin but didn't see anything relevant. So I really don't have a clue what really solved the issue.

ukhwaja avatar Apr 22 '20 12:04 ukhwaja

@emrahkaya I'm using Pulse Secure. Type of VPN is SSTP. In the Authentication section, PAP, CHAP, and MS-CHAPv2 are ticked.

huyen-streamotion avatar Apr 27 '20 11:04 huyen-streamotion

Also having this problem with a Cisco Meraki VPN (L2TP with PAP). Its weird because "most" of the network traffic works fine (SSHing for example), but accessing https://google.com does NOT work, while https://duckduckgo.com DOES work.

I just ran a test.. if the TLS connection is made from inside WSL2 before making it on the host, it does work. But if the host then hits the same site, the connection doesnt work.

Example, in WSL I can hit https://xkcd.com, until I go to https://xkcd.com in a windows browser. Then WSL fails to hit xkcd.com

jondavidschober avatar Apr 29 '20 19:04 jondavidschober

I just found #416 and tried a few of the suggestions, but was unable to fix this issue.

NiklasBr avatar Apr 29 '20 20:04 NiklasBr