Smallest Covering CIDR (Two CIDRs)
Find the smallest CIDR that contains two CIDR blocks
Containment Visualization
Network Addresses (Binary)
Summary
| CIDR | Network | Prefix | Addresses |
|---|---|---|---|
| CIDR 1 | 192.168.1.0 | /24 | 256 |
| CIDR 2 | 192.168.5.0 | /24 | 256 |
| Covering | 192.168.0.0 | /21 | 2,048 |
The Smallest Covering CIDR (Two CIDRs) tool calculates the minimal supernet that completely encompasses two specified CIDR blocks. Enter 192.168.0.0/24 and 192.168.1.0/24 to find that the covering CIDR is 192.168.0.0/23 with zero extra addresses, or enter 192.168.0.0/24 and 192.168.3.0/24 to see that the covering /22 includes 512 extra addresses from the gap between them.
Understanding Supernetting Two CIDR Blocks
Route summarization is one of the most important techniques in network engineering. When you have multiple specific routes in your routing table, you can often replace them with a single, less-specific summary route that covers all of them. This reduces routing table size, simplifies configuration, and improves convergence times. Finding the covering CIDR for two subnets is the fundamental building block of this process.
Unlike finding the covering CIDR for two individual IPs, this tool must consider the full range of each input CIDR block. A /24 is not a single point -- it is a range of 256 addresses. The covering CIDR must encompass both ranges entirely, from the lowest address of the lower block to the highest address of the upper block. The result is always a CIDR with a shorter prefix (larger block) that contains every address in both inputs.
The critical insight is the concept of "extra" addresses. When two CIDR blocks are perfectly adjacent (like 192.168.0.0/24 and 192.168.1.0/24), they merge into 192.168.0.0/23 with zero wasted space. But when there is a gap between them (like 192.168.0.0/24 and 192.168.3.0/24), the covering CIDR must span that gap, pulling in the addresses from 192.168.1.0/24 and 192.168.2.0/24 as extras. These extra addresses have real implications for routing and security that you need to understand before deploying a summary route.
How to Find the Smallest CIDR Covering Two Subnets
- Enter the first CIDR block (e.g.,
192.168.0.0/24) - Enter the second CIDR block (e.g.,
192.168.1.0/24) - The tool computes the minimal covering supernet that includes every address in both blocks
- Review the covering CIDR, the extra address space included, and the full range covered
Covering CIDR Examples for Two Subnets
| CIDR Block 1 | CIDR Block 2 | Covering CIDR | Extra Addresses |
|---|---|---|---|
192.168.0.0/24 | 192.168.1.0/24 | 192.168.0.0/23 | 0 |
192.168.0.0/24 | 192.168.3.0/24 | 192.168.0.0/22 | 512 |
10.0.0.0/24 | 10.0.1.0/24 | 10.0.0.0/23 | 0 |
10.0.0.0/24 | 10.0.255.0/24 | 10.0.0.0/16 | 65,024 |
172.16.0.0/16 | 172.17.0.0/16 | 172.16.0.0/15 | 0 |
192.168.0.0/25 | 192.168.0.128/25 | 192.168.0.0/24 | 0 |
When the two CIDRs are perfectly adjacent (like the first row), the covering CIDR includes zero extra addresses. When gaps exist between them, the covering CIDR must span those gaps, pulling in additional address space.
When to Use This Tool
- BGP route summarization -- combine two specific prefixes into a single announcement to reduce the global routing table
- Firewall rule consolidation -- replace two separate allow/deny rules with one covering rule when the extra addresses are acceptable
- Network planning -- determine the parent allocation needed to contain two planned subnets
- Routing efficiency -- create a single static or OSPF summary route instead of two specific routes
- Understanding scope implications -- visualize how much extra address space is pulled in when summarizing two prefixes
- Capacity assessment -- determine the minimum allocation size needed from an upstream provider to cover two existing subnets
How Supernetting Two CIDRs Works
Unlike the two-IP version, this tool must consider the full range of each input CIDR block, not just two points.
The Algorithm
- Determine the lowest address across both CIDRs (the network address of whichever starts lower)
- Determine the highest address across both CIDRs (the broadcast address of whichever ends higher)
- Find the longest common binary prefix between these two boundary addresses
- The resulting prefix length is the covering CIDR
Worked Example
For 192.168.0.0/24 and 192.168.3.0/24:
Block 1 range: 192.168.0.0 - 192.168.0.255
Block 2 range: 192.168.3.0 - 192.168.3.255
Lowest address: 192.168.0.0 = 11000000.10101000.000000|00.00000000
Highest address: 192.168.3.255 = 11000000.10101000.000000|11.11111111
^^
Bits 23-24 differ
Longest common prefix: 22 bits
Covering CIDR: 192.168.0.0/22
The covering /22 spans 192.168.0.0 to 192.168.3.255 (1,024 addresses). The two input /24 blocks account for 512 addresses, leaving 512 "extra" addresses from 192.168.1.0/24 and 192.168.2.0/24 that are included in the supernet but were not in either input.
Why Extra Addresses Matter
Those extra addresses in the covering CIDR can have routing and security implications:
- Routing black holes -- if you create a summary route for
192.168.0.0/22but only have actual paths for.0.0/24and.3.0/24, traffic to.1.0/24and.2.0/24may be routed to your network and then dropped - Security exposure -- a firewall rule allowing
192.168.0.0/22permits traffic from 512 addresses that were not in your original two rules - Documentation accuracy -- the covering CIDR may misrepresent the actual scope of your network
Practical Advice for Route Summarization
When deciding whether to use a covering CIDR or keep two separate routes, the key question is whether the extra addresses are acceptable. If the gap between your two subnets is unused address space within your own allocation, a summary route is usually fine -- traffic to the gap addresses will simply be dropped when it arrives and finds no active host. But if the gap contains address space that belongs to another organization or another part of your network, the summary route could cause misrouted traffic.
A common best practice is to plan your subnets so they aggregate cleanly. If you know you will eventually need subnets at 192.168.0.0/24 and 192.168.1.0/24, allocate them from the same /23 parent so they can be summarized with zero waste. If you instead allocate 192.168.0.0/24 and 192.168.5.0/24, you lose the ability to summarize tightly.
When working with BGP, remember that the extra addresses in a summary announcement do not just affect your routing table -- they affect every router on the internet that receives your announcement. If you announce 192.168.0.0/22 but only use .0.0/24 and .3.0/24, other networks may try to send traffic to the gap addresses to your AS, where it will be black-holed. This is generally not a problem for private address space behind NAT, but it matters for public IP space.
Frequently Asked Questions
When do two CIDRs produce a covering CIDR with zero extra addresses?
This happens only when the two CIDRs are perfectly adjacent and together form a valid larger CIDR block. For example, 192.168.0.0/24 and 192.168.1.0/24 combine exactly into 192.168.0.0/23 with no gaps. Both blocks must have the same prefix length, be adjacent, and share the same parent prefix at one bit shorter.
Is this the same as CIDR aggregation?
Not exactly. Aggregation merges adjacent or overlapping blocks into one. The covering CIDR finds the smallest supernet that contains both blocks, even if they are not adjacent. Two non-adjacent blocks cannot be aggregated but always have a covering CIDR (which may include extra addresses between them).
What if one CIDR completely contains the other?
If 10.0.0.0/16 and 10.0.1.0/24 are the inputs, the /24 is entirely within the /16. The covering CIDR is simply 10.0.0.0/16 -- the larger block already covers both.
What if the two CIDRs overlap partially?
The covering CIDR is still calculated normally, using the lowest address from either block and the highest from either block. The overlap does not change the algorithm.
Can I find the covering CIDR for more than two subnets?
Use the Smallest Covering CIDR (Many IPs/CIDRs) tool to process any number of CIDR blocks in a single batch.
Related Tools
- Smallest Covering CIDR (Two IPs) - Find the smallest CIDR that contains two IP addresses
- Smallest Covering CIDR (Many IPs/CIDRs) - Find the smallest CIDR containing a list of IPs or CIDRs
- CIDR Aggregator - Aggregate multiple CIDR blocks into summarized routes
- Adjacency Checker - Check if two CIDR blocks can be merged
- Subnet Overlap Checker (Two CIDRs) - Check if two CIDR blocks overlap