Lesson 3 of 9 · 26m
Interfaces, Peers, AllowedIPs, and Routes
The exact mechanics behind peer selection, route installation, anti-spoofing, overlapping ranges, and why most WireGuard routing bugs are actually AllowedIPs bugs.
Most WireGuard incidents described as “the tunnel is up but traffic does not flow” are neither cryptographic nor mysterious. They are peer-selection mistakes. WireGuard consults AllowedIPs before choosing a peer, and the kernel consults its routing table before choosing wg0 at all. You must make both decisions line up.
The forwarding decision happens twice
A packet to 10.44.10.20 first hits the ordinary route table:
$ ip route get 10.44.10.20
10.44.10.20 dev wg0 src 10.44.0.12Only after wg0 is selected does WireGuard search its peers for an AllowedIPs entry containing 10.44.10.20. If the route exists but no peer matches, the packet is dropped internally. If the peer exists but no route points into wg0, WireGuard is never consulted.
wg-quick often adds routes automatically from AllowedIPs. On hosts with complex policy routing, decide whether you want that convenience or explicit network control.
AllowedIPs is also source validation
For inbound traffic, AllowedIPs constrains which source addresses a peer may use. If 10.44.0.12/32 is assigned to a laptop peer and packets arrive over that peer claiming to be 10.44.0.99, WireGuard discards them. This is crypto-routing: the key authorizes specific addresses.
This is why a roaming laptop normally gets a narrow /32, while a site gateway gets the LAN prefixes it is allowed to represent:
# laptop peer
AllowedIPs = 10.44.0.41/32
# branch gateway peer
AllowedIPs = 10.44.0.8/32, 192.168.20.0/24Do not lazily use 0.0.0.0/0 everywhere. That is not flexibility; it is disabling a security boundary and inviting accidental default-route capture.
Look for the four classic mismatches
$ wg show wg0
peer: bN0rC3Wc4Q3Q0mK8sN6FjN6iE0Q6vH2r6mVhY8nQyD4=
endpoint: 203.0.113.9:51820
allowed ips: 10.44.10.0/24
latest handshake: 1 minute, 12 seconds ago
transfer: 18.2 MiB received, 4.7 MiB sentThen compare:
$ ip route | grep wg0
$ ip rule
$ ip route get 10.44.10.20The classics are: route missing, route pointing at the wrong table, overlapping peer ranges, and asymmetry where return traffic uses another interface.
Overlaps create winner-take-all behavior
Two peers cannot both claim the same destination prefix. If one peer has 10.44.0.0/16 and another has 10.44.20.0/24, the more specific route logic may work in some contexts but creates operational ambiguity and often masks design errors. Treat overlap as a defect unless you can explain exactly why it exists.
Field notes
- Debug with
ip route get,wg show, and packet counters together. One command rarely tells the whole story. - A handshake with zero useful traffic often means crypto is fine and routing or source validation is wrong.
- On multi-homed hosts, inspect policy routing with
ip rule;wg-quickroutes may land in a table you are not reading. - Keep peer prefixes as narrow as the architecture permits. Narrow is debuggable; broad is magical.
Was this lesson helpful?