Blog

WireGuard AllowedIPs: two jobs, six mistakes

AllowedIPs chooses the peer for each packet WireGuard sends and drops received packets from addresses a peer may not use. We broke it six ways and logged each.

Published November 25, 2026 · 17 minutes read

Key takeaways

  • wg set gave a second peer the same range in silence; wg show listed it under that peer only, in 3 of 3 runs.
  • With 0.0.0.0/0 and no ::/0, all 3 IPv6 test pings left outside the tunnel while IPv4 went through it.
  • To leave one /n block out of IPv4 AllowedIPs you write exactly n prefixes: 16 for 192.168.0.0/16, 32 for one address.
  • AllowedIPs does two jobs: it picks the peer for each packet WireGuard sends and drops received packets from sources that peer may not use.
  • rx_errors on our Linux server counted all 5 pings dropped for a disallowed source; the wg show transfer counted none.
On this page (15)

On 25 November 2026 we gave one range, 10.20.0.0/24, to two WireGuard peers with wg set, the command that changes a running interface. Silence. The first peer lost the range and every ping went to the second. On one interface, each AllowedIPs range has one owner: the peer that receives traffic sent to it and may send traffic from it.

The wg(8) manual does not mention it. Below are six ways to get the setting wrong, the mark each leaves on a tunnel, and the review in which two routes beat the default route in our own router package, before its first release.

AllowedIPs is a list of address ranges kept for each peer, and it does two jobs. Going out, WireGuard hands a packet to the peer whose range matches longest, and refuses it when no range matches. Coming in, it discards a decrypted packet if its source address lies outside the sending peer's ranges. The operating system's routing table is a different list, which wg-quick (the script that brings an interface up from a .conf file) fills in for you.

How does WireGuard use AllowedIPs?

One list serves two purposes: it selects the peer for an outgoing packet, and it decides whether an incoming packet is kept. The WireGuard site describes this as a routing table when sending and an access control list when receiving, and calls the whole arrangement cryptokey routing.

Prefix and longest match
A prefix such as 10.20.0.0/16 pins the first 16 bits of an address and leaves the rest open. If several prefixes contain an address, the one with the most pinned bits wins.

Follow one packet addressed to 10.20.0.7:

  1. The routing table of the operating system sends it to the WireGuard interface.
  2. WireGuard compares the destination with the AllowedIPs of every peer and takes the longest match.
  3. The packet is encrypted for that peer and sent.

Receiving runs the same table in reverse. A packet arrives and is decrypted with peer A's key. WireGuard reads its source address and keeps it only when the match is A.

Sending

  1. Packet for 10.20.0.7
  2. Routing table: dev wg-c
  3. Longest match in AllowedIPs: peer B
  4. Encrypted to B

Receiving

  1. Packet from peer A
  2. Decrypted with A’s key
  3. Source inside A’s AllowedIPs?
  4. Kept, or dropped and counted in rx_errors
One list, two questions: who gets a sent packet, and may a received one stay

Quantum is the tunnel engine we build for ForestVPN, and its table works the same way: a lookup returns the longest match. The code is in the overlap section below.

What belongs in AllowedIPs on a client and on a server?

For a client, write the destinations that should enter the tunnel: 0.0.0.0/0 and ::/0 for all traffic, or a single subnet such as a home network. For a server, write each client's tunnel address as a /32 (a /128 for IPv6), plus any network that sits behind that client.

SideTypical AllowedIPsWhat it does
Client0.0.0.0/0, ::/0, or 10.8.0.0/24Chooses which destinations enter the tunnel
ServerIts own /32 per client, such as 10.8.0.2/32Fixes which source address that client may use

That asymmetry follows from the two jobs. A server entry works mostly as a source filter, and a client entry mostly as a destination choice.

It also sets a trap. Give two clients 0.0.0.0/0 as their only entry on one server, and the one configured last owns every address: replies to both go to it, and the other's packets are dropped for their source. We measured the two halves separately, the move with a /24 shared by two peers and the drop with a server entry that missed the client's address; neither depends on the prefix length.

What does each AllowedIPs mistake look like?

Each one leaves its own mark, and none needs a packet capture to read. The table lists the six we reproduced. The order is ours: we gathered no counts of how often each happens.

