Skip to content

Lesson 8 of 9 · 26m

WireGuard Beyond the Happy Path

Configure peers, routes, keys, endpoints, NAT traversal, and MTU with the operational details that decide whether WireGuard actually carries traffic.

WireGuard is refreshingly small, which tempts people to treat it as simple. It is simple in design, not immune to operational mistakes. Most broken WireGuard deployments come down to four things: wrong keys, wrong AllowedIPs, no return route, or UDP filtered somewhere along the path. The protocol will not negotiate around those mistakes for you.

Keys are identity, endpoints are location

A minimal interface configuration:

[Interface]
PrivateKey = 4F3w...
Address = 10.8.0.2/24
ListenPort = 51820

[Peer]
PublicKey = qP7x...
AllowedIPs = 10.8.0.1/32, 172.16.0.0/16
Endpoint = vpn.example.net:51820
PersistentKeepalive = 25

The private key stays local; the peer public key identifies the remote side. Endpoint is where this peer sends encrypted UDP. AllowedIPs is both a routing selector and a cryptographic access-control list. If a packet's destination does not match a peer's AllowedIPs, WireGuard will not send it to that peer. If inbound traffic claims a source outside AllowedIPs, it is not accepted as that peer.

Inspect the live interface, not only the config

sudo wg show
sudo wg show wg0 latest-handshakes
sudo wg show wg0 transfer

The output gives endpoint, handshake age, transfer counters, and AllowedIPs. No handshake means packets are not being authenticated successfully — usually endpoint reachability, key mismatch, or firewalling. Handshake present but zero received traffic means the encrypted channel works one way while routing or return policy fails.

Routes still matter

Adding Address = 10.8.0.2/24 normally creates a connected route for the tunnel subnet. It does not automatically route arbitrary networks through the tunnel. Tools such as wg-quick can add policy rules depending on Table, PostUp, and default-route tricks. Inspect before assuming:

ip route get 172.16.5.10
ip rule show
ip route show table all | grep -E 'wg0|172[.]16'

A split tunnel should have explicit routes for private networks. A full tunnel often uses policy routing so the encrypted default route does not recursively capture the endpoint traffic itself.

NAT and roaming are normal, not exceptional

WireGuard identifies peers by key, not source IP. Roaming works because a valid packet from a new endpoint can update the peer's endpoint. But UDP state in NAT and firewalls still expires. PersistentKeepalive = 25 is common for clients behind NAT because it keeps the outbound pinhole warm. It is not required on a stable server with a public address.

MTU is part of correctness

WireGuard overhead is typically around 80 bytes for IPv4. On a 1500-byte path, an interface MTU near 1420 is common. On already encapsulated paths, lower it further:

sudo ip link set dev wg0 mtu 1380
ping -M do -s 1352 -c 3 10.8.0.1

Small pings can succeed while TLS or bulk transfer stalls. Test payload size, not just reachability.

Field notes

  • AllowedIPs = 0.0.0.0/0 on the client does not magically make the server forward the client to the internet; forwarding and NAT still apply.
  • A peer without Endpoint can only be reached after it initiates traffic from a known address.
  • Key mismatches do not produce helpful plaintext errors at the application layer; handshake age is the truth.
  • WireGuard is layer 3 only. Do not expect broadcast, multicast service discovery, or ARP inside the tunnel.
  • wg-quick convenience commands can install routes and firewall rules; read /etc/wireguard/*.conf before debugging behavior manually.

Was this lesson helpful?

Sign in to rate