Allowlist Builder
Build minimal CIDR allowlist from IP list
Input IPs/CIDRs
Minimal CIDR Allowlist
The Allowlist Builder converts a list of individual IP addresses into the minimal set of CIDR blocks that cover exactly those addresses. Enter addresses like 192.168.1.0, 192.168.1.1, 192.168.1.2, 192.168.1.3 and get back a single 192.168.1.0/30 -- fewer firewall rules, faster rule processing, and more manageable configurations.
Understanding IP Allowlists and CIDR Aggregation
If you run firewalls, security groups, or web server access controls, you have almost certainly maintained an allowlist at some point. An allowlist is a set of IP addresses that are explicitly permitted to access a resource -- everything else is denied. The challenge comes when that list grows from a handful of addresses to hundreds or thousands. Every individual IP entry is a separate rule in your firewall, and every rule costs processing time on every packet that passes through.
CIDR aggregation solves this by combining adjacent IP addresses into compact blocks. Instead of listing 256 individual addresses from 172.16.0.0 to 172.16.0.255, you write a single 172.16.0.0/24. The firewall evaluates one rule instead of 256, which matters when you are processing millions of packets per second on a busy edge device. Cloud platforms enforce hard limits on rule counts -- AWS security groups allow 60 rules per group by default, and Azure NSGs cap at 1000 -- so efficient CIDR representation is not just a performance optimization, it is often a requirement.
The critical distinction between generic CIDR aggregation and allowlist building is accuracy. A general aggregation tool might combine 192.168.1.0 and 192.168.1.3 into 192.168.1.0/30, but that block also includes .1 and .2, which may not be authorized. For an allowlist, including unauthorized addresses is a security hole. This builder guarantees that the output never covers an address that was not in the original input -- it always chooses accuracy over compression.
How to Build a Minimal CIDR Allowlist
- Enter your list of IP addresses -- one per line, comma-separated, or mixed with existing CIDR notation.
- The builder analyzes adjacency and grouping opportunities across all input addresses.
- Adjacent addresses are aggregated into CIDR blocks only when doing so does not include any unauthorized IPs.
- Review the output showing each CIDR block and how many original addresses it covers.
- Copy the optimized allowlist for use in your firewall, security group, or ACL configuration.
Allowlist Aggregation Examples
| Input IPs | Output CIDR | Addresses Covered |
|---|---|---|
192.168.1.0, 192.168.1.1, 192.168.1.2, 192.168.1.3 | 192.168.1.0/30 | 4 |
10.0.0.0, 10.0.0.1 | 10.0.0.0/31 | 2 |
172.16.0.0 through 172.16.0.255 | 172.16.0.0/24 | 256 |
192.168.1.0, 192.168.1.2 | 192.168.1.0/32, 192.168.1.2/32 | 2 (cannot merge -- 192.168.1.1 is missing) |
Compression Ratio
A list of 256 consecutive addresses starting at a /24 boundary compresses to a single CIDR block -- a 256:1 reduction. Real-world lists typically achieve 5:1 to 20:1 compression depending on how clustered the addresses are.
When to Use the Allowlist Builder
- Firewall rule limits -- Cloud security groups (AWS limits 60 rules per SG, Azure limits 1000 per NSG) require compact allowlists to stay within quotas.
- Access log consolidation -- Convert weeks of authorized IP addresses from access logs into a maintainable allowlist.
- Migration planning -- Combine allowlists from multiple legacy firewalls into a single optimized set.
- Performance optimization -- Fewer CIDR rules means faster packet matching on high-throughput firewalls.
- API gateway configuration -- Services like Cloudflare or AWS API Gateway benefit from minimal CIDR lists for IP-based access control.
How CIDR Aggregation Works for Allowlists
CIDR aggregation combines IP addresses into blocks by identifying shared network prefixes in binary representation. Two addresses can merge into a larger block only when:
- They are numerically adjacent --
10.0.0.4and10.0.0.5are adjacent;10.0.0.4and10.0.0.6are not. - They align on a power-of-two boundary --
10.0.0.0/31is valid (covers.0and.1), but you cannot start a/31at an odd address. - No gaps exist -- If
10.0.0.1is missing from a list containing10.0.0.0and10.0.0.2, they cannot be combined into/30because that would include the unauthorized.1address.
Safe vs. Unsafe Aggregation
Safe: 192.168.1.0 + 192.168.1.1 β 192.168.1.0/31
(both addresses are in the input list)
Unsafe: 192.168.1.0 + 192.168.1.3 β 192.168.1.0/30
(would include .1 and .2, which are NOT in the list)
The Allowlist Builder always chooses accuracy over compression -- it will never produce a CIDR block that includes IPs outside your original list.
The Aggregation Algorithm
The builder works bottom-up. It starts by converting every input address to a /32 (single host). It then attempts to pair adjacent /32 entries into /31 blocks, adjacent /31 blocks into /30 blocks, and so on. At each step, it checks whether the resulting block would include any address not in the original input. If it would, the merge is skipped and the smaller blocks are kept. This greedy approach guarantees the minimal number of CIDR blocks while never over-covering.
Input: 10.0.0.0, 10.0.0.1, 10.0.0.2, 10.0.0.3, 10.0.0.4
Step 1: 10.0.0.0/32, 10.0.0.1/32, 10.0.0.2/32, 10.0.0.3/32, 10.0.0.4/32
Step 2: 10.0.0.0/31, 10.0.0.2/31, 10.0.0.4/32
Step 3: 10.0.0.0/30, 10.0.0.4/32 (merge .0/.1 and .2/.3 into /30)
Step 4: Cannot merge /30 + /32 (would need 10.0.0.5-7 to fill a /29)
Result: 10.0.0.0/30, 10.0.0.4/32 (2 entries instead of 5)
Practical Advice for Building Allowlists
The biggest source of trouble with IP allowlists is stale entries. Addresses get added when a new partner or office comes online, but nobody removes them when the partner relationship ends or the office moves to a new IP range. Over time the allowlist grows into a sprawling mess that nobody trusts and nobody wants to touch. Make it a practice to attach an expiration date or a ticket number to every entry, and review the list quarterly. If you cannot identify why an address is there, it probably should not be.
When building allowlists from access logs, be careful about the time window you use. A single day of logs might miss legitimate addresses that only connect weekly (monitoring systems, batch jobs, monthly report generators). Pull at least 30 days of logs to catch infrequent but legitimate traffic. On the other hand, do not blindly allowlist every address that has ever connected -- check that the traffic was actually authorized, not just successful. An attacker who got in once should not be permanently allowlisted.
If you are hitting rule count limits on a cloud platform, consider whether you actually need per-IP allowlisting or whether a broader CIDR block is acceptable. If all of a partner's servers live in 203.0.113.0/24, allowlisting the whole /24 is simpler and more resilient to their infrastructure changes than tracking individual server IPs. This is a judgment call that depends on how much you trust the network owner, but it dramatically reduces your rule count.
Frequently Asked Questions
What input formats does the Allowlist Builder accept? The builder accepts IP addresses one per line, comma-separated, space-separated, or mixed with existing CIDR notation. You can paste directly from spreadsheets, log files, or existing firewall configurations. Both IPv4 and IPv6 addresses are supported.
Will the builder ever include IPs I did not specify?
No. The builder prioritizes accuracy over compression. If merging two addresses into a CIDR block would include even one address not in your original list, it keeps them as separate /32 (IPv4) or /128 (IPv6) entries. This guarantee is critical for security allowlists.
How is this different from CIDR aggregation? General CIDR aggregation assumes you already have CIDR blocks and wants to merge them. The Allowlist Builder starts from individual IP addresses and finds the optimal CIDR representation. It is specifically designed for building firewall allowlists where including extra addresses is unacceptable.
Can I use the output directly in my firewall? The output is a list of CIDR blocks in plain text. For platform-specific syntax, use the output with a snippet generator like the CIDR Allow/Deny Snippet Generator (nginx) or the Apache Require ip Snippet Generator to produce ready-to-deploy configuration.
What compression ratio should I expect?
It depends entirely on how clustered your addresses are. A list of 256 consecutive addresses on a /24 boundary compresses to a single block (256:1). A list of 100 addresses scattered across different subnets might only compress to 80 blocks (1.25:1). In practice, most real-world access logs produce ratios between 5:1 and 20:1.
Can I mix IPv4 and IPv6 addresses in the same input? Yes. The builder processes IPv4 and IPv6 addresses separately and produces independent CIDR block lists for each address family. This matches how most firewalls handle dual-stack rules.
Related Tools
- Blocklist Builder - Build minimal CIDR blocklist from IP list
- IP:Port Allowlist Validator - Validate bulk IP:port entries before deployment
- CIDR Allow/Deny Snippet Generator (nginx) - Generate nginx allow/deny directives from CIDR list
- Rule Conflict Finder - Find duplicate, shadowed, or overlapping firewall rules
- Apache Require ip Snippet Generator - Generate Apache Require ip directives