WSL: WSL2 fails to make HTTPS connection if Windows is using VPN
-
Your Windows build number: Microsoft Windows [Version 10.0.19013.1122]
-
What you’re doing and what’s happening:
- Open WSL 2 terminal (Ubuntu) and type:
wget --timeout=30 http://packages.microsoft.com/ubuntu/18.04/prod, which succeeds. - In WSL 2, type:
wget --timeout=30 https://packages.microsoft.com/ubuntu/18.04/prod, which also succeeds. - Connect through a VPN on Windows using the built-in VPN client.
- In WSL 2, type:
wget --timeout=30 http://packages.microsoft.com/ubuntu/18.04/prod, which still succeeds. - In WSL 2, type:
wget --timeout=30 https://packages.microsoft.com/ubuntu/18.04/prod, which fails with message “Unable to establish SSL connection”. - (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
datecommand in WSL shows correct date-time. - I’ve also tried with
--no-hstsand--no-check-certificateoptions, 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.
About this issue
- Original URL
- State: closed
- Created 7 years ago
- Reactions: 118
- Comments: 135 (2 by maintainers)
A simple fix for me was to set MTU to 1350 (same as VPN interface):
sudo ifconfig eth0 mtu 1350Even SSH connections are more stable now.
thank you @earljon .
This is my solution for:
Pulse Secure VPN
netsh interface ipv4 show subinterfaceip link listsudo ip link set dev eth0 mtu 1400Notes
Local Area Connection*with an MTU value ~100 less than the other “Local Area Connection” entries. That’s the value I wanted.eth0mtu value is set to. It was not the MTU value discovered in Step 1.eth0to the value discovered in Step 1.Thank you! This worked for me.
Changing the MTU did it for me. My tip was to doublecheck the MTU my network adapter is actually using with
netsh interface ipv4 show subinterfaceThen I could follow the tip by @neseih (but with the
ipcommand instead)That solved it for me. Did not succeed in having it apply after a reboot though, but I just inserted the snippet into a script and I run it manually on each morning when I start working via the VPN.
Sorry if I missed a statement of it in the discussion, but is this planned to be fixed? Like that WSL 2 applies MTU changes automatically when switching to VPN. Or will this config always be have to be done manually on a per-user basis?
This solved my issues as well. I am using checkpoint VPN.
to get the MTU value of your VPN run below command for checkpoint, for example :
Note the index of the connection, then run below statement. Match the index found above in below result and note the mtu.
Not you have the mtu value… Login into your wsl and run below statement(1350 is the mtu found above):
sudo ifconfig eth0 mtu 1350You can also run this script when you wsl2 is starting. below is the script if you have debian based wsl
sudo ip link set dev eth0 mtu 1350I 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.
@r-l-x describes the issue I’m seeing too and suggests the best workaround IMO.
However this also depends on the remote side of the VPN not having broken path MTU discovery, too - because it is still possible to negotiate a higher TCP MSS that the server will try to use when sending its response. The second workaround below of reducing interface MTU in the guest will cause a lower TCP MSS to be negotiated and works around this potential issue at the far-end of the VPN.
So if this first workaround does not work for you, then move on to the second.
@jakebrinkmann also suggests a valid workaround, although this will reduce MTU for all traffic out of the WSL2 guest, rather than just traffic over the VPN.
Just to re-iterate and expand on what @r-l-x has already described:
In the issue report, it is described that an HTTP request works, but a following HTTPS request to the same server times out. With the assumption there are no firewall/server issues with transport of HTTPS to/from the server, this is a classic symptom of an MTU blackhole.
In my case, I could not see any ICMP “fragmentation needed” messages arriving at the guest. So the issue is due to broken path MTU discovery, leading to an MTU blackhole where any packets larger than the VPN MTU are silently discarded.
The normal behaviour is for an ICMP “fragmentation needed” message to be generated from the egress interface (the VPN) back to the sender, so that it can learn of the constrained MTU and shrink future packets to the destination to the size of this reported MTU.
But this is either not happening at all (bug in windows VPN interface), or this message is being discarded/not forwarded to the WSL2 guest (possibly a bug in Hyper-V virtual switch/nic interface).
Similarly for IPv6 there is an ICMPv6 “packet too big” message, but I don’t know if that also suffers from this issue/bug.
This needs to be identified as a bug so that a proper fix may be implemented.
For anyone else experiencing issues - if you find that you are not able to even ping a destination over your VPN from your WSL2 guest, then it is likely you are experiencing a different issue than what is described here.
sudo ip link set eth0 mtu 1400works for me.But, how do I set that permanently?
Same. Using Windows10’s built-in VPN with type L2TP/IPsec. WSL 2 unable to connect to the internet.
Example:
apt updatefails with:What works:
My Usecase: I am using WSL2 on Windows 11. Wireguard is the VPN that I am using. I am using WSL2 with the tool DDev for running a local Drupal environment that is entirely open source.
1st problem encountered:
curl https://packages.drupal.org/8/packages.jsoncurl: (6) Could not resolve host: packages.drupal.orgSolution: (Within WSL)
cd /etc/sudo chattr -i resolv.confrm -r resolv.confsudo echo 'nameserver 1.1.1.1' >resolv.confsudo chattr +i resolv.confsudo echo -e '[network] \ngenerateResolvConf = false' >> /etc/wsl.conf2nd problem encountered: I then was experiencing the same behavior as below… Though instead of
https://packages.microsoft.com/ubuntu/18.04/prod,https://packages.drupal.org/8/packages.jsonwas timing out at the same spot.Like many others before, my issue now was that the MTU value of WSL did not match the MTU value of my VPN interface.
Solution:
Figure out the MTU of your VPN.
C:\WINDOWS\system32>netsh interface ipv4 show subinterfaceMine was 1420. Everything else was set to 1500.In WSL, See your network interfaces with
ifconfig. set the eth0 interface to match the VPN’s MTU value.sudo ifconfig eth0 mtu 1420In my case it was an MTU issue and
sudo ifconfig eth0 mtu 1400fixed outbound traffic for me.@smerrill That was a great catch.
After seeing the TLSv1.3 to TLSv1.2 change in your
icanhazip.comlog, I started thinking that it can related with TLS version. And tried several other servers to confirm that. The result is if the server supports TLS v1.3, then the handshake is successful, otherwise it doesn’t work. You can check other servers’ TLS support from https://www.cdn77.com/tls-test, and try to connect from WSL. For my case,packages.microsoft.comdoesn’t support TLS v1.3, so handshake doesn’t work. Interestingly,apple.comdoesn’t support TLS v1.3 and doesn’t work; butwww.apple.comsupports v1.3 and works. Btw, for meicanhazip.comdidn’t work either, because it doesn’t support v1.3.I also tried to force
curlto use v1.2 by setting--tlsv1.2and--tls-max 1.2parameters, but it didn’t work:So, I think the problem is now a bit more focused, but I still don’t know why it behaves this way.
I also ran into this problem. This is a classic Path MTU discovery black hole case, where for some reason the Windows/VPN side doesn’t send a “Fragmentation Needed” ICMP packet to the linux side. Rather than hardcoding a smaller MTU on the linux interface, a cleaner workaround is (I think) to enable MTU black hole detection on the linux side:
# echo 1 > /proc/sys/net/ipv4/tcp_mtu_probingFor the reference, here is the documentation for this kernel setting (source)
Note that the fact that there is no convenient way at the moment in WSL2 to keep a persistent sysctl setting (see #4232) is quite annoying, and this setting must be applied every time WSL2 restarts for the moment.
To be honest I don’t understand why common linux distributions don’t enable MTU black hole detection by default. This is a very helpful feature. Microsoft has enabled this by default in Windows since Vista (source). For the reference, here are some discussions I have seen on this subject in Ubuntu: https://lists.ubuntu.com/archives/ubuntu-devel-discuss/2012-February/013195.html and in OpenSUSE: https://bugzilla.opensuse.org/show_bug.cgi?id=971797.
This solves the same problem I had, however the command to enable MTU black hole detection doesn’t work for me. I had to use
For reference see: https://lists.ubuntu.com/archives/ubuntu-devel-discuss/2012-February/013198.html
Unbelievable, finally, a solution works for me
Just an update on my WSL2 Issue with Check Point Endpoint VPN. I think I have solved it following solution found here - https://github.com/microsoft/WSL/issues/4246
Basically, what I only did is to set the MTU to the correct value. I’ve been trying to set my MTU to 1400 but based on the link above, for Checkpoint VPN to work with WSL2, a value of MTU 1350 is all it needs.
No modification of /etc/resolv.conf needed. No restart needed.
When connected using NordVPN, I get very slow or no internet connectivity when using WSL2.0
Resolution for NordVPN
sudo ip link set dev eth0 mtu 1400Adding on to the pile, I can confirm that Cisco AnyConnect VPN 4.8 appears to break most connectivity within WSL 2.
I don’t know if a different issue needs to be created, but when I use a windows-side VPN (PulseSecure), all networking in WSL2 fails. I’m unable to reach any hosts, resolve DNS, or make HTTP requests, SSL or not. My workaround is literally to use my Mac.
There seems to be 3 issues as far as I can tell, all of them different depending on the VPN client. The 3 issues are:
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!)Open windows firewall and add wsl application and check all the boxes and restart the computer. This solved my connection issue.
This will prevent you have having to enter password every time it runs.
sudo vi /etc/dhcp/dhclient.conf
below ‘send host-name’, add the following line. default interface-mtu 1350;
I’ve been struggling with extremely low download speed for almost a year as described in #5638 In my case it happened only when I turn on my VPN and only within WSL, from Windows was everything fine.
The
sudo ip link set dev eth0 mtu 1400solution worked like a charm, it now works perfectly. I can’t believe it but finally there we go 😃I would add it to my
~/.bashrcor~/.profile, etc so it runs everytime WSL initalises, but I suppose that isn’t truly permanent, more so just “apply it every time the user logs (so when WSL loads)”.Since everyone else is posting their case: I got it working for me by setting different DNS nameserver IPs in
/etc/resolvconf, not by adjusting the interface MTU.I was able to get ssh working with following fix (3) provided by @roniburd . I did not have to make any other changes. Thanks @roniburd
@emrahkaya I’m using Pulse Secure. Type of VPN is SSTP. In the Authentication section, PAP, CHAP, and MS-CHAPv2 are ticked.
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.
i also don’t use, 1200 mtu solved for me…
Has anyone experienced these issues when conncted to a vpn via PaloAlto GlobalProtect? Changing the MTU to the same or below the vpn adapter mtu sadly didnt help.
I now have AnyConnect working with WSL2 using version 4.10.01075.
I think you need to make sure you have the ‘Allow local LAN access’ option checked:
MTU solution worked perfectly for me. My MTU for my VPN connection is 1400, while my other connections are 1500. I set the linux MTU to 1400 to match my VPN and it works
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.
@craigloewen-msft do you know if
networkingMode=mirroredwill be available on Windows 10?I’m not using VPNs for connecting to the Internet (although I have some installed), and I face the same problem in some of my WSL distros (Debian and Ubuntu), and not in others (CentOS).
The problem did not been solved by changing MTU. My NIC drivers are seemed to be updated.
I’m trying with
sudo ip link set dev wifi0 mtu 1400but after runip addragain, it is still in 1500Tested using Windows 11 + wsl1 + ubuntu 20.04
this (
dhclient.conf) solution worked once (hence the 👍), however it is not working consistently. tried shutting down wsl and restarting, but it still does not workis there anything that needs to be done to cause the dhclient code to be executed again by wsl?
+1 on this
I was able to configure my WSL2 installation using steps from a post on Cisco forums. Since I am behind a proxy that requires authentication, I also configured the
/etc/resolv.confto point to our local DNS server - and also setup CNTLM for authentication. I added the proxy forhttpandhttpsvialocalhost:3128to my.bashrcand/etc/apt/apt.conffiles.After updating the interface metrics on the Cisco Anyconnect and vEthernet (WLS) adapter (after any resets/reconnects) as per Cisco forum post, I am able to access external resources via the proxy. However, only
httpresources are accessible and anyhttpsresults in errors. I see following issues when I try toapt updateusing repositories withhttpsURLs.Similar SSL/TLS handshake issues when trying to
git cloneusing anyhttpsURLs from GitHub.I am running Cisco AnyConnect 4.9.03049, but I do not see the setting (‘Allow local LAN access’) recommended by @Glen-Moonpig’s previous suggestion on this thread.
I have also tried recommendations in the previous replies, and changed the MTU on the Cisco and WSL2 adapters both from Windows 10 host (using Poweshell as admin) and from within WSL2 to the same value. However, none of the values (ranging between 1100-1400 in steps of 10) helped. The OP for Issue #5346 reported the
gnutls_handshakeissue - but again the solution recommended there was also using MTUs - and it did not work for me.I guessed something like this would have been resolved considering WSL2 has many users behind VPNs - but it appears its not a straightforward fix. When I was using Docker Desktop (before the licensing model changed) I did not see this issue - perhaps Docker had figured out a secret sauce to get this working with all VPNs.
Any recommendations and suggestions to get past the
httpsissue would be greatly appreciated. I am hoping this will be the last issue I may have to fix in WSL2 before its fully functional for my development needs.Just to add to the chorus here, I’m using WSL2 on Windows 10, and using Mozilla VPN. I was unable to update apt, checked around and started noticing my WSL2 Ubuntu install couldn’t ping out at all. Disabled the VPN, all working fine again. I can try the MTU solution too, but I’d prefer to find out if this there’s a WSL2 fix coming for this or if it’s expected behavior. I’m submitting a bug report to the Mozilla VPN crew too so they’re aware.
The “MTU fix” worked for me as well. Naturally, it would be best if this were automated. Is there an “official” solution by the WSL team, or an available script that changes the MTU when WSL is started based on the MTU setting of the VPN connection?
Works for me too! (Except my mtu was 1350.)
I am using checkpoint mobile VPN, and in addition to the mtu change, I have to 1) disable the wsl network interface before connecting to vpn, and 2) enable the interface after connection has been established.
sudo ip link set dev eth0 mtu 1420fixes it for me when running with WireGuard on WSL2 Ubuntu, thanks for the tip.There might be a way to make it stick due to some work on
systemdbeing done in https://github.com/microsoft/WSL/issues/994#issuecomment-698927438This has been a very helpful thread - thanks to everyone who contributed. After a ton of trial and error, I finally resolved my own connectivity issues by updating the /etc/resolv.conf file and updating the MTU setting on WSL2’s eth0 to match my VPN’s. In my case, this meant changing it from 1500 to 1396.
I do have one question, though. I understand that this setting gets reset and, as such, I’ve updated my .bashrc. This works great. However, I expected that I would need to change it back to 1500 when I am not using VPN. So far, I have not had to do that. I’ve tested this by downloading large files, cloning git repos, connecting to remote servers using SSH, etc. It seems to work perfectly fine when it’s always set to 1396.
Is it possible that this mismatch will cause issues at some point? I’m fine with changing the setting as needed, but it would be great if I can just leave it as-is and not have to change it when I sign on/off VPN.
It’s not a DNS issue for me (Cisco), can’t reach anything by IP either:
@NiklasBr I’m also using Cisco AnyConnect for connecting windows to vpn. If you find a solution, please post here. Thank you.
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:
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 😃 ):
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.