Two WireGuard server configs that look equally wrong behave very differently. I checked both against the real kernel module before changing what my config checker says about them, because the checker was wrong on one of the two.
Test bed: Linux 6.8, wireguard-tools v1.0.20210914, a throwaway network namespace, a server interface wg0 at 10.8.0.1/24 and two peers with fake endpoints on 127.0.0.1. Which peer a packet is routed to is read from wg show wg0 transfer: the peer whose sent counter moves is the one the kernel picked.
Case 1: the same range on two peers
A common copy-paste mistake on the server side: every [Peer] block gets AllowedIPs = 10.8.0.0/24.
wg set wg0 peer <peer1> allowed-ips 10.8.0.0/24 wg set wg0 peer <peer2> allowed-ips 10.8.0.0/24 wg show wg0 allowed-ips Result:
peer1 (none) peer2 10.8.0.0/24 The kernel keeps one owner per exact range. The peer set last takes it, the first one is left with nothing. With wg-quick the peers are loaded in file order, so the last [Peer] in the file wins. The first device still completes its handshake (handshakes do not depend on AllowedIPs), but the server never routes anything to it and drops what it sends: "handshake OK, no traffic".
Fix: one /32 per client on the server.
[Peer] # laptop AllowedIPs = 10.8.0.2/32 [Peer] # phone AllowedIPs = 10.8.0.3/32 Case 2: a /24 next to a /32
Now the laptop got AllowedIPs = 10.8.0.2/24 (a client address written with the subnet prefix) and the phone got a correct 10.8.0.3/32.
wg prints Warning: AllowedIP has nonzero host part: 10.8.0.2/24 and stores 10.8.0.0/24. Then I pinged four addresses from the server, one fresh namespace per ping, and read which peer sent the handshake:
| Destination | Peer that got the packet |
|---|---|
| 10.8.0.2 | peer1 (laptop, 10.8.0.0/24) |
| 10.8.0.3 | peer2 (phone, 10.8.0.3/32) |
| 10.8.0.9 | peer1 |
| 10.8.0.200 | peer1 |
Nothing breaks today. Routing is longest prefix match, so the phone keeps its /32 whatever the order of the blocks. The trap is for later: every address of the subnet that has no line of its own goes to the laptop. Add a third client and forget its [Peer] on the server, and its traffic quietly goes into the laptop's tunnel. And the server accepts packets coming from the laptop with any source address in 10.8.0.0/24, so the laptop can speak as any future client.
So case 1 is an error (a device is cut off right now) and case 2 is a warning (it works, but the server trusts the laptop with the whole subnet).
What my checker said before, and now
I run a free config checker at wg.vpnsmith.com/check. Until today it reported both cases with the same message, "the last peer loaded takes the shared addresses". That is true for case 1 only. In case 2 the phone was never at risk. Same story for AllowedIPs = 0.0.0.0/0 on a server peer: the old text said it "starves the others", but clients that have their own /32 keep their traffic. It is every other address that goes to that peer.
Output now, for the case 1 file:
[error] AllowedIPs 10.8.0.0/24 is given to peer 1 and peer 2. wg keeps one owner per range: the peer loaded last (peer 2) takes it and peer 1 silently loses it, the classic "handshake OK, no traffic" bug. And for case 2, a single warning on the laptop line, with the replacement to paste:
[warn] AllowedIPs 10.8.0.2/24 has host bits set. wg turns it into 10.8.0.0/24: every address of that range without a more specific line goes to this one peer. Paste instead: AllowedIPs = 10.8.0.2/32 One more correction: Address = 10.8.0.1/32 on the server
The checker also warned that a server Address in /32 stops clients from reaching each other. With wg-quick that is not true: it adds one route per peer AllowedIPs (ip route add 10.8.0.2/32 dev wg0 and so on), so client to client traffic is routed. It only bites when the interface is brought up by hand with ip commands or by a tool that routes the Address prefix alone. That finding is now a note instead of a warning, and the "outside the server subnet" warnings it used to drag along on every peer are gone.
Reproduce it
You need root and the wireguard module, nothing else.
ip netns add wgt && ip -n wgt link set lo up ip -n wgt link add wg0 type wireguard wg genkey > s.key ip netns exec wgt wg set wg0 private-key s.key listen-port 51820 ip netns exec wgt wg set wg0 peer $(wg genkey | wg pubkey) allowed-ips 10.8.0.2/24 endpoint 127.0.0.1:40001 ip netns exec wgt wg set wg0 peer $(wg genkey | wg pubkey) allowed-ips 10.8.0.3/32 endpoint 127.0.0.1:40002 ip -n wgt addr add 10.8.0.1/24 dev wg0 && ip -n wgt link set wg0 up ip netns exec wgt ping -c1 -W1 10.8.0.9 ip netns exec wgt wg show wg0 transfer ip netns del wgt The peer with a non-zero second column after the ping is the one the kernel chose. Reuse the namespace for a second ping and the counter will not move again: the first handshake is still pending, so start a new namespace for each destination.
If you are computing AllowedIPs for a client (full tunnel except the LAN, several subnets), the AllowedIPs calculator does the subtraction. Paste a server or client file into the checker and it is checked in the browser: the file is not uploaded, only a run counter is sent.