What it means
IPsec protects traffic at the network layer, below the applications. Its main protocol is Encapsulating Security Payload (ESP). ESP encrypts each packet and adds an integrity value and a sequence number. A reader on the path learns nothing from the contents. A changed packet is discarded, and so is a replayed one when the receiver has replay protection on, which is the default. An older protocol, Authentication Header (AH), checks integrity and does not encrypt.
Each runs in one of two modes. Transport mode protects the payload and leaves the original IP header readable. Tunnel mode wraps the whole original packet and adds a new outer header that names only the two gateways. The keys come from a separate exchange, IKEv2, in which the two ends agree keys and authenticate each other before any data is protected. Between sites, ESP in tunnel mode is the usual choice.
See the idea / Networks
ESP in tunnel mode hides the whole original packet.
One antenna command crosses rented fiber between two gateways. See what is wrapped, what an observer sees, and where protection ends.
Meridian headquarters and Station South are joined by fiber rented from a carrier. A gateway at each end, hq-gateway and south-gateway, has already agreed keys with the other using the IKEv2 protocol. They use ESP, the IPsec protocol that encrypts and integrity-protects packets, with the cipher AES-256-GCM. An SPI is the number that tells the receiver which keys apply. A console at headquarters sends one command to the antenna controller, ant-ctl-2.
01 / 04
Original
The console sends a command to ant-ctl-2. The packet reaches hq-gateway unprotected: its addresses and contents are readable.
More about this step
Inside headquarters the packet is ordinary. Its IP header names the console as source and ant-ctl-2 as destination. The gateway is configured to protect everything bound for the Station South network.
Step through at your own pace.
Keep in mindKey agreement happened before this picture. Protection covers the path between the two gateways only. Before hq-gateway and after south-gateway the packet travels as it was sent. An observer still learns that the gateways are talking, how much, and when. The AH protocol and transport mode are not shown. Host names stand in for addresses.
Read the visual, step by step
- Original. The console sends a command to ant-ctl-2. The packet reaches hq-gateway unprotected: its addresses and contents are readable. Inside headquarters the packet is ordinary. Its IP header names the console as source and ant-ctl-2 as destination. The gateway is configured to protect everything bound for the Station South network.
- Wrap. hq-gateway encrypts the whole packet, header included. It adds an ESP header and a new outer header that names only the two gateways. This is tunnel mode. The ESP header, added by the IPsec protocol that encrypts and checks packets, carries the SPI, a number that tells the receiver which keys apply, and a sequence number that counts up from 1 for each packet. An integrity value over the ESP contents lets the receiver detect any change. The new outer IP header is outside that protection, because routers must read it.
- Cross. On the fiber, an observer sees hq-gateway talking to south-gateway with ESP. The console, ant-ctl-2 and the command are hidden. Meridian does not own the fiber, so it assumes someone is watching. The observer can read the outer header, the SPI and the sequence number, and can measure packet sizes and timing. The inner addresses and the payload are ciphertext. This is what Nyx saw in ten minutes of capture on the carrier side: two gateway addresses, an SPI on each packet, and encrypted bytes.
- Unwrap. south-gateway checks the sequence number and the integrity value, then decrypts. The original packet goes on to ant-ctl-2 as it was sent. A packet that fails the integrity check is discarded. With replay protection on, a sequence number already seen is discarded too, which stops a recorded command from being sent again. After decryption the packet is ordinary once more, so the zones and checks inside the station still have to do their job.
Key agreement happened before this picture. Protection covers the path between the two gateways only. Before hq-gateway and after south-gateway the packet travels as it was sent. An observer still learns that the gateways are talking, how much, and when. The AH protocol and transport mode are not shown. Host names stand in for addresses.
Flow references: RFC 4303: IP Encapsulating Security Payload (ESP) · RFC 4301: Security Architecture for the Internet Protocol · RFC 7296: Internet Key Exchange Protocol Version 2
AN ILLUSTRATIVE SCENARIO
Two clinics and a shared records system
A health group links two clinics over a leased line so both can use one records system. The first design uses AH, because the supplier said it authenticates every packet. A review points out that anyone on the line could still read patient records. The group rebuilds the link with ESP in tunnel mode and certificate authentication between the gateways. A capture on the leased line then shows only the two gateway addresses and encrypted ESP packets.
Put it to work
- State what the link must provide: confidentiality, integrity, hidden internal addresses. Choose the protocol and mode from that list.
- Authenticate the two ends with certificates or a long random shared key, and use current algorithms such as AES-GCM.
- Remember where the tunnel ends. Plan the controls for traffic after the gateway unwraps it.
How to check your work
Capture on the unprotected side of the link while traffic flows. You should see only gateway addresses and ESP packets. Then break authentication on one side, for example with a revoked certificate, clear the existing security associations (SAs), and confirm traffic stops rather than flowing unprotected.
Connect the ideas
- VPN
An encrypted tunnel that carries traffic across a network you do not control, between a device and a gateway or between two gateways.
- Encryption
Transforming data so only holders of the appropriate key can read it, protecting confidentiality in transit or at rest.
- TLS
A protocol that encrypts and integrity-protects an application conversation and checks a certificate for a name.
- Integrity
The property that data and processes remain complete and unaltered except by authorized action.