Vol. I · No. 46The protocol sectionSat, 10 Oct 2026
Layer 3 · Security · encryption below the application

IPsec

IP Security

IPsec encrypts at the network layer, so nothing above needs to know. It authenticates and encrypts whole IP packets, negotiating keys with IKE before any traffic passes — which is what lets two offices behave as one network across the public internet.

IPsec secures the packet rather than the connection — so every application above it is protected without being changed at all.

Operates at
Layer 3
Network
Protocols
ESP · AH
IP 50 · 51
Key exchange
IKEv2
UDP 500 · 4500
Modes
Tunnel · transport
site-to-site · host

How it works

The original packet, wrapped whole inside a new one
ESP in tunnel mode — what actually crosses the internet
New IP header
ESP header
Encrypted payload
ESP auth
inside the encryption: the original IP header + the original payload

In tunnel mode the entire original packet — addresses included — is encrypted and given a fresh outer header addressed gateway to gateway. An observer sees two gateways talking, and nothing about who is really behind them.

The main points

What IPsec does, step by step

1
Negotiate with IKE

IKEv2 authenticates the peers, by certificate or pre-shared key, and derives keys over UDP 500.

2
Establish the SAs

A pair of security associations is set up — one per direction — each with its own keys and parameters.

3
Protect every packet

ESP encrypts and authenticates each packet; AH authenticates only, and is rarely used now.

4
Rekey and tear down

SAs expire on time or volume and are rekeyed; DPD notices when the far end has gone away.

The pieces
ESP — encrypt + authenticate — the one you want
AH — authenticate only; NAT breaks it
IKEv2 — the modern key exchange
Tunnel mode — site to site, whole packet
Transport mode — host to host, payload only
NAT-T — ESP inside UDP 4500

In cybersecurity

IPsec is strong cryptography with a great many knobs — most real failures are not breaks but weak pre-shared keys and obsolete algorithms left enabled.

Pre-shared key weakness

IKEv1 aggressive mode with a PSK can be captured and cracked offline — use certificates or EAP.

Retire old crypto

DES, 3DES, MD5 and DH groups 1, 2 and 5 should all be off; use AES-GCM and a modern group.

IKEv1 is legacy

IKEv2 is simpler, faster to rekey and has fewer footguns — migrate where you can.

AH and NAT

AH authenticates the outer header, so any NAT on the path breaks it; ESP with NAT-T is the answer.

Perfect forward secrecy

Enable PFS on rekey so one compromised key doesn’t unlock previously captured traffic.

Tunnel ≠ authorisation

A site-to-site tunnel joins two networks; what may cross it is still a firewall’s decision.

Rides in the stack

IPIPsecthe original packet

Unlike TLS it is not carried by a transport — ESP is an IP protocol in its own right, wrapping packets rather than streams.

Works with

IPv4IPv6

IPsec or TLS?

TLSIPsec
ProtectsOne connectionEvery packet
Apps mustUse itKnow nothing
Typical useClient to serverSite to site
Sees addressesYesNo, in tunnel mode