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:

  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.

About this issue

  • Original URL
  • State: closed
  • Created 7 years ago
  • Reactions: 118
  • Comments: 135 (2 by maintainers)

Most upvoted comments

A simple fix for me was to set MTU to 1350 (same as VPN interface): sudo ifconfig eth0 mtu 1350

Even SSH connections are more stable now.

thank you @earljon .

This is my solution for:

Pulse Secure VPN

  1. PowerShell: netsh interface ipv4 show subinterface
  2. WSL2: ip link list
  3. WSL2: sudo ip link set dev eth0 mtu 1400

Notes

  1. I ran this after successfully connected to the VPN. I noticed an extra Local Area Connection* with an MTU value ~100 less than the other “Local Area Connection” entries. That’s the value I wanted.
  2. Inside WSL2, check what your eth0 mtu value is set to. It was not the MTU value discovered in Step 1.
  3. Inside WSL2, set the MTU value of the interface eth0 to the value discovered in Step 1.
  4. HTTPS IS NOW WORKING 🎉

This is my solution for:

Pulse Secure VPN

  1. PowerShell: netsh interface ipv4 show subinterface
  2. WSL2: ip link list
  3. WSL2: sudo ip link set dev eth0 mtu 1400

Notes

  1. I ran this after successfully connected to the VPN. I noticed an extra Local Area Connection* with an MTU value ~100 less than the other “Local Area Connection” entries. That’s the value I wanted.
  2. Inside WSL2, check what your eth0 mtu value is set to. It was not the MTU value discovered in Step 1.
  3. Inside WSL2, set the MTU value of the interface eth0 to the value discovered in Step 1.
  4. HTTPS IS NOW WORKING 🎉

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 subinterface

# powershell on Windows
PS > netsh interface ipv4 show subinterface

   MTU  MediaSenseState   Bytes In  Bytes Out  Interface
------  ---------------  ---------  ---------  -------------
4294967295                1          0     747508  Loopback Pseudo-Interface 1
  1500                1  2244351051  1452619074  Wi-Fi
  1500                5          0          0  Cellular
  1500                5          0          0  Bluetooth Network Connection
  1500                5          0          0  Ethernet
  1500                5          0          0  Ethernet 3
  1392                5          0          0  Ethernet 4
  1500                5          0          0  Local Area Connection* 1
  1500                5          0          0  Local Area Connection* 2
# ↓↓↓↓ here's my actual VPN MTU config
  1200                1  1845392493  1251827749  My VPN setup
# ↑↑↑↑
  1500                5          0          0  Ethernet 2
  1500                1          0    7931843  vEthernet (Default Switch)
  1500                1   38626057   38625717  vEthernet (Ethernet 3)
  1500                1    3007499  116996182  vEthernet (WSL)
  1500                1   38626627   38626517  vEthernet (Ethernet)
  1500                1    7944342    7923059  vEthernet (Ethernet 4)
  1500                1    7938322    7919906  vEthernet (Ethernet 2)
  1500                1   18285484   18286252  vEthernet (Cellular)
  1500                1    7924600    7909471  vEthernet (Wi-Fi)
  1500                1    7875089    7865975  vEthernet (My VPN setup)

Then I could follow the tip by @neseih (but with the ip command instead)

# bash inside my WSL 2
$ sudo ip link set eth0 mtu 1200

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?

A simple fix for me was to set MTU to 1350 (same as VPN interface): sudo ifconfig eth0 mtu 1350

Even SSH connections are more stable now.

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 :

Get-NetAdapter | Where-Object {$_.InterfaceDescription -Match "Check"}

Name                      InterfaceDescription                    ifIndex Status                   LinkSpeed
----                      --------------------                    ------- ------                  ---------
Ethernet 3                Check Point Virtual Network Adapter Fo…       8 Up                   1 Gbps

Note the index of the connection, then run below statement. Match the index found above in below result and note the mtu.

netsh.exe interface ipv4 show interfaces

