CIDR Calculator: CIDR to IP Range and Back
Convert CIDR blocks to IP ranges and IP ranges to the smallest list of CIDR blocks. This CIDR calculator also merges overlapping blocks, for IPv4 and IPv6.
IPv4 or IPv6, for example 10.0.0.0/8 or 2001:db8::/32. A single address counts as /32 or /128.
| CIDR blocks | | |
|---|---|---|
| Addresses | |
| CIDR | First IP | Last IP | Addresses | Subnet mask |
|---|
Convert Between CIDR Blocks and IP Ranges
Firewalls, cloud security groups, VPN configs and allowlists expect CIDR notation such as 203.0.113.0/24, but vendors and colleagues often hand you a start and end address instead. This CIDR calculator converts in both directions: paste CIDR blocks to see their first and last address and size, or enter any IP range to get the shortest list of CIDR blocks that covers it exactly.
Paste a long list of blocks and it also merges overlapping and neighbouring blocks into the smallest equivalent list, which keeps firewall rules short. It works with IPv4 and IPv6 and runs entirely in your browser.
How to use the CIDR calculator
- CIDR to IP range: type or paste CIDR blocks into the left box, one per line. The table shows the first IP, last IP, number of addresses and subnet mask of each block.
- IP range to CIDR: enter a start and end IP. You can also paste a range such as
10.0.0.5-10.0.0.20into the Start field. The calculator lists the CIDR blocks that cover exactly that range. - Merge a list: the merged list below the table combines overlapping and adjacent blocks from the left box.
- Copy the CIDR list, the merged list or the table as CSV.
What is CIDR notation?
CIDR (Classless Inter-Domain Routing, RFC 4632) writes a block of IP addresses as a starting address plus a prefix length: 192.168.1.0/24. The prefix says how many leading bits are fixed. The rest can vary, so the block contains 2(32 − prefix) IPv4 addresses, or 2(128 − prefix) for IPv6.
- First address = the address with all variable bits set to 0.
- Last address = first address + 2(32 − prefix) − 1.
10.0.0.0/8covers10.0.0.0to10.255.255.255: 16,777,216 addresses.2001:db8::/32covers2001:db8::to2001:db8:ffff:ffff:ffff:ffff:ffff:ffff: 296 addresses.
CIDR replaced the old class A, B and C system in 1993, so networks can have any size that is a power of two instead of only /8, /16 or /24.
How an IP range becomes CIDR blocks
A CIDR block must start at an address that is a multiple of its size: a /29 (8 addresses) can start at .0, .8, .16 and so on, but not at .5. That is why most ranges need more than one block. The calculator starts at the first address, takes the largest block that is correctly aligned and does not pass the end, then repeats from the next address.
For example, 10.0.0.5 to 10.0.0.20 (16 addresses) becomes 5 blocks: 10.0.0.5/32, 10.0.0.6/31, 10.0.0.8/29, 10.0.0.16/30, 10.0.0.20/32. This is the smallest possible list. The same rule explains merging: 192.168.0.0/24 and 192.168.1.0/24 merge into 192.168.0.0/23, but 192.168.1.0/24 and 192.168.2.0/24 cannot, because a /23 cannot start at 192.168.1.0.
CIDR prefix reference table (IPv4)
| CIDR | Subnet mask | Total addresses | Size in /24 networks |
|---|---|---|---|
| /8 | 255.0.0.0 | 16,777,216 | 65,536 |
| /9 | 255.128.0.0 | 8,388,608 | 32,768 |
| /10 | 255.192.0.0 | 4,194,304 | 16,384 |
| /11 | 255.224.0.0 | 2,097,152 | 8,192 |
| /12 | 255.240.0.0 | 1,048,576 | 4,096 |
| /13 | 255.248.0.0 | 524,288 | 2,048 |
| /14 | 255.252.0.0 | 262,144 | 1,024 |
| /15 | 255.254.0.0 | 131,072 | 512 |
| /16 | 255.255.0.0 | 65,536 | 256 |
| /17 | 255.255.128.0 | 32,768 | 128 |
| /18 | 255.255.192.0 | 16,384 | 64 |
| /19 | 255.255.224.0 | 8,192 | 32 |
| /20 | 255.255.240.0 | 4,096 | 16 |
| /21 | 255.255.248.0 | 2,048 | 8 |
| /22 | 255.255.252.0 | 1,024 | 4 |
| /23 | 255.255.254.0 | 512 | 2 |
| /24 | 255.255.255.0 | 256 | 1 |
| /25 | 255.255.255.128 | 128 | 1/2 |
| /26 | 255.255.255.192 | 64 | 1/4 |
| /27 | 255.255.255.224 | 32 | 1/8 |
| /28 | 255.255.255.240 | 16 | 1/16 |
| /29 | 255.255.255.248 | 8 | 1/32 |
| /30 | 255.255.255.252 | 4 | 1/64 |
| /31 | 255.255.255.254 | 2 | 1/128 |
| /32 | 255.255.255.255 | 1 | 1/256 |
Where CIDR blocks are used
- Firewalls and security groups: AWS security groups, Azure NSGs, GCP firewall rules and
iptablesornftablesall take CIDR sources such as198.51.100.0/24; use/32for a single IPv4 address. - Cloud networks: an AWS VPC takes an IPv4 block between /16 and /28, which you then divide into subnets.
- Web servers and databases: nginx
allow/deny, ApacheRequire ipand PostgreSQLpg_hba.confaccept CIDR blocks. - Kubernetes and Docker: pod, service and bridge networks are configured as CIDR ranges that must not overlap your existing networks.
Tips
- Merge before you deploy. Provider rule limits are often low (security groups allow 60 inbound rules by default), so combine adjacent blocks first.
- Check for host bits.
10.0.0.5/24is not a valid network for many tools; the calculator shows the correct network address,10.0.0.0/24. - Prefer one larger aligned block over many small ones when you control the address plan.
- /0 means everything:
0.0.0.0/0and::/0match every address, so use them in inbound rules only on purpose.
Need the usable hosts, broadcast address and masks of one subnet, or want to split a network into equal parts? Use the subnet calculator. The chmod calculator covers file permissions on the same servers.
Frequently Asked Questions
Common questions about CIDR notation and IP ranges.
Set every bit after the prefix to 0 for the first address and to 1 for the last. 192.168.1.0/24 runs from 192.168.1.0 to 192.168.1.255. Paste blocks into the calculator to do it instantly.
Enter the start and end address under IP range to CIDR. The calculator returns the minimal list of aligned blocks that covers the range exactly, with no extra addresses.
256 addresses (2 to the power of 8). A /16 has 65,536 and a /8 has 16,777,216. Each step down in prefix doubles the size.
A CIDR block must start at a multiple of its own size. A range that starts or ends in an unaligned place, such as 10.0.0.5, has to be covered by several smaller blocks.
In IPv4, /32 is a single address, because all 32 bits are fixed. Firewalls use it to allow one host. The IPv6 equivalent is /128.
Yes. Paste them into the left box; the merged list combines overlapping and adjacent blocks into the smallest set of CIDR blocks that covers the same addresses.
Yes. Both CIDR to range and range to CIDR work with IPv6 addresses, including the compressed :: notation.
A CIDR calculator converts between blocks and ranges and merges lists. A subnet calculator looks at one network in detail: usable hosts, broadcast address, masks and splitting.