Module 15: VPNs & Tunneling
VPNs (Virtual Private Networks) create secure, encrypted connections over public networks. This module covers VPN types, tunneling protocols, and real-world implementations.Estimated Time: 3-4 hours
Difficulty: Intermediate
Prerequisites: Module 7 (Security basics), Module 10 (NAT)
Difficulty: Intermediate
Prerequisites: Module 7 (Security basics), Module 10 (NAT)
15.1 What is a VPN?
A VPN extends a private network across a public network, allowing users to send and receive data as if connected to the private network directly. The analogy is a sealed, private tunnel through a public highway. Cars (packets) entering the tunnel are visible to everyone on the highway — but no one can see what is inside the tunnel or tamper with its contents. When a car exits the tunnel on the other end, it is on the private road (network) as if it had always been there.Without VPN
With VPN
15.2 VPN Types
Remote Access VPN
Individual users connect to a corporate network.- Work from home
- Traveling employees
- Contractors accessing internal systems
Site-to-Site VPN
Connects two networks together permanently.- Connect branch offices
- Connect on-premises to cloud (AWS VPN)
- Merge networks after acquisition
Client-to-Site vs Site-to-Site
15.3 Tunneling Protocols
IPsec (Internet Protocol Security)
Industry standard for site-to-site VPNs. Two Modes:
IPsec Phases:
Think of the two phases like establishing diplomatic relations. Phase 1 is the countries agreeing on which language to speak and verifying each other’s credentials (authentication). Phase 2 is negotiating the actual terms of the treaty (encryption parameters for the data tunnel). If Phase 1 fails, Phase 2 never starts.
What an IPsec packet looks like on the wire
OpenVPN
Open-source, widely used for remote access. Characteristics:- Uses OpenSSL library
- TCP or UDP (UDP preferred)
- Port 1194 by default (can use 443 to bypass firewalls)
- Certificate-based authentication
WireGuard
Modern, fast, simple VPN protocol. WireGuard has rapidly become the preferred choice for new VPN deployments due to its simplicity and performance. Advantages:- ~4,000 lines of code (vs 100,000+ for OpenVPN) — a smaller codebase means fewer bugs and a smaller attack surface. The entire codebase is auditable by a single person.
- Built into the Linux kernel (since 5.6) — no user-space daemons needed, which means better performance.
- Faster than IPsec and OpenVPN in most benchmarks — lower latency and higher throughput due to its minimal, efficient design.
- Uses modern cryptography only (Curve25519, ChaCha20, Poly1305, BLAKE2s) — no cipher negotiation, which eliminates downgrade attacks. The trade-off is that if any of these algorithms are ever broken, WireGuard must be updated (crypto agility is deliberately sacrificed for simplicity).
SSL/TLS VPN
VPN over HTTPS - works through any firewall. Types:- Portal VPN: Browser-based access to web apps
- Tunnel VPN: Full network access (like OpenVPN)
Protocol Comparison
15.4 Split Tunneling
Full Tunnel
All traffic goes through VPN.Split Tunnel
Only specific traffic goes through VPN.15.5 VPN in the Cloud
AWS Site-to-Site VPN
Connect on-premises network to AWS VPC.- Virtual Private Gateway (VGW): AWS side endpoint
- Customer Gateway (CGW): Your side endpoint
- VPN Connection: Two IPsec tunnels (for redundancy)
AWS Client VPN
For remote access to AWS resources.15.6 VPN Security Considerations
Authentication Methods
Best Practices
Use Strong Encryption
AES-256, ChaCha20. Avoid 3DES, DES, or anything “export grade.”
Enable MFA
Add second factor for VPN authentication.
Certificate Auth
Use certificates instead of pre-shared keys for better security.
Limit Access
Use split tunneling wisely. Apply least privilege.
15.7 Other Tunneling Methods
SSH Tunneling
Create encrypted tunnels using SSH.- Access database behind firewall
- Quick temporary secure access
- Bypass network restrictions
GRE (Generic Routing Encapsulation)
Encapsulates various network layer protocols inside point-to-point links.VXLAN (Virtual Extensible LAN)
Overlay network for data centers. Extends L2 network over L3.15.8 Troubleshooting VPN Issues
VPN won't connect
VPN won't connect
Connected but can't reach resources
Connected but can't reach resources
Slow VPN performance
Slow VPN performance
15.9 Key Takeaways
VPN = Secure Tunnel
Encrypts traffic over untrusted networks.
Choose Right Protocol
WireGuard for speed, OpenVPN for compatibility, IPsec for site-to-site.
Split Tunnel Carefully
Balance security vs. performance based on use case.
Never Use PPTP
It’s broken. Use modern protocols only.
Next Module
Module 16: Real-World Networking Scenarios
Walk through complete networking scenarios from request to response.