Deep-dive reference on Virtual Private Networks โ the real mechanics (tunneling, IPsec, IKE, crypto), not just "it's a secure tunnel." Builds on Networking (encapsulation ยง4, TLS handshake ยง2, NAT ยง7, IPsec-at-L3). Tied to AWS Site-to-Site VPN / Client VPN for AWS-Cloud-Practitioner Domain 3.
โ back to Networking ยท DevOps ยท AWS-Cloud-Practitioner
A VPN (Virtual Private Network) makes two endpoints behave as if they're on the same private LAN, even though traffic between them crosses the public, untrusted internet. Three pillars:
One-liner: a VPN is an encrypted, authenticated tunnel that carries private network traffic across a public network as if it were local.
| Remote-access (client-to-site) | Site-to-site | |
|---|---|---|
| Connects | One device โ a private network | Two whole networks |
| Examples | Corporate "connect to office", consumer privacy VPNs, AWS Client VPN | On-prem โ AWS VPC, office โ office, AWS Site-to-Site VPN |
| Your-side endpoint | VPN client software on the device | A VPN gateway/router (no per-device software) |
| Typical tech | TLS-based (OpenVPN), WireGuard, IKEv2 | IPsec |
The AWS exam's "VPN" (the VGW one) is site-to-site.
A VPN does an extra wrap beyond normal encapsulation (Networking ยง4): it puts a whole finished IP packet inside the payload of a new packet.
Original packet (inside the private network):
[IP: 10.0.1.5 โ 192.168.2.8][TCP][data]
After IPsec tunnel-mode encapsulation:
[IP: 198.51.100.7 โ 203.0.113.20] โ new OUTER header (the two gateways' PUBLIC IPs)
[ESP header]
[ ENCRYPTED { [IP:10.0.1.5 โ 192.168.2.8][TCP][data] } ] โ whole original packet, encrypted
[ESP auth/trailer]
The internet sees only the outer header (public IP A โ public IP B). Private addressing + data are encrypted inside and invisible. That's the "virtual private" part.
Mirrors the TLS handshake (Networking ยง2): asymmetric crypto to bootstrap, symmetric to do bulk work.
| Protocol | Layer | Used for | Notes |
|---|---|---|---|
| IPsec | L3 | Site-to-site (+ IKEv2 remote-access) | The classic. What AWS Site-to-Site VPN uses. |
| TLS/SSL VPN (OpenVPN, AnyConnect) | rides TLS | Remote-access | Often on port 443 to pass firewalls. AWS Client VPN is OpenVPN-based. |
| WireGuard | L3 (UDP) | Modern everything | Tiny codebase, fixed modern crypto (ChaCha20 / Curve25519), roaming-friendly, "cryptokey routing" (peer = its public key). |
| PPTP / L2TP / SSTP | various | Legacy | PPTP broken/dead; L2TP usually L2TP/IPsec. |
A suite with two jobs: negotiate keys (IKE), then protect data (ESP/AH).
A one-way agreement (cipher + keys + rules for one direction). A working tunnel needs two SAs (one each way). Identified by an SPI (Security Parameter Index) in the ESP header so the receiver picks the right keys.
Plain ESP has no ports โ breaks crossing a NAT (Networking ยง7). NAT-T wraps ESP in UDP 4500 so the NAT has a port to track. Needed because nearly every on-prem router is behind NAT (AWS handles it).
10.0.1.5) โ Host B (192.168.2.8) on the remote net.192.168.2.0/24 โ VPN gateway" โ packet goes to Gateway A.[GW-A public IP โ GW-B public IP].Same machinery, one twist: pick a full-tunnel exit server in country X, and your traffic reaches the internet from that country's IP.
- Why it works = IP geolocation. Your public IP must be real/routable (it's the return address). IP blocks are allocated by region; commercial DBs (e.g. MaxMind) map IP range โ country. Sites just look up your exit IP. No VPN โ ISP's India IP (you look Indian). VPNโUS server โ server's US IP (you look American). You don't hide your location, you borrow the exit node's.
- Flow: You (India) โ encrypted full tunnel โ VPN server (USA) makes the request from its US IP โ Netflix sees a US IP โ serves the US catalog โ response back through the tunnel.
- DNS must go through the tunnel too โ else a query to your real ISP resolver = a DNS leak that exposes your true location. VPN pushes its own resolvers.
- Why it breaks: streaming services run VPN detection โ blocklists of known datacenter/VPN IP ranges โ "you appear to be using a proxy/unblocker." Providers counter with rotating + residential IPs. Permanent cat-and-mouse (same server works one week, not the next).
- Contrast: this is full tunnel + remote-access (disguise location); a typical corporate OpenVPN is split tunnel (reach private resources, only some traffic in). Opposite goals, same tech.
AWS Site-to-Site VPN = textbook IPsec tunnel mode: - Customer Gateway (CGW) = resource describing your side (on-prem router public IP, BGP ASN). - Virtual Private Gateway (VGW) = the AWS side, attached to the VPC (or attach to a Transit Gateway for many VPCs). - AWS provisions two tunnels to two endpoints for HA/redundancy. - Routing static or dynamic (BGP); IPsec (IKE + ESP), encrypted, over the public internet.
AWS Client VPN = managed remote-access flavor (OpenVPN/TLS) for individual users reaching the VPC.
Exam nuance: Direct Connect alone is private but NOT encrypted (dedicated physical line, no tunnel). Need dedicated line and encryption โ run a VPN over Direct Connect. Common distractor. See AWS-Cloud-Practitioner Domain 3 connectivity menu.
OpenVPN is remote-access + TLS-based โ it has NO Virtual Private Gateway. VGW is an AWS site-to-site IPsec construct (two networks); a person on a laptop logging in is remote-access. The box that feels like a "gateway" in an OpenVPN setup is just the OpenVPN server / concentrator (typically an instance/appliance inside the company's AWS VPC).
| OpenVPN (typical corporate) | AWS Site-to-Site VPN (VGW) | |
|---|---|---|
| Type | Remote-access (a person) | Site-to-site (two networks) |
| Tech | TLS/SSL (OpenSSL certs) | IPsec (IKE + ESP) |
| Your side | OpenVPN client app | A router/gateway |
| Concentrator | An OpenVPN server | A Virtual Private Gateway |
Corrected step-by-step flow:
1. Auth happens ONCE at tunnel setup โ mutual TLS: server cert + client cert (+ usually username/password, often MFA). Not per-request.
2. Server assigns a virtual IP from the VPN pool (e.g. 10.8.0.6), bound to a TUN interface on your laptop.
3. Server pushes routes to your machine ("corporate ranges โ the tun interface"). The send-side routing lives on your box, not the destination server. (Split tunnel = only corp ranges; full = everything.)
4. You hit an internal app โ OS matches a pushed route โ packet into TUN โ OpenVPN encrypts โ ships to the OpenVPN server.
5. OpenVPN server decrypts + forwards into the VPC/corp network. Return routing to your virtual IP is handled by the OpenVPN server โ either a route for the VPN pool points back at it, or it NATs your traffic to its own IP (so the app server never even knows your 10.8.0.6 exists).
The misconception to avoid: the destination app server does not list your virtual IP in its routing table, and there is no VGW authenticating each request. Auth is one-time (mutual TLS); the OpenVPN server is the only component that knows your virtual IP and does the routing/NAT on both ends.
Taught in the AWS CLF-C02 study session, 2026-06-29, off the back of AWS-Cloud-Practitioner Module 5 (Networking). Mechanics-level companion to the exam-level VPN coverage in the hub's Domain 3.