Solution:
Root Cause: Cryptokey Routing and AllowedIPs Mismatch
WireGuard enforces a fundamental security mechanism called
Cryptokey Routing. Each public key is mapped to a specific list of IP addresses (
AllowedIPs). When the server receives an inner packet from a client, it checks if the source IP matches the
AllowedIPs assigned to that client's
PublicKey. If the client uses an internal IP (e.g.,
10.0.0.5) not explicitly included in the server's
[Peer] definition, the server silently drops the packet.
# Diagnostic Verification:
Inspect client local assigned IP: ip addr show wg0 (e.g.,
inet 10.0.0.5/32)
Inspect server configuration for that client's peer block: sudo wg show wg0
Verify whether 10.0.0.5/32 is listed under allowed ips: for the matching peer.# Step-by-Step Fix:
1. Edit Server Interface Configuration:
Open /etc/wireguard/wg0.conf on the server.2. Adjust Peer AllowedIPs Definition:
Ensure the exact IP address assigned to the client is specified: ini
[Peer]
PublicKey = <CLIENT_PUBLIC_KEY>
AllowedIPs = 10.0.0.5/32
3. Adjust Client AllowedIPs Definition (Routing Full-Tunnel Traffic):
If the client intends to route all internet traffic through the VPN, set on client configuration: AllowedIPs = 0.0.0.0/0, ::/0
4. Synchronize Server State:
Reload configuration: sudo wg syncconf wg0 <(wg-quick strip wg0)# Prevention & Long-Term Monitoring:
Maintain strict static IP assignment tables for all WireGuard peers to avoid overlapping AllowedIPs subnets.