Loading learning content...
VPN is not a single technology but an architecture built on various protocols that provide encryption, authentication, and encapsulation. The choice of VPN protocol affects everything: security strength, performance characteristics, firewall traversal capability, and operational complexity.
Networking professionals encounter a alphabet soup of VPN protocols: IPSec, IKE, ESP, AH, L2TP, PPTP, SSTP, OpenVPN, WireGuard, GRE. Understanding these protocols—what each does, how they relate to each other, and when to use which—is essential for designing secure, performant VPN deployments.
This page dissects the major VPN protocols in depth. We'll examine the IPSec protocol suite that dominates enterprise site-to-site VPN, the SSL/TLS-based solutions that excel at remote access, the modern WireGuard protocol that challenges established approaches, and legacy protocols you may encounter in existing deployments. By the end, you'll understand not just what these protocols do, but why they were designed as they were and how to choose appropriately among them.
By the end of this page, you will understand: IPSec's two-phase architecture and the difference between ESP and AH; how IKEv1 and IKEv2 negotiate security parameters; how SSL/TLS VPNs like OpenVPN work; WireGuard's cryptographic approach and operational model; legacy protocols like PPTP and L2TP; and criteria for selecting the right protocol for specific requirements.
IP Security (IPSec) is a framework of protocols that provides security services at the IP layer (Layer 3). Standardized by the IETF, IPSec is the dominant protocol for site-to-site VPN and a major option for remote access.
Why IPSec Operates at Layer 3
Operating at the network layer provides fundamental advantages:
IPSec Suite Components
IPSec is not a single protocol but a suite of protocols that work together:
IKE (Internet Key Exchange): Negotiates security parameters and establishes shared keys. Uses UDP port 500 (or 4500 with NAT-T).
ESP (Encapsulating Security Payload): Provides encryption, authentication, and integrity of payloads. IP Protocol 50.
AH (Authentication Header): Provides authentication and integrity (no encryption). IP Protocol 51. Rarely used today.
SA (Security Association): A logical connection defining security parameters between peers. Not a protocol but a critical concept.
NAT-T (NAT Traversal): Encapsulates ESP in UDP to traverse NAT devices. UDP port 4500.
These components work in concert: IKE negotiates SAs that define how ESP (or AH) will protect traffic.
Security Associations (SA)
A Security Association is the foundation of IPSec—a set of parameters that define how to protect traffic between peers:
SA Components:
SA Databases:
SA Direction:
IPSec Modes: Tunnel vs. Transport
Tunnel Mode:
Transport Mode:
Tunnel mode's encapsulation of the entire original packet is what makes VPN work: the original addresses (private IPs like 10.x.x.x) are hidden inside the encrypted payload, while the outer header shows only gateway addresses (public IPs). This allows private networks to communicate over public Internet without exposing internal addressing.
Internet Key Exchange (IKE) is the protocol that negotiates and establishes Security Associations for IPSec. It performs authenticated key exchange so that both peers share cryptographic keys without transmitting them over the network.
IKE Phases
Phase 1: IKE SA Establishment
Phase 1 creates a secure, authenticated channel between peers that protects Phase 2 negotiations:
The IKE SA has its own encryption and integrity keys, used to protect subsequent negotiations.
Phase 2: IPSec SA Establishment
Phase 2 negotiates the actual IPSec SAs that will protect user traffic:
IKEv1 vs. IKEv2
IKEv2 (RFC 7296) was developed to address IKEv1's complexity and limitations:
| Feature | IKEv1 | IKEv2 |
|---|---|---|
| Standards | Multiple RFCs, extensions | Single RFC 7296 |
| Messages (initial exchange) | 6-9 | 4 |
| NAT Traversal | Separate RFC, add-on | Built-in |
| Dead Peer Detection | Separate RFC, add-on | Built-in |
| Message reliability | None | Retransmission, sequencing |
| Multiple SA pairs | Complex | CHILD_SA exchanges |
| EAP authentication | Not supported | Supported |
| MOBIKE (mobility) | Not supported | Supported (RFC 4555) |
| DoS protection | Limited | Cookie challenge mechanism |
IKEv2 Exchange Flow
Initiator Responder
| |
|---------- IKE_SA_INIT Request ----------->| (DH, nonces, proposals)
|<--------- IKE_SA_INIT Response -----------| (DH, nonces, selected proposal)
| |
| [IKE SA established - encrypted from here]
| |
|---------- IKE_AUTH Request -------------->| (identity, auth, traffic selectors)
|<--------- IKE_AUTH Response --------------| (identity, auth, traffic selectors)
| |
| [IPSec CHILD_SA established]
| |
|<======== Encrypted User Traffic =========>|
Four messages complete initial setup (vs. 6-9 for IKEv1).
IKE Authentication Methods
Pre-Shared Key (PSK):
RSA/ECDSA Certificates:
EAP (Extensible Authentication Protocol) - IKEv2 only:
Perfect Forward Secrecy (PFS)
PFS performs additional Diffie-Hellman exchange during Phase 2:
Avoid DH Groups 1, 2, and 5 (768, 1024, 1536-bit MODP). Use Group 14 (2048-bit MODP) minimum, or preferably Group 19 (256-bit ECC), Group 20 (384-bit ECC), or Group 21 (521-bit ECC). Weak DH groups are vulnerable to attacks with nation-state resources.
Encapsulating Security Payload (ESP) (RFC 4303) is the IPSec protocol that actually protects user data. It provides confidentiality (encryption), data-origin authentication, and integrity.
ESP Packet Structure
ESP encapsulates the protected data with header and trailer fields:
| IP Header (new in tunnel mode) | ESP Header | Encrypted Payload | ESP Trailer | ESP Auth |
| (8 bytes)| | (variable) | (variable)|
ESP Header:
├─ Security Parameters Index (SPI): 32 bits - Identifies the SA
└─ Sequence Number: 32 bits - Anti-replay protection
ESP Trailer (encrypted with payload):
├─ Padding: 0-255 bytes - Block cipher alignment
├─ Pad Length: 8 bits
└─ Next Header: 8 bits - Protocol of encapsulated packet
ESP Authentication Data:
└─ ICV (Integrity Check Value): Variable (typically 96-256 bits)
What Gets Encrypted and Authenticated
|<-------- Encrypted -------->|
| IP Header | ESP Header | Payload | ESP Trailer | ICV |
|<----------- Authenticated ---------->|
ESP Encryption Algorithms
Recommended (Modern):
Legacy (Still Supported):
ESP Integrity Algorithms
When using AES-GCM or other AEAD:
When using non-AEAD encryption:
Anti-Replay Protection
ESP's sequence number field enables anti-replay:
Extended Sequence Numbers (ESN) provide 64-bit sequence numbers for high-speed links where 32-bit (4 billion packets) might wrap.
AES-GCM is the gold standard for ESP encryption. It provides authenticated encryption (encryption + integrity in one operation), has excellent performance (especially with Intel AES-NI), and is well-analyzed. Unless you have a specific reason otherwise, configure AES-256-GCM for ESP.
Authentication Header (AH) (RFC 4302) provides data-origin authentication and integrity protection without encryption. While largely superseded by ESP (which can provide authentication without encryption using NULL cipher), understanding AH is important for completeness and legacy systems.
AH Packet Structure
| IP Header | AH | Payload |
AH Fields:
├─ Next Header: 8 bits - Protocol of following header
├─ Payload Length: 8 bits - Length of AH in 32-bit words minus 2
├─ Reserved: 16 bits
├─ Security Parameters Index (SPI): 32 bits
├─ Sequence Number: 32 bits
└─ Integrity Check Value (ICV): Variable length
What AH Authenticates
AH authenticates more than ESP:
Mutable fields excluded:
AH vs. ESP Comparison
| Feature | AH | ESP |
|---|---|---|
| Confidentiality (encryption) | ❌ No | ✅ Yes |
| Data integrity | ✅ Yes | ✅ Yes |
| Data-origin authentication | ✅ Yes | ✅ Yes |
| Anti-replay protection | ✅ Yes | ✅ Yes |
| IP header authentication | ✅ Yes (immutable fields) | ❌ No (outer header) |
| Works with NAT | ❌ No (breaks auth) | ✅ Yes (with NAT-T) |
| IP protocol number | 51 | 50 |
| Typical overhead | ~24+ bytes | ~32-50+ bytes |
Why AH is Rarely Used Today
AH's primary distinguishing feature—IP header authentication—is also its fatal flaw in modern networks:
NAT Incompatibility: NAT devices modify IP addresses, breaking AH authentication. Since NAT is ubiquitous, AH is impractical for most deployments.
ESP Can Do Everything AH Can (Almost): ESP with NULL encryption provides integrity and authentication without confidentiality. The minor gap (IP header coverage) isn't worth NAT incompatibility.
Overhead Without Encryption Benefit: If you're going to add header overhead, you might as well encrypt.
When AH Might Still Be Seen
Practical Recommendation
Don't use AH. Use ESP with AES-GCM for encryption + authentication, or ESP with NULL cipher and HMAC-SHA-256 if you somehow need integrity without confidentiality. AH's NAT incompatibility makes it impractical for virtually all modern deployments.
AH was designed when IPSec was envisioned as a pervasive Internet security layer. The assumption was that NAT would be eliminated with IPv6 adoption. That prediction didn't materialize—NAT became more entrenched, IPv6 adoption remains incomplete, and ESP became the dominant IPSec protocol. AH remains in standards but is effectively deprecated in practice.
SSL/TLS VPN uses the same Transport Layer Security (TLS) protocol that secures HTTPS websites to create VPN tunnels. This approach offers significant advantages for remote access, particularly firewall traversal.
TLS VPN Architecture
SSL/TLS VPNs typically operate in one of two modes:
Full Tunnel Mode:
Clientless (Portal) Mode:
OpenVPN
OpenVPN is the most widely used open-source VPN solution:
Architecture:
Protocol Details:
Cisco AnyConnect
Cisco's enterprise SSL VPN solution:
Architecture:
Unique Features:
SSTP (Secure Socket Tunneling Protocol)
Microsoft's SSL VPN protocol built into Windows:
Architecture:
Characteristics:
SSL/TLS VPN vs. IPSec Comparison
| Aspect | SSL/TLS VPN | IPSec |
|---|---|---|
| OSI Layer | Session/Transport (Layer 5/4) | Network (Layer 3) |
| NAT Traversal | Excellent (uses HTTPS) | Requires NAT-T |
| Firewall Traversal | Excellent (TCP 443) | May be blocked |
| Performance | Good (TCP overhead) | Excellent |
| Native OS Support | Limited | Windows, iOS, macOS, Android |
| Clientless Mode | Yes (for web apps) | No |
| Enterprise Features | Rich | Rich |
When SSL VPN uses TCP transport (TLS over TCP), and the encapsulated traffic is also TCP, two layers of TCP congestion control interact negatively. Packet loss triggers retransmission at both layers, causing "TCP meltdown." This is why OpenVPN and AnyConnect prefer UDP/DTLS when possible. Use TCP transport only when UDP is blocked.
WireGuard is a modern VPN protocol that has gained significant traction due to its simplicity, performance, and cryptographic elegance. Designed by Jason Donenfeld, WireGuard takes a fundamentally different approach from IPSec and OpenVPN.
Design Philosophy
WireGuard was designed with several principles:
Simplicity: ~4,000 lines of code (vs. 100,000+ for OpenVPN or IPSec implementations). Small codebase is easier to audit.
Modern Cryptography: Uses only state-of-the-art primitives—no algorithm negotiation or legacy support.
Protocol Silence: Doesn't respond to unauthenticated packets, making it invisible to network scanners.
Roaming: Handles endpoint address changes seamlessly.
Minimal State: Stateless operation where possible, reducing attack surface.
Cryptographic Primitives
WireGuard uses a fixed cryptographic suite (no negotiation):
No cipher suite negotiation means:
WireGuard Configuration Model
WireGuard configuration is remarkably simple:
[Interface]
PrivateKey = <base64-encoded private key>
Address = 10.200.200.1/24
ListenPort = 51820
[Peer]
PublicKey = <base64-encoded public key of peer>
AllowedIPs = 10.200.200.2/32
Endpoint = peer.example.com:51820
Key Concepts:
Cryptokey Routing
WireGuard's "AllowedIPs" serves dual purpose:
This elegant design replaces complex routing configuration with simple association of IP ranges to public keys.
Performance Characteristics
Enterprise Considerations
WireGuard was designed for simplicity, which means some enterprise features are external:
Tailscale, Netmaker, NetBird, and other solutions build enterprise features on WireGuard. They add identity management, ACLs, automatic key distribution, and monitoring while preserving WireGuard's performance advantages. These make WireGuard practical for enterprise deployment where pure WireGuard would be too manual to manage.
Several VPN protocols, while still encountered in some environments, are considered legacy or deprecated. Understanding these is important for migration planning and security assessments.
PPTP (Point-to-Point Tunneling Protocol)
PPTP was developed by Microsoft and widely deployed in the 1990s-2000s:
Architecture:
Security Problems:
PPTP should never be used. It is fundamentally insecure, with practical attacks publicly demonstrated. Any remaining PPTP deployments should be migrated immediately.
L2TP/IPSec
Layer 2 Tunneling Protocol (L2TP) combined with IPSec:
Architecture:
Characteristics:
| Protocol | Security Status | Known Weaknesses | Recommendation |
|---|---|---|---|
| PPTP | 🔴 Broken | MS-CHAPv2 crackable, RC4 weak | Never use; migrate immediately |
| L2TP/IPSec (IKEv1 PSK) | 🟡 Weak | Aggressive mode PSK vulnerable | Migrate to IKEv2 or modern VPN |
| L2TP/IPSec (IKEv2) | 🟢 Acceptable | Overhead, complexity | Acceptable, prefer IKEv2 native |
| IKEv1 (non-PSK) | 🟡 Legacy | Complex, extension-dependent | Migrate to IKEv2 |
| OpenVPN 2.4+ | 🟢 Good | None significant | Recommended open-source option |
| IKEv2 + ESP/AES-GCM | 🟢 Excellent | None | Recommended standard |
| WireGuard | 🟢 Excellent | None; newer, less deployment history | Excellent for new deployments |
L2TP/IPSec Security Considerations
L2TP/IPSec security varies significantly by configuration:
Weak Configuration:
Acceptable Configuration:
The protocol itself isn't broken, but legacy deployments often use weak parameters. Certificate-based IKEv2 with modern crypto is secure but has significant configuration complexity and overhead compared to alternatives.
GRE (Generic Routing Encapsulation)
GRE is a tunneling protocol without inherent security:
GRE itself is not a VPN security protocol—it's an encapsulation mechanism.
Migration Recommendations
From PPTP:
From L2TP/IPSec:
If you discover PPTP still in use in your environment, treat it as a security incident. Tools to crack MS-CHAPv2 are publicly available. An attacker with network access can capture the handshake and recover the user's password in hours. Replace PPTP with any modern alternative immediately.
VPN protocols are the foundation upon which secure network connectivity is built. Understanding their characteristics enables informed technology selection and secure implementation. Let's consolidate the key knowledge from this page:
What's Next:
The final page in this module examines VPN Security—the threats VPNs face, vulnerabilities in implementations, secure configuration practices, and the security considerations that complement protocol selection. You'll learn about VPN-specific attacks, hardening measures, and how VPN fits within a comprehensive security architecture.
You now have deep knowledge of VPN protocols: from the IPSec suite's components and operation to SSL/TLS VPN implementations, from WireGuard's elegant design to legacy protocols you should avoid. This understanding enables you to select appropriate protocols for specific requirements and configure them securely.