$ wg-quick up wg0

VPN

A VPN (Virtual Private Network) builds an encrypted tunnel across an untrusted network so that a remote machine behaves as if it were plugged into a private one. Your laptop’s packets to an internal address are encrypted, wrapped in an ordinary-looking outer packet addressed to a VPN gateway, and unwrapped there. For a data engineer, that is how you reach a warehouse, a database or an internal Airflow UI that has no public address.

Encapsulation, step by step

$ psql -h 10.0.2.15 # from a café
One packet through a WireGuard tunnel
PUBLIC INTERNET · CAFÉ WI-FI PRIVATE 10.0.0.0/16 ENCRYPTED TUNNEL · UDP 51820 LAPTOP 192.0.2.44 VPN GATEWAY 198.51.100.1 DATABASE 10.0.2.15:5432 1 · LAPTOP BUILDS IP 10.8.0.2 → 10.0.2.15 TCP → 5432 SELECT … 2 · ENCRYPT + WRAP IP 192.0.2.44 → 198.51.100.1 UDP 51820 encrypted inner packet 3 · CAFÉ SEES laptop ↔ gateway, UDP, size, timing. Not the DB, not the query. 4 · GATEWAY UNWRAPS IP 10.8.0.2 → 10.0.2.15 TCP → 5432 SELECT … → DATABASE
  1. You are on café Wi-Fi. The database lives in a private network and has no public IP. Only the VPN gateway is reachable from the internet.
  2. Your app sends a normal packet to 10.0.2.15. The OS routes it to the VPN interface, which gave the laptop an inner address, 10.8.0.2.
  3. The VPN client encrypts the whole inner packet and wraps it in a new outer packet addressed to the gateway. This is encapsulation.
  4. Anyone on the path sees only the outer header: who talks to the gateway, when, and how much. The content and the real destination are hidden.
  5. The gateway decrypts, strips the outer header and forwards the original packet into the private network. The database sees a normal internal connection.

Kinds of VPN

Kind Connects Typical use
Remote access One device → a network Engineers reaching internal tools and databases
Site-to-site Network → network Office or on-prem data center ↔ cloud VPC (AWS Site-to-Site VPN, Cloud VPN)
Mesh / overlay Every device ↔ every device Tailscale, NetBird, ZeroTier: peer-to-peer WireGuard with central identity
Consumer privacy VPN You → a provider’s exit server Hides your traffic from the local network and ISP, moves trust to the VPN provider

Protocols in 2026

Protocol Notes
WireGuard Small, fast, modern crypto, in the Linux kernel since 5.6. The default choice for new setups. UDP only.
IPsec (IKEv2) The standard for site-to-site links and cloud provider VPN gateways. Mature, complex to configure.
OpenVPN TLS-based, runs over UDP or TCP 443, gets through restrictive networks. Slower than WireGuard.
SSL VPN appliances Vendor products (Fortinet, Ivanti, Cisco). Frequent targets of critical vulnerabilities: patch quickly.

VPN vs zero trust

A classic VPN says “once you’re in the network, you’re trusted”. If one laptop is compromised, the attacker is inside too. Zero-trust access (Cloudflare Access, Google BeyondCorp/IAP, Tailscale ACLs, Teleport) checks identity and device health on every request to each service, and grants access to one app instead of a whole subnet. Many teams now use an identity-aware proxy for web tools and keep a VPN, or a short-lived SSH tunnel, only for raw database ports.

Common mistakes

  • Overlapping address ranges. If the office uses 10.0.0.0/16 and so does the VPC, routes conflict. Plan non-overlapping CIDRs early.
  • Full tunnel by accident. Sending all traffic, including video calls, through the gateway makes everything slow. Use split tunneling for internal ranges only, unless policy requires otherwise.
  • Assuming a VPN means anonymity. The VPN provider or your company sees everything the café used to see.
  • MTU problems. Encapsulation adds bytes. Large packets that don’t fit are dropped and connections hang after the handshake. WireGuard’s default MTU of 1420 accounts for this.

Learning Resources

See also: Firewalls, SSH.