HQ firewall (WAN 203.0.113.1, LAN 10.10.0.0/16) and Branch firewall (WAN 198.51.100.1, LAN 10.20.0.0/16) share a pre-configured PSK and matching IKE/IPsec policy. No tunnel exists yet.
SetupA server at HQ (10.10.5.10) sends a packet toward a branch server (10.20.8.20). It matches the firewall's defined "interesting traffic" — the subnet pair this VPN policy is meant to protect. Since no active Security Association exists yet, the firewall holds the packet and initiates IKE negotiation toward 198.51.100.1 before it can forward anything.
TriggerThe two firewalls negotiate an ISAKMP/IKE SA — agreeing on the encryption algorithm (e.g. AES-256), hash (SHA-256), Diffie-Hellman group, and authentication method that will protect the negotiation itself. Nothing about the real data traffic is discussed yet; this phase exists purely to build a secure channel to negotiate in.
Phase 1Both firewalls exchange DH public values over the open internet and each independently computes the same shared secret — without that secret ever being transmitted. Every key used for the rest of Phase 1 is derived from this shared value.
DHEach side proves it's who it claims to be. With a pre-shared key, each firewall computes a keyed hash using the PSK and proves it without ever sending the PSK itself. If the PSKs don't match on both sides, this step fails outright and the tunnel never comes up — the single most common cause of a site-to-site VPN that simply won't establish.
AuthAn authenticated, encrypted ISAKMP/IKE SA now exists between the two firewalls. No user data has moved yet — this channel exists solely to negotiate the real, data-carrying tunnel in the next phase. "Phase 1 is up" and "the VPN is working" are not the same claim.
CheckpointInside the protected Phase 1 channel, the firewalls run Quick Mode to negotiate the actual IPsec parameters: encryption/integrity algorithms for real traffic, optionally a fresh Diffie-Hellman exchange for Perfect Forward Secrecy, and — critically — the traffic selectors (proxy IDs): exactly which subnets this tunnel covers. 10.10.0.0/16 ↔ 10.20.0.0/16 must be configured identically on both ends, or this phase fails even though Phase 1 succeeded.
Phase 2Two unidirectional IPsec SAs are installed — one HQ→Branch, one Branch→HQ — each with its own SPI (Security Parameter Index) and its own derived encryption/authentication keys. These SA database entries are what every subsequent packet gets matched against.
SA / SPIHQ's original packet (10.10.5.10 → 10.20.8.20) now matches the installed SA. It's wrapped in an ESP header, encrypted and authenticated with the SA's keys, and given a new outer IP header — source 203.0.113.1, destination 198.51.100.1 — then sent out onto the internet like any other WAN packet.
ESPThe branch firewall receives the ESP packet, reads the SPI to look up the matching inbound SA, and decrypts/verifies it with that SA's key. Stripping the outer header leaves the original, untouched inner packet: 10.10.5.10 → 10.20.8.20.
DecryptThe branch firewall routes the now-plaintext inner packet normally — a completely ordinary routing decision toward 10.20.8.20 on its internal network. From the receiving server's point of view, this looks exactly like any other packet from a remote subnet.
RouteThe reply uses the Branch→HQ SA installed in step 8, encapsulated and decrypted the same way in reverse. SAs carry a lifetime (time- and/or traffic-based); before expiry, IKE transparently rekeys — negotiating fresh keys without tearing the tunnel down — so a long-lived site-to-site VPN doesn't restart Phase 1/Phase 2 from scratch on every renewal.
Steady| Term | Meaning |
|---|---|
| IKE | Internet Key Exchange — the protocol that negotiates and manages the SAs used by IPsec |
| Phase 1 (Main Mode) | Negotiates and authenticates a secure channel used only to protect further negotiation |
| Phase 2 (Quick Mode) | Negotiates the actual IPsec SAs that will encrypt real data traffic |
| SA | Security Association — an agreed set of algorithms, keys, and parameters for one direction of protected traffic |
| SPI | Security Parameter Index — an identifier in each ESP packet used to look up which SA to decrypt with |
| ESP | Encapsulating Security Payload — the IPsec protocol that encrypts and authenticates the actual data |
| Traffic Selector / Proxy ID | The subnet pair defining which traffic a given IPsec SA covers — must match exactly on both peers |
| PFS | Perfect Forward Secrecy — a fresh DH exchange per Phase 2 negotiation so past sessions stay safe if a key leaks later |
| NAT-T | NAT Traversal — wraps ESP in UDP/4500 so IPsec can survive a NAT device between the peers |
| Rekey | Renegotiating fresh SA keys before the current SA's lifetime expires, without dropping the tunnel |