In a distributed computing world where remote workers connect from untrusted coffee shop Wi-Fi and corporate data centers bridge across cloud regions, transmitting unencrypted data across the public internet is catastrophic. A Virtual Private Network (VPN) creates an encrypted, authenticated communications tunnel over an untrusted physical network, ensuring confidentiality, data integrity, and sender authentication.
IPsec (Internet Protocol Security) operates at Layer 3 (Network Layer), encrypting all protocols above it (TCP, UDP, ICMP). IPsec consists of two primary protocols and two operational modes:
| IPsec Component | Operational Functionality | Security Services Provided |
|---|---|---|
| Authentication Header (AH) | Calculates a cryptographic hash across the IP header and payload. | Provides Integrity & Authentication ONLY. Zero Encryption / No Confidentiality! |
| Encapsulating Security Payload (ESP) | Encrypts the packet payload using AES-GCM and appends authentication data. | Provides Confidentiality, Integrity, and Authentication. Industry standard! |
| Transport Mode | Encrypts only the IP payload; keeps the original IP header visible. | Used primarily for direct host-to-host communications on a private network. |
| Tunnel Mode | Encrypts the entire original IP packet and wraps it inside a brand new IP header. | Mandatory standard for Site-to-Site VPNs; hides internal subnet addressing. |
| Metric | IPsec (IKEv2) | OpenVPN | WireGuard |
|---|---|---|---|
| OSI Layer | Layer 3 (Network) | Layer 4 (Transport / SSL-TLS) | Layer 3 (Kernel module) |
| Codebase Size | 100,000+ lines of C code | 120,000+ lines of code | ~4,000 lines of code! |
| Cryptographic Primitives | Negotiable (supports legacy DES, 3DES, AES) | Negotiable via OpenSSL library | Opinionated Modern: ChaCha20, Poly1305, Curve25519, BLAKE2s |
| Performance & Speed | High (Kernel-level) | Moderate (User-space context switches) | Blazing Fast (Instant connection handshake) |
[Interface]
Address = 10.0.0.1/24
ListenPort = 51820
PrivateKey = aAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAA=
SaveConfig = true
[Peer]
PublicKey = bBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBB=
AllowedIPs = 10.0.0.2/32
Broaden your defensive and offensive security knowledge across our curriculum:
Diffie-Hellman key exchanges and symmetric encryption protecting VPN tunnels.
Configuring VPN endpoints behind NAT routers and stateful firewalls.
Comparing IPsec Layer 3 tunneling with OpenVPN/TLS Layer 4 encryption.
Exam questions comparing OpenVPN, WireGuard, and IPsec implementations.