Adjacency Checker
Check if two CIDR blocks can be merged
Enter two CIDR blocks to check if they can be merged
The Adjacency Checker determines whether two CIDR blocks are adjacent in address space and whether they can be merged into a single larger CIDR block. Enter two blocks like 192.168.0.0/25 and 192.168.0.128/25 to find out if they are neighbors, whether they satisfy all three merge conditions, and what the resulting supernet would be.
Understanding CIDR Adjacency and Merging
When you look at two subnet ranges sitting next to each other in an address plan, it seems obvious that they should combine into one larger block. After all, 192.168.0.0/25 covers .0 through .127 and 192.168.0.128/25 covers .128 through .255 -- together they cover the entire .0/24 range. But CIDR merging is not just about being neighbors. Two blocks can be right next to each other in the address space and still fail to merge, which catches a lot of engineers off guard the first time they encounter it.
The reason is alignment. CIDR notation is fundamentally a binary system. Every block is a power-of-two-sized range starting at a position where a specific number of low-order bits are zero. When you merge two /24 blocks into a /23, the resulting /23 must start at an address where the 23rd bit is zero. If your two /24 blocks are 192.168.1.0/24 and 192.168.2.0/24, they are adjacent (no gap), but 192.168.1.0 has its 23rd bit set to 1, so the pair is not /23-aligned. They are not siblings in the binary tree -- they belong to different parent blocks.
This tool checks all three merge conditions for you: same prefix length, adjacency (no gap between the ranges), and boundary alignment. When merging is possible, it shows the result. When it is not, it explains exactly which condition failed and why, making it both a practical tool for route optimization and a learning aid for understanding how CIDR boundaries work.
How to Check If Two CIDR Blocks Can Be Merged
- Enter the first CIDR block (e.g.,
192.168.0.0/25) - Enter the second CIDR block (e.g.,
192.168.0.128/25) - Click check to analyze adjacency and mergeability
- Review the result: adjacent or not, mergeable or not, and the merged CIDR if applicable
- If merging is not possible, read the explanation of which condition failed
Adjacency and Merge Examples
Two /25 blocks that merge into a /24
| Field | Value |
|---|---|
| CIDR A | 192.168.0.0/25 (addresses 192.168.0.0 - 192.168.0.127) |
| CIDR B | 192.168.0.128/25 (addresses 192.168.0.128 - 192.168.0.255) |
| Adjacent? | Yes |
| Same prefix length? | Yes |
| Aligned on /24 boundary? | Yes |
| Merged result | 192.168.0.0/24 |
Adjacent blocks that cannot merge (alignment issue)
| Field | Value |
|---|---|
| CIDR A | 192.168.1.0/24 (addresses 192.168.1.0 - 192.168.1.255) |
| CIDR B | 192.168.2.0/24 (addresses 192.168.2.0 - 192.168.2.255) |
| Adjacent? | Yes |
| Same prefix length? | Yes |
| Aligned on /23 boundary? | No -- 192.168.1.0 is not on a /23 boundary |
| Result | Cannot merge |
Note: 192.168.0.0/24 and 192.168.1.0/24 would merge to 192.168.0.0/23 because 192.168.0.0 is properly /23-aligned.
Non-adjacent blocks
| Field | Value |
|---|---|
| CIDR A | 10.0.0.0/24 |
| CIDR B | 10.0.5.0/24 |
| Adjacent? | No -- gap of 4 /24 blocks between them |
| Result | Cannot merge |
Different-sized blocks
| Field | Value |
|---|---|
| CIDR A | 10.1.0.0/24 (256 addresses) |
| CIDR B | 10.1.1.0/25 (128 addresses) |
| Adjacent? | Yes |
| Same prefix length? | No |
| Result | Cannot merge -- blocks must be the same size |
When to Use the Adjacency Checker
- Route aggregation -- find pairs of routes in your BGP table that can be summarized into a single announcement, reducing table size
- Firewall rule optimization -- identify adjacent allow/deny rules that combine into one, reducing processing overhead
- Address plan cleanup -- after reorganizing subnets, check whether neighboring blocks now align for consolidation
- Network education -- understand why some adjacent subnets merge and others do not, reinforcing CIDR boundary concepts
- Change impact assessment -- before modifying a subnet, check whether it currently participates in a merged supernet
- Pre-merge validation -- verify that a planned merge is valid before committing the change to your routing configuration
How CIDR Block Merging Works
Three conditions must all be true for two CIDR blocks to merge:
Condition 1: Same Prefix Length
Both blocks must have the same prefix length. A /24 (256 addresses) and a /25 (128 addresses) cannot merge because the combined range would not be a power-of-two size expressible in CIDR notation.
Condition 2: Adjacency (No Gap)
The last address of one block must immediately precede the first address of the other. 192.168.0.255 (end of 192.168.0.0/24) plus one equals 192.168.1.0 (start of 192.168.1.0/24), so these are adjacent.
Condition 3: Boundary Alignment
The combined range must start on a valid CIDR boundary for the new prefix length. When merging two /n blocks, the result is a /(n-1) block. The starting address of the result must have its (n-1)th bit set to zero.
In binary, 192.168.0.0 = 11000000.10101000.00000000.00000000. The 23rd bit (for a /23 merge) is 0, so this address is /23-aligned. But 192.168.1.0 = 11000000.10101000.00000001.00000000 has the 23rd bit set to 1, so it is not /23-aligned, meaning 192.168.1.0/24 + 192.168.2.0/24 cannot merge.
Quick Rule
Two /n blocks merge if and only if they are a sibling pair in the CIDR binary tree -- they share the same parent /(n-1) block. You can check this by verifying that the two network addresses differ only in bit position n.
Practical Tips for Route Aggregation
When auditing a routing table or firewall ruleset for merge opportunities, start from the bottom of the prefix tree and work upward. First look for /32 pairs that merge to /31, then /31 pairs that merge to /30, and so on. This bottom-up approach catches cascading merges that a single pass would miss. The Minimal Merge Tool automates this process for large lists, but understanding the mechanics helps you validate the results.
A common mistake is trying to merge blocks that belong to different administrative domains. Two /24 blocks might be technically mergeable, but if one belongs to the production network and the other to the DMZ, merging them into a single BGP announcement or firewall rule loses the administrative boundary between them. Always consider whether a merge makes organizational sense, not just mathematical sense.
When you find blocks that are adjacent but cannot merge due to alignment, consider whether renumbering one of the blocks is feasible. If 192.168.1.0/24 and 192.168.2.0/24 cannot merge but 192.168.0.0/24 and 192.168.1.0/24 can, and you have the flexibility to reassign the first block, the consolidation might be worth the effort during a planned maintenance window.
Frequently Asked Questions
Can I check more than two blocks at once?
The Adjacency Checker analyzes exactly two blocks. To find all mergeable pairs in a larger list, use the Minimal Merge Tool, which iteratively merges all adjacent pairs until no more merges are possible.
What about IPv6 adjacency?
The same three conditions apply to IPv6. Two 2001:db8::/33 and 2001:db8:8000::/33 blocks merge to 2001:db8::/32 following identical binary alignment rules, just with 128-bit addresses instead of 32-bit.
Why do 192.168.1.0/24 and 192.168.2.0/24 not merge even though they are adjacent?
These blocks are adjacent (no gap between them), but 192.168.1.0 is not on a /23 boundary. The /23 block starting at 192.168.1.0 would be 192.168.1.0/23 covering .1.0 through .2.255, which is a valid range, but 192.168.1.0 in binary has its 23rd bit set to 1. CIDR requires all host bits to be zero, so the supernet must start at an even multiple. The valid pairs are 192.168.0.0/24 + 192.168.1.0/24 = 192.168.0.0/23 and 192.168.2.0/24 + 192.168.3.0/24 = 192.168.2.0/23.
Is there a quick way to tell if two blocks are siblings?
Yes. Convert both network addresses to binary and compare them. If they differ in exactly one bit -- the bit at position equal to the prefix length -- they are siblings and can merge. If they differ in any other bits, they cannot merge.
Can three or more blocks merge at once?
Not directly. CIDR merging is always pairwise: two siblings merge to their parent. However, the parent might then be a sibling of another block, enabling a cascading merge. Four /26 blocks can merge to one /24, but it happens in two steps: two pairs of /26 become two /25 blocks, which then merge to one /24.
Related Tools
- Minimal Merge Tool - Merge all mergeable CIDR blocks in a list
- CIDR Aggregator - Aggregate multiple CIDR blocks into summarized routes
- Subnet Overlap Checker (Two CIDRs) - Check if two CIDR blocks overlap
- Subnet Contains Subnet? Checker - Check if one CIDR block contains another
- CIDR List Minimal Non-overlapping Set - Convert a CIDR list to minimal non-overlapping blocks