VPN Fundamentals — IPsec, OpenVPN, WireGuard and the Math That Makes Them Work

Manish Garg
Manish Garg Associate of (ISC)² · RingSafe
Apr 19, 2026
10 min read
Read as

Last updated: May 1, 2026

A VPN tunnels Layer 3 (or Layer 2) traffic over an untrusted network, with confidentiality, integrity, and authentication. The three protocols you need to know are IPsec (the enterprise default), OpenVPN (the legacy SSL VPN), and WireGuard (the modern lightweight default). This module compares the three, walks through phase 1 / phase 2 of IPsec, the cryptographic primitives at play, and how to choose. Module 16 covers ZTNA — the alternative that increasingly replaces traditional VPN.

A VPN is a tunnel: take a packet, encrypt it, wrap it in a new outer packet, ship it over the internet, decrypt at the other side. Easy in concept; the security depends entirely on the cryptographic handshake and the policy you put around it. This module compares the three VPN protocols you will actually meet in 2026 — IPsec for site-to-site, OpenVPN for legacy remote access, WireGuard for everything modern — and demystifies the IPsec phase 1/phase 2 model that confuses every beginner.

What "VPN" actually means in 2026

Three patterns are all called “VPN” but solve different problems. Site-to-site VPN connects two networks (HQ to a branch office, on-prem to a cloud VPC) so hosts on either side can talk as if on the same backbone. Remote-access VPN connects a single user’s laptop to a corporate network so they can reach internal apps. Consumer VPN (NordVPN, ProtonVPN, Surfshark) tunnels traffic through a third-party endpoint to anonymise or geo-shift the user — a fundamentally different threat model from corporate VPN. This module focuses on the first two; consumer VPN is briefly addressed in M16 alongside the ZTNA comparison.

IPsec — the enterprise standard that nobody loves but everyone uses

IPsec is a suite, not a single protocol. The pieces: IKE (Internet Key Exchange) negotiates keys; ESP (Encapsulating Security Payload) carries encrypted data; AH (Authentication Header) provides integrity-only and is rarely used. The two-phase model: Phase 1 (IKE_SA_INIT + IKE_AUTH in IKEv2) establishes a secure channel for negotiation — Diffie-Hellman exchange, mutual authentication via PSK or certificates, identity protection. Phase 2 (CHILD_SA) negotiates the actual data tunnel — which proxies (subnets) to encrypt, which cipher, lifetime. Modern deployments must use IKEv2 (RFC 7296). IKEv1 is deprecated — it had identity-leak issues, no MOBIKE, no anti-DoS cookies, and is on every penetration tester’s hit list.

Cipher recommendations 2026AES-256-GCM for ESP encryption, SHA-2/256 for integrity, DH group 19 (P-256) or 20 (P-384) or curve25519 (group 31) for key exchange. Drop DH groups 1/2/5 (768-1536 bit) — Logjam-vulnerable. Drop 3DES, MD5, SHA-1.

OpenVPN — TLS-over-UDP, the workhorse of the 2010s

OpenVPN wraps a TLS handshake (control channel) and UDP-or-TCP carrier for encrypted data. It is mature, multiplatform, and configurable to a fault. Modern OpenVPN deploys with tls-crypt (better than tls-auth — encrypts the entire control channel preventing fingerprinting), AES-256-GCM data cipher, and TLS 1.3 control channel. OpenVPN over TCP/443 is the standard “punch through restrictive firewalls” mode but suffers from TCP-over-TCP head-of-line blocking; UDP/1194 is preferred when network policy allows.

OpenVPN downsides in 2026large codebase (roughly 100K LOC in C, perpetual audit cost), complex config (a typical .ovpn has 30+ directives), slower handshakes than WireGuard. Still ubiquitous because of vendor lock-in (every appliance supports an OpenVPN client) and policy/auth flexibility.

WireGuard — the protocol you should pick for new builds

WireGuard (Donenfeld, 2017) is a deliberately minimal VPN protocol. ~4,000 lines of kernel code (vs OpenVPN’s 100K+, IPsec’s gigantic surface). No cipher negotiation — protocol mandates ChaCha20-Poly1305, Curve25519, BLAKE2s. Configuration is a public-key list per peer, no certificates, no PKI to manage.

Performancein benchmarks, 3-5× faster than OpenVPN, 2-3× faster than IPsec for similar hardware, with lower CPU usage.

Authentication modeleach peer has a Curve25519 keypair; access control is a static list of allowed-IPs per public key. This is restrictive (no native AD/RADIUS auth) — production deploys add a control plane on top: Tailscale, Headscale, NetBird, Twingate. For pure infrastructure tunnels (cloud-to-cloud, branch-to-HQ where you control both endpoints) raw WireGuard is excellent. For users with corporate auth requirements, you want an SSO-integrated WireGuard control plane.

Drawbackno built-in roaming/MOBIKE-equivalent at the protocol level — peers must reach each other; NAT traversal works via persistent keepalives but requires clean network paths.

Choosing between them — a decision tree