MistakeSymptomWhere to lookOur run (3 runs)
A route sends traffic into the tunnel, yet no peer covers its destinationping says Destination Host Unreachable and names your own tunnel address; the socket call says Required key not availablePeer transfer in wg show does not move0 of 3 pings answered, +3 errors
The range sits in AllowedIPs but Table = off left no routePackets leave by your normal gateway unencrypted (ours answered Destination Net Unreachable)ip route get shows the physical interface0 of 3 answered, tunnel rx0/tx0
One range on two peersSilence; the peer set last takes the trafficwg show allowed-ips no longer lists the range under the other peer (ours printed (none))3 of 3 pings reached the last peer
Server entry misses the client's addressHandshake completes, replies never comeServer rx_errors; debug line unallowed src IP0 of 5 answered, rx_errors 5
0.0.0.0/0 and no ::/0IPv6 still works, but outside the tunnelip -6 route get shows the physical interface3 of 3 IPv6 pings answered outside
Another default route added to a table that has oneFile exists at equal metric; at metric 10 it is accepted and ignoredip route get still shows the first route10 of 10 pings stayed on the first route
How we broke AllowedIPs
What ran
the in-kernel WireGuard module with the stock wg and wg-quick tools from wireguard-tools; open source; no ForestVPN code and no ForestVPN account
Versions
Ubuntu 26.04.1 LTS, kernel 7.0.0-43-generic, wireguard-tools 1.0.20250521-1ubuntu1, iproute2 6.19.0
Machines
one virtual machine; four network namespaces (a client, two WireGuard servers, one plain host standing in for the internet); fresh namespaces and fresh keys for every run
Runs
11 setups, 3 runs each, 25 November 2026; every recorded field agreed in 3 of 3 once ping times were removed
Who answered
echo-request counters (nstat) on each server and on the plain host
Addresses
private ranges and documentation ranges (198.51.100.0/24, 2001:db8::/32)
Not tested: other operating systems, roaming, NAT, PersistentKeepalive, wireguard-go, routers.

Every measurement dated 25 November in this post comes from this setup.

Counter fingerprints for a tunnel that handshakes and then goes quiet are in WireGuard handshake but no traffic. Here we read error strings, wg show allowed-ips and ip route get.

How does WireGuard choose between overlapping AllowedIPs?

The longest matching prefix wins, no matter which peer was added first. Say peer A holds 0.0.0.0/0 and peer B holds 10.20.0.0/16: a packet for 10.20.0.7 goes to B, and one for 198.51.100.7 goes to A.

Two longest-match lookups run back to back. The kernel routing table goes first: ip route get 10.20.0.7 printed dev wg-c from the main table, thanks to wg-quick's /16 route, while 198.51.100.7 printed dev wg-c table 51820. WireGuard's own table then picks the peer. What each round of three pings did to the wg show counters, identical in all three runs:

  • To 10.20.0.7: B moved from rx0/tx0 to rx476/tx532; A stayed at 0.
  • To 198.51.100.7: A moved from rx0/tx0 to rx476/tx532.
  • After wg set took the /16 off B (it kept 10.8.0.1/32), the ping to 10.20.0.7 reached A instead, which grew from rx476/tx532 to rx860/tx916.

The byte counts add up, so nothing else was moving. By our reading of the format, each ping request or reply counts as 128 bytes in wg show: the 84-byte IPv4 packet padded to 96, plus 32 bytes of WireGuard header and tag. The counter leaves out the outer UDP and IP headers.

Then 476 = 92 + 3 × 128 (the handshake response plus three replies), and 532 = 148 + 3 × 128 (the initiation plus three requests). The next round adds exactly 384 to each side, so no new handshake was needed.

Quantum's lookup is the same idea in three lines (Rust, trimmed):

pub fn find(&self, key: IpAddr) -> Option<&D> {
    self.ips.longest_match(key).map(|(_net, data)| data)
}

What happens when two peers share an AllowedIPs range?

The range moves to whichever peer was set last, with no error and no warning. The loser keeps its keys and its session, but nothing is sent to it for that range, and packets it sends from that range are dropped.