Idx     Met         MTU          State                Name
---  ----------  ----------  ------------  ---------------------------
  1          75  4294967295  connected     Loopback Pseudo-Interface 1
 24          35        1500  connected     Wi-Fi
 16          25        1500  disconnected  Local Area Connection* 1
 10           5        1500  disconnected  Ethernet 2
  5          25        1500  disconnected  Local Area Connection* 2
 17          65        1500  disconnected  Bluetooth Network Connection
 38          15        1500  connected     vEthernet (Default Switch)
 59          15        1500  connected     vEthernet (WSL)
  8           0        1350  connected     Ethernet 3

Not you have the mtu value… Login into your wsl and run below statement(1350 is the mtu found above): sudo ifconfig eth0 mtu 1350

You 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 1350

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.

@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.

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_probing

For the reference, here is the documentation for this kernel setting (source)

tcp_mtu_probing - INTEGER
	Controls TCP Packetization-Layer Path MTU Discovery.  Takes three
	values:
	  0 - Disabled
	  1 - Disabled by default, enabled when an ICMP black hole detected
	  2 - Always enabled, use initial MSS of tcp_base_mss.

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. …

@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.

PowerShell: netsh interface ipv4 show subinterface # find MTU of VPN interface (e.g. 1400) WSL2: ip link list WSL2: sudo ip link set dev eth0 mtu 1400

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 1400 works 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 update fails with:

Temporary failure resolving ‘deb.debian.org’

What works:

  • Turning off VPN
  • Switching back to WSL 1

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.json curl: (6) Could not resolve host: packages.drupal.org

Solution: (Within WSL)

  1. cd /etc/
  2. sudo chattr -i resolv.conf
  3. rm -r resolv.conf
  4. sudo echo 'nameserver 1.1.1.1' >resolv.conf
  5. sudo chattr +i resolv.conf
  6. sudo echo -e '[network] \ngenerateResolvConf = false' >> /etc/wsl.conf

2nd 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.json was timing out at the same spot.

This really is the weirdest thing, because some HTTPS handshakes work from WSL2 while I’m on the VPN, like so:

