How to Check if Two CIDR Blocks Overlap
Two IPv4 CIDR blocks overlap when they share at least one IP address. Checking for overlap is one of the most common tasks in network planning — before peering VPCs, building VPN tunnels, or merging office networks. This guide shows two reliable methods, worked examples, and the mistakes that cause real outages.
What CIDR overlap means
Every CIDR block is a continuous range of addresses. 10.0.0.0/24 covers 10.0.0.0 through 10.0.0.255, and 10.0.0.128/25 covers 10.0.0.128 through 10.0.0.255. Because the second range sits entirely inside the first, the two blocks overlap. Two blocks are disjoint only when one range ends before the other begins.
Why CIDR overlap matters
- AWS VPC peering is rejected when the two VPCs have overlapping CIDR blocks, even partially.
- VPN tunnels route traffic to the wrong network when the remote subnet overlaps your local one.
- Merging office or data center networks with overlapping address plans causes routing conflicts that are hard to diagnose after the fact.
Method 1: compare address ranges
Convert each block to its start and end addresses. Two ranges overlap when:
a.start <= b.end AND b.start <= a.end
For 10.0.0.0/24: start 10.0.0.0, end 10.0.0.255. For 10.0.0.128/25: start 10.0.0.128, end 10.0.0.255. The first range’s start is before the second’s end, and the second’s start is before the first’s end — so they overlap. This test also catches containment, where one block sits entirely inside another.
Method 2: check whether one network start falls inside the other range
For each block, ask whether its network address lies within the other block’s range. In the example above, 10.0.0.128 (the start of the /25) lies inside 10.0.0.0/24, which immediately proves overlap. The caveat: you must test both directions, because either block can contain the other. When the two blocks are identical, this check alone still works — each network address lies inside the other range.
Practical examples
Example 1 — overlap
10.0.0.0/24 (10.0.0.0 – 10.0.0.255) and 10.0.0.128/25 (10.0.0.128 – 10.0.0.255): overlap.
Example 2 — no overlap
10.0.0.0/24 (10.0.0.0 – 10.0.0.255) and 10.0.1.0/24 (10.0.1.0 – 10.0.1.255): the first range ends at 10.0.0.255 and the next begins at 10.0.1.0 — no overlap.
Example 3 — containment
10.0.0.0/8 (10.0.0.0 – 10.255.255.255) and 10.255.255.255/32 (a single address): the /32 lies inside the /8 — overlap.
Real-world conflict examples
- AWS VPC: VPC A uses 10.0.0.0/16, VPC B uses 10.0.128.0/17. Peering is refused because B’s range falls inside A’s.
- VPN: the office LAN is 192.168.1.0/24 and a remote site uses 192.168.0.0/16. After the tunnel is up, traffic to the remote site can be misrouted locally, or the tunnel never passes traffic correctly.
- Office merge: two acquired companies both use 172.16.0.0/12 internally. Every interconnect between them is a routing conflict until one side is renumbered.
Common mistakes
- Comparing only the first octet. 10.0.0.0/8 and 10.1.0.0/16 look different but overlap completely.
- Forgetting containment. A /24 inside a /16 is an overlap even though neither boundary matches.
- Treating adjacent blocks as overlapping. 10.0.0.0/25 (…0.0 – …0.127) and 10.0.0.128/25 (…0.128 – …0.255) touch but share no address.
- Ignoring /0. 0.0.0.0/0 overlaps every address in IPv4, including your private ranges.
When CIDR blocks do NOT overlap
Blocks are disjoint when one range ends before the other begins, or when they are exactly adjacent. A quick sanity check: if the highest address of the smaller-range block is lower than the lowest address of the other block, there is no overlap.
FAQ
Does overlapping mean the two blocks are identical?
No. Identical blocks overlap, but so do partial overlaps and containment.
Can I peer two AWS VPCs with overlapping CIDRs?
No. AWS rejects peering between VPCs whose CIDR blocks overlap, even partially.
Are adjacent subnets overlapping?
No. 10.0.0.0/25 and 10.0.0.128/25 are adjacent and share no address.
Do I need to check both directions?
Yes — either block can contain the other, so test each range against the other.
Check your networks with our CIDR Overlap Detector
Enter two CIDR blocks and see their exact ranges and the shared overlap range instantly.
CIDR Overlap Detector