We ran four steps:

  1. wg set gave peer A 10.20.0.0/24. It returned 0, and A answered.
  2. wg set gave peer B the same range and returned 0. wg show allowed-ips then read A= (none) | B= 10.20.0.0/24, and the ping went to B: A stayed at rx476/tx532 while B went from rx0/tx0 to rx476/tx532.
  3. Setting A again handed the range back. A grew from rx476/tx532 to rx860/tx916, and B did not change.
  4. With a config file loaded by wg setconf, the last [Peer] block that names the range keeps it. File order A, B ended with B; order B, A ended with A.

wg set returned 0 and printed nothing. That was the whole warning.

The same-range run, trimmed (rtt lines removed; keys never printed)
ROW> s1_wgset_A_rc = rc=0
ROW> s1_A_only_allowed = A= 10.20.0.0/24 | B= 10.31.0.1/32 |
ROW> s1_A_only_transfer_after = A=rx476/tx532 B=rx0/tx0
ROW> s2_wgset_B_rc = rc=0
ROW> s2_B_after_A_allowed = A= (none) | B= 10.20.0.0/24 |
ROW> s2_B_after_A_transfer_after = A=rx476/tx532 B=rx476/tx532
ROW> s3_wgset_A_rc = rc=0
ROW> s3_A_again_allowed = A= 10.20.0.0/24 | B= (none) |
ROW> s3_A_again_transfer_after = A=rx860/tx916 B=rx476/tx532

A single owner per range is what makes the outbound lookup return one answer, so the table has no way to share a range. A 2019 mailing-list thread reported the same silence from wg setconf, with only one peer left holding the range; our run shows which one. Quantum's table also keeps one owner per prefix, since inserting a prefix that already exists replaces its value.

The peer that lost the range may still show a recent handshake. That age says nothing about data, as our counters post shows.

What does "Required key not available" mean in WireGuard?

On Linux it means a route handed the packet to the WireGuard interface, but no peer's AllowedIPs holds its destination, so the kernel encrypts and sends nothing. ping prints "Destination Host Unreachable" from your own tunnel address, and the system call fails with errno 126, ENOKEY.

To get there we gave the client AllowedIPs 10.8.0.0/24 and added the route 198.51.100.0/24 dev wg-c by hand. The kernel then passed packets for 198.51.100.7 to WireGuard, which had no peer to take them (output trimmed: icmp_seq 2 and 3 repeat the same two lines):

PING 198.51.100.7 (198.51.100.7) 56(84) bytes of data.
From 10.8.0.2 icmp_seq=1 Destination Host Unreachable
ping: sendmsg: Required key not available
3 packets transmitted, 0 received, +3 errors, 100% packet loss, time 2029ms

A UDP sendto to the same address failed the same way. Transfer stayed at rx0/tx0, and a control ping to 10.8.0.1, which a peer does cover, got 3 of 3.

With no route at all, the failure reads "Network is unreachable" instead, covered in why a handshake does not complete. AllowedIPs can break traffic even when the handshake finishes cleanly.

Why does traffic skip the tunnel even though the range is in AllowedIPs?

Because WireGuard itself creates no routes: on Linux, wg-quick writes them from AllowedIPs, and Table = off or a bare wg setup leaves them to you. When nothing in the routing table points a destination at the WireGuard interface, the packet follows your ordinary default route and leaves outside the tunnel.

We used one entry, 10.20.0.0/16, in two setups. With wg-quick's default the main table gained 10.20.0.0/16 dev wg-c, ip route get 10.20.0.7 printed dev wg-c, and the server answered 3 of 3.

Under Table = off, wg show still listed the range, but ip route get 10.20.0.7 printed via 10.0.2.2 dev u0. Ping said From 10.0.2.2 ... Destination Net Unreachable three times, and the tunnel stayed at rx0/tx0.

The packet did leave, unencrypted: our plain host was the client's default gateway, and it answered "Net Unreachable" only because it had no route to 10.20.0.0/16. On a live network your gateway would pass it on. Our handshake post met the same case with a client whose AllowedIPs was too narrow: pings past the server failed, and none of them entered the tunnel.

A route with no AllowedIPs fails with a specific error (the previous section); AllowedIPs with no route fails only with a generic "Net Unreachable", or not at all.

Where does WireGuard count a packet dropped for its source address?

