Skip to content
Dorian FINKEL
WireGuardVPNRoutingTutorial · 2026 · 4 min read · Updated 9 October 2026
Level · IntermediateDuration · 30 min

Linking two sites with a WireGuard tunnel

Two local networks that see each other as if they were neighbours: one WireGuard peer on each side, the remote networks in AllowedIPs, routes on the gateways, and close attention to MTU.

Prerequisites

  • A Linux machine or a WireGuard-capable gateway at each site
  • At least one site reachable from the Internet over UDP
  • Non-overlapping addressing plans

01The principle

In site-to-site mode, each peer stands for a whole network. AllowedIPs holds the peer’s tunnel address and the local network behind it. wg-quick then creates the matching routes, and WireGuard only accepts packets from the peer that come from those networks.

The two networks must differ: two sites both on 192.168.1.0/24 cannot reach each other without address translation. The addressing plan is decided before the tunnel.

02Site A

Site A, reachable from the Internet, waits for connections. The tunnel network is a /30: two addresses, one per site.

Example · /etc/wireguard/wg0.conf (site A)
[Interface]
Address = 10.9.0.1/30
ListenPort = 51820
PrivateKey = <site A private key>

[Peer]
# Site B: its tunnel address and its local network
PublicKey = <site B public key>
AllowedIPs = 10.9.0.2/32, 192.168.30.0/24

03Site B

Site B initiates the connection, which works even behind NAT or a changing address. PersistentKeepalive keeps its router’s NAT entry alive so site A can always reach it.

Example · /etc/wireguard/wg0.conf (site B)
[Interface]
Address = 10.9.0.2/30
PrivateKey = <site B private key>

[Peer]
# Site A
PublicKey = <site A public key>
Endpoint = sitea.example.com:51820
AllowedIPs = 10.9.0.1/32, 192.168.10.0/24
PersistentKeepalive = 25

04Routes and firewall

If the WireGuard machine is the site’s gateway, there is nothing more to do. Otherwise each site’s gateway needs a static route to the other network, via the WireGuard machine. On both machines, IP forwarding must be on, and the firewall must allow forwarding between wg0 and the LAN interface.

Example · Shell
# On site A's gateway, if it isn't the WireGuard machine
ip route add 192.168.30.0/24 via 192.168.10.2

# On both WireGuard machines
sysctl -w net.ipv4.ip_forward=1

05MTU

WireGuard adds 60 bytes of headers over IPv4 (80 over IPv6). wg-quick picks an MTU automatically, 1420 in the common case. Over PPPoE or behind another tunnel it may still be too large: typical symptom, ping works but web pages or transfers stall. Set MTU = 1412, or lower, in the [Interface] section.

06Verify

Example · Shell
wg show                       # recent handshake on both sides
ping 192.168.30.1             # from a host at site A
traceroute 192.168.30.10      # must go through 10.9.0.2
ping -M do -s 1372 192.168.30.10   # MTU test without fragmentation

Key takeaways

  • Each peer stands for a network: its tunnel address and its LAN in AllowedIPs.
  • Distinct addressing plans, decided before the tunnel.
  • The site behind NAT initiates, with PersistentKeepalive.
  • Static routes on the gateways if WireGuard isn’t the gateway.
  • Ping works but transfers stall: check the MTU.

Example domain and addresses.

Official sources