Terminating an IPSec tunnel,

Unanswered Question
Feb 10th, 2008
User Badges:

Hi every1, if i want to terminate an IPsec session forcefully after a specified amount of time like 5 hours what command do i need? i am using simple site to site vpn between 2 sites, i want the ipsec tunnel to be terminated so that the counters in show crypto ipsec sa equals to zero..


  • 1
  • 2
  • 3
  • 4
  • 5
Overall Rating: 0 (0 ratings)
JORGE RODRIGUEZ Sun, 02/10/2008 - 23:44
User Badges:
  • Green, 3000 points or more

you can use clear crypto sa counters

Quote !!

The counters keyword simply clears the traffic counters maintained for each security association; it does not clear the security associations themselves.

more command deatails and explanation here




illusion_rox Mon, 02/11/2008 - 00:56
User Badges:

Sorry i forgot to mention AUTOMATICALLY, i want to ipsec tunnel ( phase 2 ) to be terminated automatically after very 5 hours.


manufc Mon, 02/11/2008 - 01:08
User Badges:


Depending on your version of IOS, you can script commands using kron.


srue Mon, 02/11/2008 - 09:54
User Badges:
  • Blue, 1500 points or more

or set your ipsec lifetimes for five hours (18000seconds)...i don't know if this resets counters or not though.

illusion_rox Mon, 02/11/2008 - 20:25
User Badges:

hi srue, are you sure that ipsec lifetimes terminate the tunnel ?? coz i heard that it just re-authenticates the tunnel !! so kindly confirm me that it terminates the tunnel.


rkazmierczak Tue, 02/12/2008 - 04:51
User Badges:

There are 2 lifetimes though, for phase 1 and 2. They will terminate the tunnel but any interesting traffic will bring it up again of course.

srue Tue, 02/12/2008 - 10:41
User Badges:
  • Blue, 1500 points or more

How These Lifetimes Work

Assuming that the particular crypto map entry does not have lifetime values configured, when the router requests new security associations it will specify its global lifetime values in the request to the peer; it will use this value as the lifetime of the new security associations. When the router receives a negotiation request from the peer, it will use the smaller of either the lifetime value proposed by the peer or the locally configured lifetime value as the lifetime of the new security associations.

The security association (and corresponding keys) will expire according to whichever comes sooner, either after the number of seconds has passed (specified by the seconds keyword) or after the amount of traffic in kilobytes is passed (specified by the kilobytes keyword). Security associations that are established manually (via a crypto map entry marked as ipsec-manual) have an infinite lifetime.

A new security association is negotiated before the lifetime threshold of the existing security association is reached, to ensure that a new security association is ready for use when the old one expires. The new security association is negotiated either 30 seconds before the seconds lifetime expires or when the volume of traffic through the tunnel reaches 256 kilobytes less than the kilobytes lifetime (whichever comes first).

If no traffic has passed through the tunnel during the entire life of the security association, a new security association is not negotiated when the lifetime expires. Instead, a new security association will be negotiated only when IPSec sees another packet that should be protected.



This Discussion