$ curl -vvv -sIXGET https://www.apple.com/                                                                                                                                                                                                                                
*   Trying 23.63.229.217:443...                                                                                                                                                                                                                                              
* TCP_NODELAY set                                                                                                                                                                                                                                                            
* Connected to www.apple.com (23.63.229.217) port 443 (#0)                                                                                                                                                                                                                   
* ALPN, offering h2                                                                                                                                                                                                                                                          
* ALPN, offering http/1.1                                                                                                                                                                                                                                                    
* successfully set certificate verify locations:                                                                                                                                                                                                                             
*   CAfile: /etc/ssl/certs/ca-certificates.crt                                                                                                                                                                                                                                 
CApath: /etc/ssl/certs                                                                                                                                                                                                                                                     
* TLSv1.3 (OUT), TLS handshake, Client hello (1):                                                                                                                                                                                                                            
* TLSv1.3 (IN), TLS handshake, Server hello (2):                                                                                                                                                                                                                             
* TLSv1.3 (IN), TLS handshake, Encrypted Extensions (8):                                                                                                                                                                                                                     
* TLSv1.3 (IN), TLS handshake, Certificate (11):                                                                                                                                                                                                                             
* TLSv1.3 (IN), TLS handshake, CERT verify (15):                                                                                                                                                                                                                             
* TLSv1.3 (IN), TLS handshake, Finished (20):                                                                                                                                                                                                                                
* TLSv1.3 (OUT), TLS change cipher, Change cipher spec (1):                                                                                                                                                                                                                  
* TLSv1.3 (OUT), TLS handshake, Finished (20):                                                                                                                                                                                                                               
* SSL connection using TLSv1.3 / TLS_AES_256_GCM_SHA384                                                                                                                                                                                                                      
* ALPN, server accepted to use h2                                                                                                                                                                                                                                            
* Server certificate:                                                                                                                                                                                                                                                        
*  subject: businessCategory=Private Organization; jurisdictionC=US; jurisdictionST=California; serialNumber=C0806592; C=US; ST=California; L=Cupertino; O=Apple Inc.; OU=Internet Services for Akamai; CN=www.apple.com                                                      
*  start date: Oct 24 00:00:00 2019 GMT                                                                                                                                                                                                                                      
*  expire date: Oct 23 12:00:00 2020 GMT                                                                                                                                                                                                                                     
*  subjectAltName: host "www.apple.com" matched cert's "www.apple.com"                                                                                                                                                                                                       
*  issuer: C=US; O=DigiCert Inc; OU=www.digicert.com; CN=DigiCert SHA2 Extended Validation Server CA                                                                                                                                                                         
*  SSL certificate verify ok.                                                                                                                                                                                                                                                
* Using HTTP2, server supports multi-use                                                                                                                                                                                                                                     
* Connection state changed (HTTP/2 confirmed)                                                                                                                                                                                                                                
* Copying HTTP/2 data in stream buffer to connection buffer after upgrade: len=0                                                                                                                                                                                             
* Using Stream ID: 1 (easy handle 0x55cfbe9437c0)                                                                                                                                                                                                                            
> GET / HTTP/2                                                                                                                                                                                                                                                               
> Host: www.apple.com                                                                                                                                                                                                                                                        
> user-agent: curl/7.68.0                                                                                                                                                                                                                                                    
> accept: */*                                                                                                                                                                                                                                                                
>                                                                                                                                                                                                                                                                            
* TLSv1.3 (IN), TLS handshake, Newsession Ticket (4):                                                                                                                                                                                                                        
* TLSv1.3 (IN), TLS handshake, Newsession Ticket (4):                                                                                                                                                                                                                        
* old SSL session ID is stale, removing                                                                                                                                                                                                                                      
* Connection state changed (MAX_CONCURRENT_STREAMS == 100)!                                                                                                                                                                                                                  
< HTTP/2 200                                                                                                                                                                                                                                                                  

and

$ curl -vvv -sIXGET https://icanhazip.com/
*   Trying 116.202.244.153:443...
* TCP_NODELAY set
* Connected to icanhazip.com (116.202.244.153) port 443 (#0)
* ALPN, offering h2
* ALPN, offering http/1.1
* successfully set certificate verify locations:
*   CAfile: /etc/ssl/certs/ca-certificates.crt
  CApath: /etc/ssl/certs
* TLSv1.3 (OUT), TLS handshake, Client hello (1):
* TLSv1.3 (IN), TLS handshake, Server hello (2):
* TLSv1.2 (IN), TLS handshake, Certificate (11):
* TLSv1.2 (IN), TLS handshake, Server key exchange (12):
* TLSv1.2 (IN), TLS handshake, Server finished (14):
* TLSv1.2 (OUT), TLS handshake, Client key exchange (16):
* TLSv1.2 (OUT), TLS change cipher, Change cipher spec (1):
* TLSv1.2 (OUT), TLS handshake, Finished (20):
* TLSv1.2 (IN), TLS handshake, Finished (20):
* SSL connection using TLSv1.2 / ECDHE-RSA-AES256-GCM-SHA384
* ALPN, server accepted to use h2
* Server certificate:
*  subject: CN=icanhazip.com
*  start date: Apr 27 12:23:46 2020 GMT
*  expire date: Jul 26 12:23:46 2020 GMT
*  subjectAltName: host "icanhazip.com" matched cert's "icanhazip.com"
*  issuer: C=US; O=Let's Encrypt; CN=Let's Encrypt Authority X3
*  SSL certificate verify ok.
* Using HTTP2, server supports multi-use
* Connection state changed (HTTP/2 confirmed)
* Copying HTTP/2 data in stream buffer to connection buffer after upgrade: len=0
* Using Stream ID: 1 (easy handle 0x564d363bf7c0)
> GET / HTTP/2
> Host: icanhazip.com
> user-agent: curl/7.68.0
> accept: */*
>
* Connection state changed (MAX_CONCURRENT_STREAMS == 128)!
< HTTP/2 200

But others, like the Microsoft sample related above do not:

$ curl -vvv -sIXGET https://packages.microsoft.com/ubuntu/18.04/prod
*   Trying 40.117.131.251:443...
* TCP_NODELAY set
* Connected to packages.microsoft.com (40.117.131.251) port 443 (#0)
* ALPN, offering h2
* ALPN, offering http/1.1
* successfully set certificate verify locations:
*   CAfile: /etc/ssl/certs/ca-certificates.crt
  CApath: /etc/ssl/certs
* TLSv1.3 (OUT), TLS handshake, Client hello (1):

* OpenSSL SSL_connect: Connection reset by peer in connection to packages.microsoft.com:443
* Closing connection 0

But HTTPS connections to all three of these work from the Windows host when on the VPN.

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:

  1. Figure out the MTU of your VPN. C:\WINDOWS\system32>netsh interface ipv4 show subinterface Mine was 1420. Everything else was set to 1500.

  2. In WSL, See your network interfaces with ifconfig. set the eth0 interface to match the VPN’s MTU value. sudo ifconfig eth0 mtu 1420

In my case it was an MTU issue and sudo ifconfig eth0 mtu 1400 fixed outbound traffic for me.

@smerrill That was a great catch.

After seeing the TLSv1.3 to TLSv1.2 change in your icanhazip.com log, 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.com doesn’t support TLS v1.3, so handshake doesn’t work. Interestingly, apple.com doesn’t support TLS v1.3 and doesn’t work; but www.apple.com supports v1.3 and works. Btw, for me icanhazip.com didn’t work either, because it doesn’t support v1.3.

I also tried to force curl to use v1.2 by setting --tlsv1.2 and --tls-max 1.2 parameters, but it didn’t work:

curl --tlsv1.2 --tls-max 1.2 -vvv -sIXGET https://packages.microsoft.com/ubuntu/18.04/prod
*   Trying 13.79.133.120...
* TCP_NODELAY set
* Connected to packages.microsoft.com (13.79.133.120) port 443 (#0)
* ALPN, offering h2
* ALPN, offering http/1.1
* successfully set certificate verify locations:
*   CAfile: /etc/ssl/certs/ca-certificates.crt
  CApath: /etc/ssl/certs
* TLSv1.2 (OUT), TLS handshake, Client hello (1):

# .... waits forever ...

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_probing

For the reference, here is the documentation for this kernel setting (source)

tcp_mtu_probing - INTEGER
	Controls TCP Packetization-Layer Path MTU Discovery.  Takes three
	values:
	  0 - Disabled
	  1 - Disabled by default, enabled when an ICMP black hole detected
	  2 - Always enabled, use initial MSS of tcp_base_mss.

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.

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_probing

For the reference, here is the documentation for this kernel setting (source)

tcp_mtu_probing - INTEGER
	Controls TCP Packetization-Layer Path MTU Discovery.  Takes three
	values:
	  0 - Disabled
	  1 - Disabled by default, enabled when an ICMP black hole detected
	  2 - Always enabled, use initial MSS of tcp_base_mss.

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

$ sudo sysctl -w net.ipv4.tcp_mtu_probing=1 

For reference see: https://lists.ubuntu.com/archives/ubuntu-devel-discuss/2012-February/013198.html

This is my solution for:

Pulse Secure VPN

  1. PowerShell: netsh interface ipv4 show subinterface
  2. WSL2: ip link list
  3. WSL2: sudo ip link set dev eth0 mtu 1400

Notes

  1. I ran this after successfully connected to the VPN. I noticed an extra Local Area Connection* with an MTU value ~100 less than the other “Local Area Connection” entries. That’s the value I wanted.
  2. Inside WSL2, check what your eth0 mtu value is set to. It was not the MTU value discovered in Step 1.
  3. Inside WSL2, set the MTU value of the interface eth0 to the value discovered in Step 1.
  4. HTTPS IS NOW WORKING 🎉

Thank you! This worked for me.

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

  1. Add to ~/.bashrc or ~/.zshrc or ~/.profile sudo ip link set dev eth0 mtu 1400
  2. Restart Terminal

Adding 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:

  1. WSL not using the VPN interface. A solution that might work is doing this in PS: Get-NetAdapter | Where-Object {$_.InterfaceDescription -Match “Cisco AnyConnect”} | Set-NetIPInterface -InterfaceMetric 6000 . You can check if this works by going to your linux account and trying to ping an IP directly.
  2. DNS resolution. If #1 solved the issue, you still might find that DNS resolution is not changed. Fro that, you need to modify /etc/resolv.conf and add nameserver <CORP DNS SERVER>
  3. If both of the above dont work, you still need to fix MTU size mismatch. This is changed by using sudo ifconfig eth0 mtu 1350 , wheer 1350 is a similar value to what you see by running .\netsh.exe interface ipv4 show interfaces

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 ver and 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.

When connected using NordVPN, I get very slow or no internet connectivity when using WSL2.0

Resolution for NordVPN

1. Add to ~/.bashrc or ~/.zshrc or ~/.profile `sudo ip link set dev eth0 mtu 1400`

2. Restart Terminal

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 1400 solution worked like a charm, it now works perfectly. I can’t believe it but finally there we go 😃

I would add it to my ~/.bashrc or ~/.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

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:

1. WSL not using the VPN interface. A solution that might work is doing this in PS: Get-NetAdapter | Where-Object {$_.InterfaceDescription -Match "Cisco AnyConnect"} | Set-NetIPInterface -InterfaceMetric 6000 . You can check if this works by going to your linux account and trying to ping an IP directly.

2. DNS resolution. If #1 solved the issue, you still might find that DNS resolution is not changed. Fro that, you need to modify  /etc/resolv.conf and add nameserver

3. If both of the above dont work, you still need to fix MTU size mismatch. This is changed by using sudo ifconfig eth0 mtu 1350 , wheer 1350 is a similar value to what you see by running .\netsh.exe interface ipv4 show interfaces

@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 .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.

sudo ifconfig eth0 mtu 1350

This actually solved the issue for me. I don’t even use a VPN and it started happening to me since about a week ago.

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.

Going to post this in a few of the longer running threads. Long story short, the AnyConnect fix for this issue is available. The fix requires two pieces, an update to the client of version 4.10.01075 or later and a new custom attribute in the ASDM. Links to info below:

Release Notes Admin Document Troubleshooting Section that describes the custom attribute that needs to be set up by the VPN adminstrator.

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:

image

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

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.

@craigloewen-msft do you know if networkingMode=mirrored will 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 1400 but after run ip addr again, it is still in 1500

Tested using Windows 11 + wsl1 + ubuntu 20.04

When connected using NordVPN, I get very slow or no internet connectivity when using WSL2.0 Resolution for NordVPN

1. Add to ~/.bashrc or ~/.zshrc or ~/.profile `sudo ip link set dev eth0 mtu 1400`

2. Restart Terminal

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;

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 work

is 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.conf to point to our local DNS server - and also setup CNTLM for authentication. I added the proxy for http and https via localhost:3128 to my .bashrc and /etc/apt/apt.conf files.

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 http resources are accessible and any https results in errors. I see following issues when I try to apt update using repositories with https URLs.

wsluser@dockerhost:~$ sudo apt update Ign:1 https://download.docker.com/linux/ubuntu focal InRelease Err:3 https://download.docker.com/linux/ubuntu focal Release Could not handshake: Error in the pull function. [IP: 127.0.0.1 3128] E: The repository ‘https://download.docker.com/linux/ubuntu focal Release’ no longer has a Release file. N: Updating from such a repository can’t be done securely, and is therefore disabled by default. N: See apt-secure(8) manpage for repository creation and user configuration details.

Similar SSL/TLS handshake issues when trying to git clone using any https URLs from GitHub.

wsluser@dockerhost:~$ git clone https://github.com/containers/dnsname.git Cloning into ‘dnsname’… fatal: unable to access ‘https://github.com/containers/dnsname.git/’: gnutls_handshake() failed: Error in the pull function.

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.

anyconnect

preferences

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_handshake issue - 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 https issue 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 1420 fixes 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 systemd being done in https://github.com/microsoft/WSL/issues/994#issuecomment-698927438

This 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 was simply a DNS resolution issue.

It’s not a DNS issue for me (Cisco), can’t reach anything by IP either:

bild

@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: 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.