Notes
Tunnels
Every VPN is a tunnel: a private packet wrapped inside a public one, usually encrypted. The outer packet travels from your address to the VPN server across the internet. The other end unwraps it, and the inner packet, between private addresses, is routed inside the private network as if you were there. The wrapping adds headers, so the usable packet size inside the tunnel shrinks, a common cause of strange hangs, covered in episode seventeen.
- wrap private packets inside public ones, encrypted
- outer: your IP → VPN server
- inner: 10.0.1.5 → 10.0.2.9
- other end unwraps and routes inside
- cost: extra headers → smaller MTU inside
VPN kinds
Two kinds of VPN. Site to site connects whole networks, like an office or data centre to a cloud VPC, and is always on. A client VPN lets one laptop join the private network. Protocols: WireGuard is small and fast over UDP; IPsec is the standard for site to site and what cloud VPN gateways speak; OpenVPN is older and TLS based. For more bandwidth and predictable latency than an internet VPN, clouds offer private links like AWS Direct Connect.
- site-to-site: office or DC ↔ cloud VPC, always on client VPN: a laptop joins the private network
- WireGuard: small, fast, UDP
- IPsec: standard for site-to-site, cloud VPN
- OpenVPN: TLS based, older
- AWS: Site-to-Site VPN, Client VPN, Direct Connect
SSH local forward
You can build a tunnel with plain SSH. ssh minus L forwards a local port through the SSH connection to an address the server can reach. We forwarded local port fifteen thousand four hundred and thirty two to ShopRung's port on the server, then curl to the local port returned ShopRung's health, status UP. This is how engineers reach a private database from a laptop through a jump host, without exposing the database.
$ ssh -f -N -L
15432:127.0.0.1:8080
root@server -p 2222
$ curl :15432/api/health
{"status":"UP",...} 200
local port 15432 → through
SSH → server:8080
typical: reach a private DB SOCKS proxy
ssh minus D goes further: it starts a SOCKS proxy on your machine. Any program configured to use it sends its connections through the tunnel, and the server makes them on your behalf. We pointed curl at the SOCKS port and reached ShopRung from the server's side, with a two hundred. Note that ss showed both tunnels listening on loopback only, so other machines cannot use them, which is the safe default.
$ ssh -f -N -D 1080
root@server -p 2222
$ curl --socks5-hostname
127.0.0.1:1080
http://127.0.0.1:8080/...
200
ss: ssh listening on
127.0.0.1:1080 Forward proxies
A forward proxy sits between clients and the internet. Companies use them to control and log outbound traffic, and secure cloud setups use egress proxies that only allow approved domains. Tools read the HTTPS proxy, HTTP proxy and NO proxy environment variables. Most proxy tickets are a missing NO proxy entry, so internal calls go to the proxy and fail, or a daemon like Docker that needs its own proxy settings. Our lab machine reached the internet only through such a proxy.
HTTPS_PROXY=http://proxy:3128 HTTP_PROXY=... NO_PROXY=localhost,127.0.0.1, .internal,10.0.0.0/8 curl, pip, npm, Docker read them (Docker daemon has its own config) egress proxy = allowlist out
Reaching servers
How should engineers reach private servers? The classic answer is a bastion, one hardened SSH host, used with ssh minus J to jump through it. Newer options need no inbound ports at all: AWS Systems Manager Session Manager opens a shell through an agent, authorised by IAM and fully logged. Others use a client VPN with single sign on, or zero trust access proxies that check identity per application.
- bastion (jump host): one hardened SSH entry point ssh -J bastion app-1
- AWS SSM Session Manager: no open ports, IAM + logs
- client VPN + SSO
- zero trust access proxies: per-app, identity-aware
VLANs and overlays
The opposite problem: keeping traffic apart on shared hardware. A VLAN tags each Ethernet frame, so one switch carries many isolated networks, about four thousand. Data centres and clouds need far more, so they use overlays like VXLAN, which wraps Ethernet frames inside UDP with sixteen million network IDs. Cloud VPCs, Docker overlays and several Kubernetes network plugins use overlays like this. Our lab kernel had no VLAN support, so this part is described, not measured.
- VLAN: a 12-bit tag in the Ethernet frame; one switch, many isolated networks (max 4094)
- VXLAN: L2 frames inside UDP (port 4789), 16 million IDs
- cloud VPCs, Kubernetes CNIs and Docker overlay use overlays like this
Common mistakes
Mistakes. VPN client ranges that overlap the VPC or office network. Missing NO proxy entries, so internal traffic goes to the proxy. SSH open to the whole internet on every server instead of a bastion or Session Manager. SSH tunnels bound to all interfaces, which shares your access with the network. And ignoring the smaller MTU inside tunnels.
- VPN ranges overlapping the VPC or office
- missing NO_PROXY for internal names
- SSH open to the internet instead of a bastion/SSM
- tunnels bound to 0.0.0.0
- ignoring tunnel MTU
Say it like this
In the interview: the database has no public endpoint. Engineers reach it through Session Manager port forwarding, or a bastion with ssh minus L, or a client VPN with single sign on, and every session is logged. Offices and data centres connect with site to site IPsec VPN or Direct Connect, with non overlapping ranges. Outbound traffic from servers can go through an egress proxy with an allowlist.
- "No public endpoint. Engineers
- use SSM Session Manager or a bastion with ssh -L to forward a local port, or a client VPN with SSO. Office to cloud uses
- site-to-site IPsec or Direct
- Connect. All access is logged
- and least privilege."