SA lifetimes

Lifetimes and rekeying

Lesson 12 of 20 · 11 min · Module 4: Keeping the tunnel up

A key that never changes protects more and more data, for longer and longer. IPsec replaces its keys on a timer, while the tunnel stays up.

Start this lesson →

Free. No installation: you write and run the code in your browser, and it is checked automatically.

By the end, you’ll be able to…

  • Explain why SAs are replaced on a timer
  • Choose sensible lifetimes for the IKE SA and the child SA
  • Predict how often each is rekeyed

The idea

Each SA has a lifetime. Before it ends, the gateways rekey: they negotiate a fresh SA and move the traffic to it. The child SA, which encrypts the data, is replaced often; one hour is typical. The IKE SA lasts longer; a day is typical. Reversing the two makes the gateways renegotiate everything every hour.

ike lifetime 28800
ipsec lifetime 1800

01Short for data, longer for IKE

The child SA keys encrypt every packet, so they are replaced more often. The IKE SA is used only for negotiation and can live longer. A child SA lifetime longer than the IKE SA lifetime has no benefit: when the IKE SA is renewed, its children are renewed with it.

02Lifetimes do not have to match

In IKEv2 the lifetime is not negotiated. Each gateway rekeys when its own timer runs out, so the side with the shorter value starts first. Different values work, but agreed values make the behaviour predictable. In IKEv1 the lifetimes are part of the negotiation and a mismatch can break phase 2.

03Lifetimes on real devices

All values are in seconds.

# FortiGate
config vpn ipsec phase1-interface
    edit "to-branch"
        set keylife 86400
    next
end
config vpn ipsec phase2-interface
    edit "to-branch-p2"
        set keylifeseconds 3600
    next
end

# Huawei USG
ike proposal 10
 sa duration 86400
ipsec sa global-duration time-based 3600

# Cisco IOS
crypto ikev2 profile BRANCH
 lifetime 86400
crypto ipsec security-association lifetime seconds 3600

Your turn

The two lifetimes on this tunnel were entered the wrong way round, and the gateways renegotiate the IKE SA every hour. Set them to the values the two administrators agreed: 86400 seconds (one day) for the IKE SA and 3600 seconds (one hour) for the child SA.

What the checks look for

  • The IKE SA lifetime is set to one day
  • The child SA lifetime is set to one hour
  • In a day there is one IKE rekey and 24 child SA rekeys
  • The tunnel carries the traffic between the offices
Try it in the editor →

Take this with you

Rekeying replaces keys without taking the tunnel down. A day for the IKE SA and an hour for the child SA is a common, sensible pair.

Go a little further

Set the child SA lifetime to 300 seconds and read the number of rekeys per day in the Output tab.

Learn VPN & IPsec Foundations for free

20 short lessons with real code and instant checks.

See the whole course →