Thursday, February 28, 2013

AnyConnect VPN dropping connection after 1-2 minutes

I ran into an issue recently regarding an unstable AnyConnect VPN connection from a laptop, through a DSL router (not mine), terminating at a Cisco ASA running IOS 9.1. The laptop, running Windows 8 (yes, I know), had AnyConnect 3.1 installed on it. The problem was the AnyConnect connection would connect every time, but after about 1 or 2 minutes, it would disconnect.

The logs in the ASA indicated that the user session was being terminated on the remote end:

%ASA-5-722037: Group User IP SVC closing connection: User Requested.
%ASA-6-716002: Group User IP WebVPN session terminated: User Requested.

I couldn't figure out why, as the laptop wasn't being manually disconnected by the user, and the logs on the laptop didn't provide any reason why either.  Also, I forgot to mention that the laptop would stay connected when plugged in to any other internet connection, whether my home high speed connection, 

Running the "show vpn-sessiondb anyconnect" command on the ASA would show the following output below.  Note the top one was my testing laptop that worked, the bottom connection was the problematic one, with the output caught within the 1-2 minute window before it disconnected.


ASA/pri/act#show vpn-sessiondb anyconnect 

Session Type: AnyConnect

Username     : USERA           Index        : 229
Assigned IP  : x.x.x.x             Public IP    : x.x.x.x
Protocol     : AnyConnect-Parent SSL-Tunnel DTLS-Tunnel
License      : AnyConnect Essentials
Encryption   : AnyConnect-Parent: (1)none  SSL-Tunnel: (1)DES  DTLS-Tunnel: (1)DES
Hashing      : AnyConnect-Parent: (1)none  SSL-Tunnel: (1)SHA1  DTLS-Tunnel: (1)SHA1
Bytes Tx     : 699061                 Bytes Rx     : 245379
Group Policy : GroupPolicy_VPN  Tunnel Group : VPN
Login Time   : 10:37:45 EST Tue Feb 26 2013
Duration     : 0h:41m:04s
Inactivity   : 0h:00m:00s
NAC Result   : Unknown
VLAN Mapping : N/A                    VLAN         : none

Username     : USERB           Index        : 236
Assigned IP  : x.x.x.x            Public IP    : x.x.x.x
Protocol     : AnyConnect-Parent SSL-Tunnel
License      : AnyConnect Essentials
Encryption   : AnyConnect-Parent: (1)none  SSL-Tunnel: (1)DES
Hashing      : AnyConnect-Parent: (1)none  SSL-Tunnel: (1)SHA1
Bytes Tx     : 59422                  Bytes Rx     : 36304
Group Policy : GroupPolicy_VPN   Tunnel Group : VPN
Login Time   : 11:15:31 EST Tue Feb 26 2013
Duration     : 0h:01m:18s
Inactivity   : 0h:00m:00s
NAC Result   : Unknown
VLAN Mapping : N/A                    VLAN         : none


This command actually led me to figuring out the solution.  The part where it says "DTLS-Tunnel" on the working connection, but not the bottom connection, was where the issue was.  See, the DSL router I was going through had an outbound filter setup to allow port 443/tcp only, NOT 443/udp.

After reading online about this, I learned that the AnyConnect SSL VPN connection first tries to connect over 443/tcp (TLS), then if successful, transitions over to 443/udp (DTLS).  The problem was the connection would establish, but since 443/udp was blocked, it would time out and terminate the connection.

In the ASA, I figured out the following command to run in order to disable the DTLS part of the connection, and force it to only use TLS, since that was what was open to me.

group-policy GroupPolicy_VPN attributes
 webvpn
  anyconnect ssl dtls none

Once I turned DTLS off in my group policy, the connection established and stayed up correctly after that.


The following text I found somewhere on Cisco's support forum site, linked here, which helped me figure out the issue.

The SSL-Tunnel is the TCP tunnel that is first created to the ASA. When it is fully established, the client will then try to negotiate a UDP DTLS-Tunnel. While the DTLS-Tunnel is being established, data can pass over the SSL-Tunnel. When the DTLS-Tunnel is fully established, all data now moves to the DTLS-tunnel and the SSL-tunnel is only used for occasional control channel traffic. If something should happen to UDP, the DTLS-Tunnel will be torn down and all data will pass through the SSL-Tunnel again.

The decision of how to send the data is very dynamic. As each network bound data packet is processed there is a point in the code where the decision is made to use either the SSL connection or the DTLS connection. If the DTLS connection is healthy at that moment, the packet is sent via the DTLS connection. Otherwise it is sent via the SSL connection.

The SSL connection is established first and data is passed over this connection while attempting to establish a DTLS connection. Once the DTLS connection has been established, the decision point in the code described above just starts sending the packets via the DTLS connection instead of the SSL connection. Control packets, on the other hand, always go over the SSL connection.

The key point is if the connection is considered healthy. If DTLS, an unreliable protocol, is in use and the DTLS connection has gone bad for whatever reason, the client does not know this until Dead Peer Detection (DPD) occurs. Therefore, data will be lost over the DTLS connection during that short period of time because the connection is still considered healthy. Once DPD occurs, data will immediately be set via the SSL connection and a DTLS reconnect will happen.

The ASA will send data over the last connection it received data on. Therefore, if the client has determined that the DTLS connection is not healthy, and starts sending data over the SSL connection, the ASA will reply on the SSL connection. The ASA will resume use of the DTLS connection when data is received on the DTLS connection."

8 comments:

  1. This didn't work for me, but what did was removing the following configuration from the ASA webvpn attributes.

    group-policy AnyConnect_Policy attributes
    webvpn
    no anyconnect profiles value AC_Profile type user

    ReplyDelete
  2. It worked like a charm. Thanks so much for your post.

    ReplyDelete
  3. Really I enjoy your site with effective and useful information. It is included very nice post with a lot of our resources.thanks for share. i enjoy this post. 最好用的VPN

    ReplyDelete
  4. It is still very important to choose a reliable VPN. ExpressVPN is recommended. Although it is expensive, it is more worry-free to use.

    ReplyDelete
  5. VPNs are used more and more frequently, and work and study are inseparable. It is really important to choose a good software, recommend a professional website wallvpn

    ReplyDelete
  6. Most quality 好用的VPNs also include advanced security features like RAM-only servers (data is never stored on the hard drive)科学上网 and perfect forward secrecy (changes your encryption key to prevent future and past keys from being hacked) and come with cool extras like malware blockers and split-tunneling免费VPN.

    ReplyDelete