Skip to content

Lesson 2 of 9 · 26m

Designing Hub-and-Spoke, Mesh, and Gateway Topologies

Choose peer relationships deliberately, assign address space cleanly, and avoid turning a VPN overlay into an ungoverned second production network.

A WireGuard mesh is easy to draw and painful to operate when nobody owns its addressing, trust boundaries, or failure behavior. I have seen overlays grow from five servers to three hundred peers until every host theoretically trusted every other host and nobody could answer a basic question: should the finance laptop really be able to reach the database subnet directly? Topology is policy. Draw it before generating keys.

Start with reachability classes

Most organizations do not need a flat mesh. They need a few classes of reachability:

admin devices       bastions and control plane
servers             service-specific gateways and peers
developers          dev environment gateways
contractors         narrow project enclaves
monitoring          metrics and health endpoints only

Hub-and-spoke is usually the right starting point. Devices connect to gateways; gateways expose selected subnets. Full mesh is attractive for server-to-server traffic because it removes central bandwidth bottlenecks, but peer count and change coordination grow quickly.

Address space is an operations decision

Use a dedicated, non-overlapping overlay range and document allocation rules:

10.44.0.0/24     access gateways
10.44.1.0/24     staff workstations
10.44.2.0/24     production servers
10.44.3.0/24     development servers
10.44.240.0/24   temporary contractors

A /32 interface address with peer routes is common because it forces explicit routing intent. Do not casually overlap RFC1918 space already used by cloud VPCs, Docker defaults, home routers, or acquired companies. The worst conflicts appear only after a user tries to print from a hotel network.

Gateways need routing discipline

A Linux gateway must forward deliberately:

sysctl -w net.ipv4.ip_forward=1
sysctl -w net.ipv6.conf.all.forwarding=1
iptables -t nat -A POSTROUTING -s 10.44.1.0/24 -o eth0 -j MASQUERADE

Prefer routed access over broad NAT where possible. NAT makes client traffic look like gateway traffic, which weakens audit trails and complicates least-privilege firewalling. If NAT is unavoidable, log translation boundaries and preserve original overlay addresses in application or flow telemetry.

Mesh does not mean everyone-to-everyone

Even in a full mesh, AllowedIPs should express intended reachability. A database server may peer with application servers but not with laptops. A contractor device may peer only with a project gateway. Resist the convenience of importing every generated peer into every config.

Field notes

  • Count peer-change fanout. In a full mesh, adding one node can mean updating every node.
  • Use separate gateways for administrative and ordinary application access; compromise blast radius matters.
  • Overlay DNS names should encode role and environment, not just host owner preference.
  • Draw the offline behavior: what happens when a gateway is unavailable or a peer key is stale?

Was this lesson helpful?

Sign in to rate