IP range to CIDR
Many systems accept ranges only as CIDR blocks: firewall rules, AWS security groups, Cloudflare and nginx allow-lists, BGP prefix lists. If you have a start and end address, such as 192.168.1.10 to 192.168.1.200, this IP range calculator finds the smallest list of CIDR blocks that covers the range exactly, so you do not accidentally allow neighbouring addresses.
How the conversion works
- Start at the first address.
- Take the largest block that is aligned on that address (its size divides the address) and still fits before the end of the range.
- Emit that block, move to the address just after it and repeat until the end is reached.
Because every block must be aligned on a multiple of its own size, ranges that begin or end at awkward addresses need several blocks. A range that is exactly one subnet, such as 10.0.0.0 – 10.0.255.255, collapses to a single 10.0.0.0/16.
CIDR to IP range
To go the other way, use the CIDR calculator or the IP subnet calculator. The range of a CIDR block runs from its network address to its broadcast address. For 172.16.0.0/20 that is 172.16.0.0 to 172.16.15.255, 4,096 addresses.
Merging several ranges
Adjacent or overlapping networks can be combined into a single larger prefix (route summarisation). Two neighbouring /24 networks that start on an even boundary — for example 10.0.0.0/24 and 10.0.1.0/24 — collapse into 10.0.0.0/23. Summarising keeps routing tables and firewall rule sets short.