In Linux's kernel WireGuard, the drop lands in the receiving interface's rx_errors (ip -s link show wg0), not in the transfer figures of wg show. The kernel log mentions it only with dynamic debug on. Five pings from a client that the server's AllowedIPs left out raised the server's rx_errors to 5, while its transfer stayed at the handshake alone.

On the server we allowed 10.8.0.99/32 for the peer while the client used 10.8.0.2, and all five pings were lost. The server read rx148/tx92 (handshake initiation in, response out) and the client rx92/tx788; 788 = 148 + 5 × 128. On the server, ip -s link show wg-a counted 5 receive errors and 0 drops.

With debug logging on, the kernel wrote Packet has unallowed src IP (10.8.0.2) from peer N (addr) four times in each of the three runs (peer number and address redacted).

Two admissions. Our handshake post found this rx_errors increment in the kernel source and said ip -s link should show it; now we have watched the counter move.

And four log lines for five dropped packets is unexplained, so believe rx_errors, not the line count. One explanation fits but is untested: each run printed exactly 10 WireGuard debug lines (six handshake and key lines plus the four drops), and the kernel's shared limit for these messages is 10 per five-second window by default.

Why does IPv6 stay outside a tunnel set to 0.0.0.0/0?

0.0.0.0/0 means IPv4 and only IPv4. Without ::/0, wg-quick installs no IPv6 rules, so IPv6 takes your usual IPv6 route. In our run all 3 IPv6 pings were answered by the plain host outside the tunnel; IPv4 went through it.

The caveat: our client had a working IPv6 route outside the tunnel, so IPv6 escaped rather than failing. With 0.0.0.0/0 alone, the IPv6 rule list held only local and main, and ip -6 route get 2001:db8:77::7 printed via 2001:db8:2::2 dev u0, the physical link. The plain host counted 3 IPv6 echo requests and the server none; the tunnel transfer stayed at rx476/tx532.

Adding ::/0 changed it. The IPv6 rules appeared, the route became dev wg-c table 51820, and the server counted all 3 IPv6 echo requests, the plain host none. IPv4 used the tunnel both times.

In ForestVPN, when a session has no IPv6 address, or Block IPv6 is on in our Windows or Linux app, our shared client code leaves ::/0 out of the peer's list, so an IPv6 packet the device sends into the tunnel is not carried. We did not measure which error the device then shows. For how IPv6 escapes and how to test for it, read IPv6 leaks and IPv6, DNS and MTU.

Why does wg-quick give 0.0.0.0/0 a routing table of its own?

wg-quick moves the tunnel's default route into a table of its own so that WireGuard's own encrypted packets can still leave over your regular default route. wg-quick tags them with fwmark 51820 (0xca6c), sends every untagged packet to table 51820 (one entry, default dev wg-c), and adds a rule that tries longer main-table routes, your LAN for one, before that.

suppress_prefixlength 0 means "use the main table, unless its answer is the default route".

An older recipe in the WireGuard routing guide uses no rules: it adds two routes by hand, 0.0.0.0/1 and 128.0.0.0/1 through the WireGuard interface. Each is longer than the default and together they span IPv4, so they are matched first. The price is an explicit route to the server's own address through your old gateway, which the guide says is forgotten when that interface goes down and up.

OpenVPN's redirect-gateway def1 uses the same pair, according to the OpenVPN 2.6 reference manual. Type the pair as AllowedIPs, and wg-quick writes the same two routes for you.

For a /0, the wireguard-tools source writes the rules; it writes /1 routes only when you type them. Our run shows the two side by side:

One machine, AllowedIPs written two ways (output trimmed and annotated)

0.0.0.0/0

32764: from all lookup main suppress_prefixlength 0
32765: not from all fwmark 0xca6c lookup 51820
main:        default via 10.0.2.2 dev u0
table 51820: default dev wg-c scope link
ip route get 198.51.100.7: dev wg-c table 51820
10 of 10 pings reached the server

0.0.0.0/1 + 128.0.0.0/1

rules: only local, main, default (none added)
main:        0.0.0.0/1 dev wg-c
             128.0.0.0/1 dev wg-c
             default via 10.0.2.2 dev u0
table 51820: FIB table does not exist
ip route get 198.51.100.7: dev wg-c
10 of 10 pings reached the server

