Skip to content

Lesson 4 of 9 · 25m

Site-to-Site WireGuard Links

How to connect two networks through WireGuard gateways with clean routing, NAT decisions, MTU planning, failover, and validation from both sides.

A site-to-site WireGuard link is not two laptops calling each other. It is two routers forwarding traffic for networks they represent, often with asymmetric internet paths, carrier NAT, stateful firewalls, and users who expect the link to behave like a private leased line. The design work is mostly routing and failure behavior.

The gateway represents its LAN

Assume the Chicago office LAN is 192.168.10.0/24 and the Austin LAN is 192.168.20.0/24. Each gateway owns a tunnel address:

# chicago-gw: interface 10.44.1.1/32
[Peer]
PublicKey = AUSTIN_PUBLIC_KEY
Endpoint = 203.0.113.20:51820
AllowedIPs = 10.44.1.2/32, 192.168.20.0/24
PersistentKeepalive = 25

# austin-gw: interface 10.44.1.2/32; invert the peer side
[Peer]
PublicKey = CHICAGO_PUBLIC_KEY
Endpoint = 198.51.100.10:51820
AllowedIPs = 10.44.1.1/32, 192.168.10.0/24
PersistentKeepalive = 25

The important line is not the endpoint. It is the peer's AllowedIPs including the remote LAN. That is what binds the remote gateway key to the network it may speak for.

Forwarding is explicit

Gateways must forward packets:

$ sysctl -w net.ipv4.ip_forward=1
$ sysctl -w net.ipv6.conf.all.forwarding=1

Persist it in /etc/sysctl.d/99-wireguard-forwarding.conf, then add firewall rules that permit forwarding only for intended site prefixes. Do not blindly open forwarding to the world:

$ nft add rule inet filter forward ip saddr 192.168.10.0/24 ip daddr 192.168.20.0/24 accept
$ nft add rule inet filter forward ip saddr 192.168.20.0/24 ip daddr 192.168.10.0/24 accept

LAN hosts need return routes

The tunnel being correct is only half the job. If a Chicago server receives traffic from 192.168.20.15, it needs a route back via chicago-gw. You have three options: static routes on the site router, a routing daemon such as FRR/BGP or OSPF, or NAT at the gateway so LAN hosts see a local source.

NAT is tempting because it avoids routing changes, but it destroys end-to-end identity and complicates logs, firewall policy, and incident response. Use it as an exception for legacy environments, not as the default design.

WireGuard adds encapsulation overhead. On a normal 1500-byte internet path, a tunnel MTU of 1420 is conventional. PPPoE, nested tunnels, cloud overlay networks, or jumbo-frame mismatches can lower the real ceiling. Symptoms are large transfers hanging while ping succeeds. Validate with non-fragmenting probes:

$ ping -M do -s 1372 10.44.1.2

Failover means detecting blackholes, not handshakes

A peer can maintain an endpoint while the LAN behind it is down. Health-check remote service IPs and route around failures using your routing daemon or a watchdog. Static equal-cost routes without health awareness create deterministic packet loss, not resilience.

Field notes

  • Verify from a LAN host, not only from the gateways. Gateways can have correct local routes while client traffic still fails.
  • Document which site owns which tunnel address and LAN prefixes before touching production.
  • Avoid overlapping RFC1918 networks early. Renumbering one site is painful but less painful than years of NAT exceptions.
  • Keep PersistentKeepalive on at least one side when stateful NAT or firewalls sit in the path.
  • Test large transfers, DNS, and small pings. Each exposes a different failure class.

Was this lesson helpful?

Sign in to rate