🔒 IP Exclusion Calculator – Remove IPs from a Network Range
The IP Exclusion Calculator solves a common networking challenge: given a source IP network, compute the exact set of CIDR blocks that remain after one or more addresses or subnets have been removed. This operation — sometimes called CIDR subtraction or subnet exclusion — is essential for writing precise firewall rules, DHCP pool definitions, BGP prefix lists, and routing policies where you need to address everything except a specific range.
Why You Need CIDR Subtraction
Network devices such as firewalls, routers, and DHCP servers require explicit IP ranges in their configuration. You cannot simply say "allow 10.0.0.0/8 except 10.10.50.0/24" — you must provide a list of non-overlapping CIDR blocks that cover exactly the desired address space. Calculating this by hand is tedious and error-prone, especially for large address blocks or multiple exclusions.
Common scenarios where CIDR exclusion is required:
- Firewall ACLs — permit all traffic from a /16 block except known bad-actor /24 ranges
- DHCP pools — allocate a /24 for dynamic assignment but reserve specific addresses for printers, servers, and gateways
- BGP prefix lists — advertise a /20 aggregate but suppress a /24 sub-prefix that routes through a different provider
- Access control entries — grant access to a department subnet while blocking the management VLAN range
- Cloud security groups — restrict an entire VPC CIDR but exclude the load-balancer subnet
How the Exclusion Algorithm Works
The calculator uses a binary interval subtraction algorithm that operates on 32-bit integer representations of IPv4 addresses:
- Convert the source CIDR and all exclusions to
[start, end]integer ranges. - Clip each exclusion to the source boundary — exclusions outside the source network have no effect.
- Sort and merge overlapping exclusions into a single consolidated list so double-counting is avoided.
- Walk from
source.starttosource.end, collecting integer gaps between excluded regions. - Convert each gap back to the minimal set of CIDR blocks using a power-of-2 alignment algorithm (similar to how Linux
ipcalcworks).
Worked Example
Source network: 192.168.1.0/24 (256 addresses, 192.168.1.0–192.168.1.255)
Exclusions: 192.168.1.0/27 (32 addresses) and 192.168.1.64/28 (16 addresses)
Result: 3 CIDR blocks covering the remaining 208 addresses
| CIDR Block | Range | Hosts |
|---|---|---|
192.168.1.32/27 | 192.168.1.32 – 192.168.1.63 | 32 |
192.168.1.80/28 | 192.168.1.80 – 192.168.1.95 | 16 |
192.168.1.96/27 | 192.168.1.96 – 192.168.1.127 | 32 |
192.168.1.128/25 | 192.168.1.128 – 192.168.1.255 | 128 |
Why the Result Has Multiple Blocks
When you remove an arbitrary range from a parent CIDR, the leftover space rarely aligns to a single CIDR boundary. CIDR notation can only represent power-of-2 sized blocks whose start address is divisible by the block size. The calculator applies a greedy largest-block-first strategy: at each position it selects the largest CIDR block that (a) starts at the current address and (b) does not exceed the remaining gap. This guarantees the minimum number of CIDR entries in the output.
Input Formats Accepted
| Format | Example | Interpretation |
|---|---|---|
| CIDR notation | 10.0.0.0/8 | Standard network block |
| Host address | 192.168.1.1 | Treated as a /32 (single host) |
| CIDR with host bits | 10.0.0.5/24 | Auto-corrected to 10.0.0.0/24 with a warning |
Understanding the Output Columns
- CIDR Block — the network address with its prefix length (e.g.
10.0.0.128/25) - Network / Broadcast — the first and last addresses in the block (reserved, not assignable on standard networks)
- First / Last Usable — the assignable host range (excludes network and broadcast for prefixes shorter than /31)
- Total Hosts — all addresses including network and broadcast
- Usable Hosts — assignable addresses (
total − 2for prefixes ≤ /30; both addresses usable for /31 point-to-point links per RFC 3021; single address for /32)
Practical Tips
- Enter exclusions one per line or separated by commas — the tool accepts both formats.
- To exclude a single host address, just enter the IP without a prefix (e.g.
192.168.1.1). It will be treated as/32. - Overlapping exclusions are automatically merged, so you can paste a raw block list without pre-deduplicating it.
- Exclusions that fall entirely outside the source network are ignored — they have no effect on the result.
- Use the CSV export to import results into a spreadsheet, network management system, or scripting workflow.
- The Compact CIDR List output at the bottom of the results can be pasted directly into most router and firewall configuration interfaces.
Related Networking Tools
For broader subnet planning, use the CIDR Range Calculator to explore network details or the VLSM Calculator to allocate variable-length subnets to departments. The IP Range Merger performs the inverse operation — combining a list of CIDR blocks into the fewest possible supernets. The CIDR Splitter divides a parent block into equal-sized child subnets, while the Supernet Calculator finds the smallest CIDR that contains a set of networks.
✅ Use this tool when you need to…
- Build firewall permit rules for "all except" scenarios
- Define a DHCP scope that skips reserved addresses
- Generate BGP prefix lists that suppress sub-prefixes
- Document the remaining address space after reservations
🔗 Complementary tools
- CIDR Splitter — divide into equal subnets
- IP Range Merger — consolidate CIDR lists
- VLSM Calculator — variable-length subnet allocation
- Supernet Calculator — find smallest containing network