The first tab goes around your default route and leaves it standing; the second outranks it. A limit on the second tab: our servers sat on directly connected links, so the route to the server was more specific than either /1 and the endpoint problem could not appear. It is listed as unmeasured below.

Does a pair of /1 routes override a default route?

Within one routing table, yes: two /1 routes are each longer than the /0, and between them they cover every IPv4 address. The kernel weighs prefix length before metric, so once the pair went in on our test machine, all 10 pings moved to the WireGuard interface.

Two /1 routes cover the same addresses as one default, so in one table they always match first

We gave the client a routing table 100 that already held default via 10.0.2.2 dev u0, and added the tunnel's routes a step at a time:

  1. Adding default dev wg-c at an equal metric failed: RTNETLINK answers: File exists (rc=2).
  2. At metric 10 it was accepted, but ip route get still chose via 10.0.2.2 dev u0, and 10 of 10 pings reached the plain host.
  3. With that route deleted and both /1 routes added to the same table, route get printed dev wg-c table 100, and 10 of 10 pings reached the server behind the tunnel.

A second /0 loses to the first unless its metric is lower. Two /1 routes win whatever the metrics say.

Can two /1 routes pull traffic out of a router's VPN table?

They can, and review caught them doing it in a pre-release draft of our OpenWrt package (the ForestVPN client for OpenWrt routers). The package keeps a separate routing table for the traffic it protects, and that table's one default route points into our tunnel. To let peers of a WireGuard server on the router reach home hosts, that draft copied the gateway-less routes of every LAN-zone device into the table.

Then review put a tunnel in the LAN zone with 0.0.0.0/1 and 128.0.0.0/1. Both halves were copied, both beat our default, and probes took the wrong road: 10 of 10 from a protected client and 10 of 10 from a peer of the router's WireGuard server left through that tunnel, none through ours.

Our own draft let two /1 routes win (review of 5 October 2026)

Our kill switch was meant to hold whatever the routing table said. Copying LAN routes into its table made it trust routes, and two /1 routes were enough to carry protected traffic past it. The review caught it with counters, not by reading.

Review used an ipip tunnel as its stand-in, not WireGuard. The reasoning was that a WireGuard client with the same ranges, under OpenWrt's route_allowed_ips, would do likewise; the table 100 steps above show the same effect with routes into a kernel WireGuard interface, though not under OpenWrt.

The fix went in that same day, ahead of the first package on 7 October. New rule: any device with a default route, a split default or a route into public space counts as an uplink, and gets no LAN allowance.

A kill switch on a router stops what its own rules name. Another VPN client on that router can still route its traffic its own way. Our OpenWrt kill switch page shows what ours blocks, and running another VPN on the same router covers the second client. How the package picks devices is in OpenWrt VPN for specific devices.

How can you exclude an IP range from WireGuard AllowedIPs?

There is no "except" in AllowedIPs, so you write the prefixes that cover everything else. Leaving a /n block out of IPv4 costs exactly n prefixes: 16 for 192.168.0.0/16, 32 for one address. On Linux, one route for that block through your normal gateway is the shorter tool: wg-quick's suppress_prefixlength 0 rule lets any main-table route longer than the default win.

Counts come from Python's ipaddress module. Leaving out 10.0.0.0/8 or 127.0.0.0/8 takes 8 prefixes; 172.16.0.0/12 takes 12; 192.168.0.0/16 and 169.254.0.0/16 take 16 each; one /24 takes 24 and one /32 takes 32. IPv6 follows the same rule: fd00::/8 takes 8.

Everything exceptprefixes

  • 10.0.0.0/88
  • 172.16.0.0/1212
  • 192.168.0.0/1616
  • 169.254.0.0/1616
  • 127.0.0.0/88
  • The three private ranges together31
  • 192.168.1.0/2424
  • 192.168.1.1/3232
