cheat-sheets

VPN (Virtual Private Network)

A VPN creates an encrypted tunnel between devices or networks so traffic can cross an untrusted network safely.

Related: WireGuard, Tailscale, TLS (Transport Layer Security), OpenSSH Cheat-Sheet

Common Uses #

USEDESCRIPTION
Remote accessA client connects into a home or office network
Site-to-siteTwo networks joined permanently through gateways
PrivacyRoute traffic through a provider’s exit node
MeshEvery device talks directly to every other device (Tailscale, Nebula)

Protocols Compared #

PROTOCOLTRANSPORTNOTES
WireGuardUDP (default 51820)Tiny codebase, fast, modern crypto, static config. See WireGuard
OpenVPNUDP or TCP 1194Mature, flexible, TLS based, runs over TCP 443 to pass strict firewalls
IPsec / IKEv2UDP 500, 4500, ESPBuilt into most OSes, standard for site-to-site
L2TP/IPsecUDP 1701 + IPsecLegacy, avoid for new setups
SSTPTCP 443Windows only, passes firewalls
PPTPTCP 1723Broken, never use

Concepts #

TERMMEANING
Full tunnelAll client traffic goes through the VPN (AllowedIPs = 0.0.0.0/0)
Split tunnelOnly specific subnets go through the VPN
Road warriorRoaming client connecting to a fixed server
Exit nodePeer that forwards your internet traffic
MTUTunnel overhead reduces MTU. WireGuard commonly uses 1420. Lower it if large packets stall
KeepalivePeriodic packet that holds NAT mappings open (PersistentKeepalive = 25)

Server Prerequisites on Linux #

COMMANDDESCRIPTION
echo 'net.ipv4.ip_forward=1' | sudo tee /etc/sysctl.d/99-vpn.conf && sudo sysctl --systemEnable IP forwarding
sudo iptables -t nat -A POSTROUTING -s <VPN-SUBNET> -o <WAN-IF> -j MASQUERADENAT VPN clients to the internet, see IPTables
sudo ufw allow 51820/udpOpen the WireGuard port, see UFW (uncomplicated firewall)

Troubleshooting #

SYMPTOMCHECK
Tunnel up, no trafficIP forwarding, NAT/firewall rules, AllowedIPs
Handshake never completesPort blocked, wrong keys, wrong endpoint, clock skew (IPsec/OpenVPN)
Some sites hang, others workMTU problem. Try a lower MTU
DNS not resolvingClient DNS setting, DNS leak, push the VPN’s DNS
Drops behind NATAdd keepalive
COMMANDDESCRIPTION
sudo wg showWireGuard peers, last handshake and transfer
ip route get <IP>Which interface a destination uses
ping -M do -s 1372 <HOST>Test path MTU (1372 + 28 = 1400 bytes)
sudo tcpdump -ni <IF> udp port 51820Watch tunnel packets arrive
Search all sheets

Tip: / or Ctrl/Cmd+K to open, Esc to close.