DEVOPS, SRE AND CLOUD · PART 2 · NETWORKING FOR DEVOPS · NETWORKS · 42 OF 187

VPNs, Proxies and VLANs for DevOps Engineers

How networks are joined and separated: tunnels and VPNs (WireGuard, IPsec, site-to-site vs client VPN, cloud VPN and Direct Connect), SSH tunnels you can use today (we reached ShopRung through ssh -L and a SOCKS proxy with ssh -D), forward proxies and HTTPS_PROXY, bastions vs SSM, and VLANs and VXLAN overlays that separate traffic on shared hardware.

  1. 1
  2. 2
  3. 3
  4. 4
  5. 5
  6. 6
  7. 7
  8. 8
  9. 9
  10. 10
  11. 11
  12. 12
  13. 13
  14. 14
  15. 15
  16. 16
  17. 17
  18. 18
  19. 19
  20. 20
  21. 21
  22. 22
  23. 23
  24. 24
  25. 25
  26. 26
  27. 27
  28. 28
  29. 29
  30. 30
  31. 31
  32. 32
  33. 33
  34. 34
  35. 35
  36. 36
  37. 37
  38. 38
  39. 39
  40. 40
  41. 41
  42. 42
  43. 43
  44. 44
  45. 45
1 / 11

Press play to hear the narration, or step through at your own pace.

Key takeaways

  • Tunnels wrap packets
  • site-to-site vs client
  • ssh -L and -D (tested)
  • HTTPS_PROXY, NO_PROXY
  • bastion, SSM
  • VLAN, VXLAN

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.

The idea
  • 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.

Know these
  • 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.

Our run
$ 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.

Our run
$ 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.

Environment variables
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.

Options
  • 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.

Separation
  • 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.

Avoid these
  • 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.

In the interview
  • "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."

Interview questions

Q1What is the difference between a site-to-site VPN and a client VPN?

Site-to-site permanently links two networks (office and VPC) through gateways; a client VPN connects an individual device into a private network.

Q2What does ssh -L do?

Local port forwarding: connections to a local port are carried through the SSH session and opened from the server to a target host and port.

Q3What does ssh -D do?

It starts a local SOCKS proxy; applications using it have their connections made from the SSH server, as a dynamic tunnel.

Q4What is NO_PROXY for?

It lists hosts, domains and ranges that must bypass the proxy, such as localhost, internal domains and VPC CIDRs.

Q5Bastion host vs AWS SSM Session Manager?

A bastion needs an inbound SSH port and key management; Session Manager needs no inbound ports, uses IAM for access and logs sessions centrally.

Q6What is the difference between a VLAN and VXLAN?

A VLAN tags Ethernet frames (about 4094 IDs) on a physical network; VXLAN encapsulates L2 frames in UDP across L3 networks with 16 million IDs.