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.

IP range to CIDR

CIDR blocks
Addresses

                        
IP ranges
CIDRFirst IPLast IPAddressesSubnet mask


                    
Merged blocks (overlaps and neighbours combined)

                        

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.

IP range converted into CIDR blocks10.0.0.5–205 CIDR blocksCIDRCalculator

How to use the CIDR calculator

  1. 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.
  2. 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.20 into the Start field. The calculator lists the CIDR blocks that cover exactly that range.
  3. Merge a list: the merged list below the table combines overlapping and adjacent blocks from the left box.
  4. 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/8 covers 10.0.0.0 to 10.255.255.255: 16,777,216 addresses.
  • 2001:db8::/32 covers 2001:db8:: to 2001: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)

CIDRSubnet maskTotal addressesSize in /24 networks
/8255.0.0.016,777,21665,536
/9255.128.0.08,388,60832,768
/10255.192.0.04,194,30416,384
/11255.224.0.02,097,1528,192
/12255.240.0.01,048,5764,096
/13255.248.0.0524,2882,048
/14255.252.0.0262,1441,024
/15255.254.0.0131,072512
/16255.255.0.065,536256
/17255.255.128.032,768128
/18255.255.192.016,38464
/19255.255.224.08,19232
/20255.255.240.04,09616
/21255.255.248.02,0488
/22255.255.252.01,0244
/23255.255.254.05122
/24255.255.255.02561
/25255.255.255.1281281/2
/26255.255.255.192641/4
/27255.255.255.224321/8
/28255.255.255.240161/16
/29255.255.255.24881/32
/30255.255.255.25241/64
/31255.255.255.25421/128
/32255.255.255.25511/256

Where CIDR blocks are used

  • Firewalls and security groups: AWS security groups, Azure NSGs, GCP firewall rules and iptables or nftables all take CIDR sources such as 198.51.100.0/24; use /32 for 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, Apache Require ip and PostgreSQL pg_hba.conf accept 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/24 is 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/0 and ::/0 match 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.