Prefixes needed to write everything except one block, IPv4, computed 25 November 2026. A /n block costs n prefixes; the three private ranges together cost 31.
Show the data
GroupSeriesValue, prefixesRange
Everything except10.0.0.0/88
Everything except172.16.0.0/1212
Everything except192.168.0.0/1616
Everything except169.254.0.0/1616
Everything except127.0.0.0/88
Everything exceptThe three private ranges together31
Everything except192.168.1.0/2424
Everything except192.168.1.1/3232
Everything except 192.168.0.0/16, as AllowedIPs (16 prefixes, Python ipaddress)
0.0.0.0/1, 128.0.0.0/2, 192.0.0.0/9, 192.128.0.0/11, 192.160.0.0/13, 192.169.0.0/16, 192.170.0.0/15, 192.172.0.0/14, 192.176.0.0/12, 192.192.0.0/10, 193.0.0.0/8, 194.0.0.0/7, 196.0.0.0/6, 200.0.0.0/5, 208.0.0.0/4, 224.0.0.0/3

All three private ranges together take 31, not 8 + 12 + 16 = 36. Cutting a /n block out of a /m prefix swaps 1 prefix for n − m. So: 8 for the first, then 8 − 1 + 11 = 18 (the /12 lies inside a /1 by then), then 18 − 1 + 14 = 31 (the /16 lies inside a /2).

Under wg-quick and 0.0.0.0/0, a directly connected LAN normally stays outside the tunnel anyway, for the same reason: its connected route is longer than the default. We did not ping a LAN host in this run. Our Linux app leaves a range out with a single throw route in its own table rather than a prefix list, which the split tunneling post shows; app-level splitting is that post's subject.

Which four commands find an AllowedIPs mistake?

Three of the six mistakes print no error at all: the shared range, the missing ::/0 and the source outside the range. These four commands read the state instead, in this order:

  1. ip route get <destination>: does the packet reach the WireGuard interface at all? Trouble is your physical interface and gateway (in our Table = off run, via 10.0.2.2 dev u0).
  2. wg show <interface> allowed-ips: which peer owns the range? Trouble is (none), or the range listed under another peer.
  3. ip -s link show <interface> on the receiving end: trouble is rx_errors rising while the wg show transfer stands still.
  4. ip -6 route get <IPv6 destination>: trouble is your physical interface.

What don't we know yet?

  • Other systems: We measured kernel WireGuard on Linux only: no wireguard-go, Windows, macOS, Android or iOS client, and not how their apps turn AllowedIPs into routes.
  • Endpoint inside a /1: The two /1 ranges cover every IPv4 address, the server's included, so unless a more specific route sends the server's address to the old gateway, the handshake itself is routed into the tunnel. Our servers sat on directly connected links, so we never reproduced it.
  • The fifth drop: Four "unallowed src IP" log lines appeared for 5 dropped packets, while rx_errors read 5 in every run. One untested explanation fits: each run printed exactly 10 WireGuard debug lines in all, and the kernel's shared limit for these messages is 10 per five-second window by default.
  • MikroTik: RouterOS calls the list allowed-address, and we did not re-measure it here. Our MikroTik WireGuard post covers the router side.
  • Frequency: We collected no counts from forums or help requests, so we cannot say which mistake is common.

See also: Self-hosted WireGuard vs a VPN service, ForestVPN compared with WireGuard.

Questions and answers

Does AllowedIPs work the same in the WireGuard app on Android?

The two jobs are the same in every WireGuard implementation. What differs is how the ranges become routes: on Linux, wg-quick writes routes (plus policy rules for 0.0.0.0/0), while the Android app hands them to Android's VPN routing. We measured Linux only, so we cannot show Android's error messages or counters.

Is MikroTik's allowed-address the same as AllowedIPs?

It is the same per-peer list and does the same two jobs. In our MikroTik post the built-in WireGuard interface does nothing you did not write, so you add the route yourself. We did not re-measure RouterOS for this post.

Sources

  1. WireGuard: Cryptokey Routing (read November 25, 2026)
  2. WireGuard: Routing and network namespace integration (read November 25, 2026)
  3. wg(8) manual page (read November 25, 2026)
  4. wg-quick(8) manual page (read November 25, 2026)
  5. wireguard-tools: src/wg-quick/linux.bash (read November 25, 2026)
  6. OpenVPN 2.6 reference manual (read November 25, 2026)
  7. WireGuard mailing list: Overlapping AllowedIPs Configuration (2019) (read November 25, 2026)

How this was made

AI-assisted drafting from our own test runs of 25 November 2026 and our OpenWrt package review of 5 October 2026, checked against the raw output and code, with automated and editorial review.

All posts

Back to top

Ask us anything