New site-to-site between cloud + on-premWireGuard if both endpoints are Linux/cloud-managed; IPsec if you need vendor-supported HA, AD-authenticated dynamic spokes, or interop with non-Linux gateways (most appliances still default to IPsec).

Site-to-cloud (AWS/Azure/GCP)AWS Site-to-Site VPN is IPsec; Azure VPN Gateway is IPsec; both expose only IKEv2/ESP. So choose IPsec on the on-prem side.

Remote access for employeesdo not pick OpenVPN for new builds. Choose ZTNA (Cloudflare Access, Tailscale, Twingate, Zscaler ZPA) — see M16. Pure VPN remote access is being deprecated in well-run enterprises because the trust model (once on the VPN, you reach everything) is unsafe. Site-to-site with strict regulator requirements (RBI, SEBI): IPsec with FIPS-validated cipher modules is still the safe default, regardless of what is technically better.

The three things that go wrong with every VPN

1Split-tunnel vs full-tunnel. Full-tunnel sends all client traffic over the VPN — strong inspection, high bandwidth cost, breaks if VPN dies. Split-tunnel sends only corporate destinations through the VPN — lighter, but loses visibility on internet-bound traffic and historically introduced DNS leaks. The right answer depends on your inspection model.
2MTU/MSS issues. A VPN adds overhead (IPsec ~70 bytes, WireGuard ~32 bytes, OpenVPN ~50-70 bytes). If the tunnel does not adjust MSS, large web pages hang. Always set tcp-mss-clamping or your equivalent and test with a 1400-byte ping with DF set.
3Routing asymmetry. Traffic enters via VPN, returns via direct internet — stateful firewalls drop the unmatched return. Always verify both directions cross the same path or that all transit firewalls allow asymmetric flows.

India context — DoT licensing and regulator expectations

Operating a VPN service that terminates on Indian soil and offers it to third parties triggers DoT licensing under the OSP framework. Operating a VPN for your own corporate access is unregulated. Note also CERT-In’s 2022 directive on logging (lengthy log retention requirements that several consumer VPN providers cited as their reason for exiting the Indian market — many maintain “no Indian PoPs” stances). For corporate VPN: log connection metadata (user, source IP, time) for at least 6-12 months for incident response, and keep IPsec/IKE logs for forensics. Enterprises subject to RBI / SEBI / IRDAI typically need much longer retention plus periodic crypto-suite reviews — IT teams in 2026 should be planning the migration off any IKEv1 or 3DES-anywhere quietly, before regulators ask in writing.

Site-to-cloud VPN — the practical AWS / Azure / GCP patterns

Connecting on-prem to cloud almost always uses IPsec — every cloud VPN service speaks IKEv2 and ESP.

AWS Site-to-Site VPNtwo tunnels (active/active or active/standby), terminating at AWS Virtual Private Gateway (VGW) or Transit Gateway. Specify static or BGP routing; BGP enables auto-failover.

Azure VPN Gatewaysimilar two-tunnel architecture, supports BGP and active-active.

GCP HA VPNrequires four tunnels (two interfaces on the GCP side × two peers on yours) for the SLA.

Cipher choicescloud sides default to modern but verify (AES-256-GCM, SHA-2/256, DH groups 14+/19+); some legacy on-prem appliances need explicit configuration to match.

Operational realitycloud-side VPN is typically rock-solid; on-prem appliance flakiness causes most issues. Logging on both sides; configure SLA monitors; have an automatic failover plan. For higher reliability and bandwidth, AWS Direct Connect / Azure ExpressRoute / GCP Interconnect are the dedicated alternatives — pricier but predictable.

WireGuard at scale — the control-plane decision

WireGuard’s simplicity is a feature for engineers and a bug for operators — by itself it has no AD/SSO integration, no policy engine, no central logging. Production deployments wrap it with a control plane: Tailscale (commercial, easy, polished UX, exit-node-on-demand), Headscale (open-source Tailscale-compatible coordination server, self-host), NetBird (open-source, SSO, ACLs), Twingate (commercial, ZTNA-leaning), Innernet (lightweight P2P).

Choosingfor small dev teams, Tailscale free tier is unbeatable. For corporate with SSO + audit requirements, Tailscale Business or NetBird. For privacy-sensitive or regulated entities that must self-host, Headscale or NetBird self-hosted.

Indian sovereigntyany control plane that holds your network topology metadata is a sensitive third-party — choose providers with documented Indian PoPs / data residency, or self-host. The control-plane choice determines audit posture more than the VPN protocol.

IPsec troubleshooting — the diagnostic flow

When an IPsec tunnel will not come up, work through this checklist methodically:

1Phase 1 (IKE) — both sides see each other’s UDP/500 (or UDP/4500 with NAT-T) packets. Check firewall on both sides.
2Authentication match — pre-shared key matches exactly (no leading/trailing whitespace), or certificates are correctly cross-trusted.
3Proposal match — at least one combination of (encryption, integrity, DH group, lifetime) is mutually acceptable. Modern stacks default differently; explicit configuration is safer.
4Identity match — IKE identity (typically IP or FQDN) matches what the other side expects.
5Phase 2 (Child SA) — proxy IDs / traffic selectors match exactly on both sides. The classic failure: side A says “10.0.0.0/24 to 192.168.1.0/24”; side B says “10.0.0.0/16 to 192.168.0.0/16” — the SA does not establish.
6Test traffic — interesting traffic must be sent to trigger SA creation; always ping with explicit source IP that falls in the proxy ID. Tooling: Linux ip xfrm state and ip xfrm policy; Cisco show crypto isakmp sa + show crypto ipsec sa; debug logs at IKE level if needed.

Diagrams

IPsec phases — the conversation that builds the tunnel
Phase 1 (IKE_SA_INIT + IKE_AUTH)
  Peer A ──── proposal: DH-group, encr, hash, lifetime ────▶ Peer B
  Peer A ◀──── chosen proposal + DH public + nonce ──────── Peer B
  Peer A ──── auth (PSK or cert) + ID + traffic selectors ▶ Peer B
  Peer A ◀──── auth + accepted selectors ─────────────────── Peer B
  ⇒ IKE_SA established (control channel encrypted)

Phase 2 (CHILD_SA — repeats per protected subnet pair)
  Peer A ──── proposal: ESP cipher, AH, lifetime, selectors ▶ Peer B
  Peer A ◀──── accepted ──────────────────────────────────── Peer B
  ⇒ ESP tunnel up — actual encrypted data flows here
WireGuard simplicity vs IPsec/OpenVPN
  WireGuard config (one peer):
  ──────────────────────────
  [Interface]
  PrivateKey = <local-priv>
  Address    = 10.7.0.1/24

  [Peer]
  PublicKey  = <peer-pub>
  AllowedIPs = 10.7.0.0/24
  Endpoint   = 203.0.113.10:51820

  IPsec config (typical):
  ─── tens of lines: IKE proposals, child SA, NAT-T, DPD,
      identity types, traffic selectors, certs, etc.

References & deeper reading

FAQ

Is WireGuard secure for production?

Yes. It is in the Linux kernel (since 5.6), audited multiple times, deployed at Cloudflare, Mullvad, Tailscale, and many large enterprises. The “but it has no certificates” concern is a process question, not a security one — pair it with a control plane (Tailscale, Headscale, Netmaker) for SSO, ACLs, and rotation.

Why is OpenVPN being phased out?

Three reasons:

1WireGuard is faster, simpler, and equally secure for most use cases.
2ZTNA (M16) replaces remote-access VPN for users.
3The remaining OpenVPN strength — auth flexibility — is now matched by WireGuard control planes. OpenVPN remains in service mostly because of installed appliance ubiquity, not because new architectures choose it.

Is split-tunnel acceptable for compliance?

Generally yes if your inspection model relies on endpoint-side controls (EDR with web filtering, Defender SmartScreen, MDM-enforced DNS over HTTPS). RBI/SEBI auditors care about provable inspection — full-tunnel + perimeter-WAF is one model; split-tunnel + endpoint-WAF + cloud SWG is another. Choose deliberately and document the threat model.

Can I use a consumer VPN for company work?

No. Consumer VPNs (NordVPN, ProtonVPN, etc.) anonymise your traffic at their PoP — the corporate origin server cannot apply geo or IP-based controls correctly, and the VPN provider sees plaintext of any non-TLS connection. Most enterprise security policies (and DPDP-aligned acceptable-use policies) explicitly prohibit consumer VPN on managed devices.

How do I size a VPN concentrator?

Two factors:

1sustained throughput (10/40/100 Gbps tier) — IPsec offload silicon matters; software-only IPsec rarely exceeds 1-2 Gbps per core.
2concurrent SAs / tunnels — branch-heavy deployments need thousands of phase-2 SAs. Ask the vendor for performance numbers under specific cipher suites, not the marketing “up to 40 Gbps” line, which is usually with AES-NI and tiny test packets.

Should I run two VPN gateways for HA?

Yes for production. Active/active or active/standby with BGP-based failover; test failover quarterly. The cost of a second gateway is modest; the cost of a six-hour outage when your primary fails over a long weekend is not.

How do I monitor VPN health?

Track tunnel state (UP/DOWN), throughput, packet loss, latency. Synthetic transactions through the tunnel (HTTP probe to a known internal endpoint) catch “tunnel up but not passing traffic” cases. Page on tunnel down >30 seconds; treat extended down as a P1.


⚖️ Legal: Use any techniques described here only on networks you own or have explicit written authorisation to test. In India, unauthorised access is punishable under IT Act §66 (up to 3 years + fine). Pair offensive testing with a signed Statement of Work / Rules of Engagement; pair forensic activity with §65B-aligned chain of custody.

Want this for your team?

Custom team training + practitioner advisory

Beyond the free academy — we run private workshops, vCISO advisory, and red-team exercises tailored to your stack. For Indian SMBs scaling past their first hire.

Book team training call Replies in 4 working hrs · India-only · Senior consultants