CIDR Calculator

Enter a CIDR block like 192.168.1.0/24 (or an IPv6 prefix) to get the network, broadcast, masks and host range, or convert any IP range to the exact CIDR blocks that cover it.

How to use the CIDR calculator

  1. Enter a block such as 192.168.1.0/24. You can also type an address with a dotted mask (172.16.5.4 255.255.240.0), a wildcard mask (10.0.0.0 0.0.0.255), a bare address (treated as /32), or an IPv6 prefix (2001:db8::/48).
  2. Read the results: network and broadcast addresses, subnet and wildcard masks, first and last usable host, total and usable host counts, address type, and a binary view where network bits are blue and host bits are yellow.
  3. Split it (optional): choose a longer prefix to list every subnet, for example a /24 into four /26 blocks.
  4. Convert a range: switch to IP range to CIDR, enter a start and end address, and copy the minimal list of blocks for a firewall rule, security group or allow list.

Everything is calculated in your browser with 128-bit integer math, so results are exact for IPv6 as well. Nothing is sent to a server.

How CIDR notation works

An IPv4 address is 32 bits. The number after the slash says how many of those bits, counted from the left, identify the network; the remaining bits identify hosts inside it. In 192.168.1.0/24 the first 24 bits (192.168.1) are the network and the last 8 bits give 256 addresses, 192.168.1.0 to 192.168.1.255.

CIDR (Classless Inter-Domain Routing, RFC 4632) replaced the old class A, B and C system in 1993. CIDR lets providers allocate any prefix length and lets routers aggregate many routes into one.

Converting an IP range to CIDR blocks

Firewalls, AWS security groups, Azure NSGs and iptables rules want CIDR blocks, but vendors often publish ranges as a start and end address. A range only fits in one block if it starts on a boundary that is a multiple of its size and its size is a power of two. Otherwise it must be split. The algorithm used here starts at the first address, takes the largest aligned block that does not run past the end, and repeats. For 192.168.1.10 to 192.168.1.20 that yields four blocks:

BlockCoversAddresses
192.168.1.10/31.10 – .112
192.168.1.12/30.12 – .154
192.168.1.16/30.16 – .194
192.168.1.20/32.201

If you only need something approximate, a single covering block (here 192.168.1.0/27) is shorter but also admits 21 addresses you did not ask for. For security rules, use the exact list.

IPv6 prefixes

IPv6 addresses are 128 bits, written as eight groups of four hex digits with leading zeros dropped and the longest run of zero groups shortened to :: (RFC 5952). Subnets are almost always /64, because SLAAC address autoconfiguration needs 64 host bits. A site typically receives a /48 (65,536 /64 subnets) or a /56 (256 subnets) from its provider. IPv6 has no broadcast address, so the calculator reports first and last address rather than usable hosts. Common ranges: 2000::/3 global unicast, fc00::/7 unique local, fe80::/10 link-local, and 2001:db8::/32 reserved for documentation. To see an address bit by bit, use the IPv6 to binary converter.

Subnet mask and CIDR reference table

Usable hosts follow the standard rule (total minus network and broadcast), with the RFC 3021 exception for /31 and a single host for /32.

CIDRSubnet maskWildcardAddressesUsable hostsNotes
/00.0.0.0255.255.255.2554,294,967,2964,294,967,294Whole IPv4 space (default route)
/1128.0.0.0127.255.255.2552,147,483,6482,147,483,646
/2192.0.0.063.255.255.2551,073,741,8241,073,741,822
/3224.0.0.031.255.255.255536,870,912536,870,910
/4240.0.0.015.255.255.255268,435,456268,435,454
/5248.0.0.07.255.255.255134,217,728134,217,726
/6252.0.0.03.255.255.25567,108,86467,108,862
/7254.0.0.01.255.255.25533,554,43233,554,430
/8255.0.0.00.255.255.25516,777,21616,777,214Class A size
/9255.128.0.00.127.255.2558,388,6088,388,606
/10255.192.0.00.63.255.2554,194,3044,194,302100.64.0.0/10 CGNAT
/11255.224.0.00.31.255.2552,097,1522,097,150
/12255.240.0.00.15.255.2551,048,5761,048,574172.16.0.0/12 private range
/13255.248.0.00.7.255.255524,288524,286
/14255.252.0.00.3.255.255262,144262,142
/15255.254.0.00.1.255.255131,072131,070
/16255.255.0.00.0.255.25565,53665,534Class B size
/17255.255.128.00.0.127.25532,76832,766
/18255.255.192.00.0.63.25516,38416,382
/19255.255.224.00.0.31.2558,1928,190
/20255.255.240.00.0.15.2554,0964,094
/21255.255.248.00.0.7.2552,0482,046
/22255.255.252.00.0.3.2551,0241,022
/23255.255.254.00.0.1.255512510
/24255.255.255.00.0.0.255256254Class C size, typical LAN
/25255.255.255.1280.0.0.127128126
/26255.255.255.1920.0.0.636462
/27255.255.255.2240.0.0.313230
/28255.255.255.2400.0.0.151614
/29255.255.255.2480.0.0.786
/30255.255.255.2520.0.0.342Classic point-to-point
/31255.255.255.2540.0.0.122Point-to-point (RFC 3021)
/32255.255.255.2550.0.0.011Single host

Private and special IPv4 ranges

BlockPurpose
10.0.0.0/8, 172.16.0.0/12, 192.168.0.0/16Private networks (RFC 1918), not routed on the internet
100.64.0.0/10Carrier-grade NAT shared space (RFC 6598)
127.0.0.0/8Loopback
169.254.0.0/16Link-local (APIPA), used when DHCP fails
192.0.2.0/24, 198.51.100.0/24, 203.0.113.0/24Documentation examples (TEST-NET-1, 2, 3)
224.0.0.0/4Multicast

Cloud providers reserve some addresses inside every subnet: AWS keeps the first four and the last one, so a /24 VPC subnet has 251 assignable addresses, not 254. Azure also reserves five per subnet.

Frequently asked questions

How do I calculate the number of hosts in a CIDR block?

Subtract the prefix from 32 to get the host bits, then raise 2 to that power for the total addresses. For normal IPv4 subnets subtract 2 for the network and broadcast addresses. A /24 has 2^8 = 256 addresses and 254 usable hosts; a /27 has 32 addresses and 30 usable hosts.

How do I convert an IP range to CIDR?

Switch to IP range to CIDR mode and enter the first and last address. The calculator returns the smallest set of CIDR blocks that covers exactly that range. For example, 192.168.1.10 to 192.168.1.20 becomes 192.168.1.10/31, 192.168.1.12/30, 192.168.1.16/30 and 192.168.1.20/32.

What is the difference between a subnet mask and CIDR notation?

They express the same thing. CIDR writes the number of network bits after a slash (/24); a subnet mask writes those bits as a dotted address with ones for network bits (255.255.255.0). You can type either form into the calculator.

Why does a /31 have two usable hosts?

RFC 3021 allows /31 subnets on point-to-point links, where no broadcast address is needed. Both addresses are assigned to the two ends of the link, so a /31 has 2 usable hosts instead of 0. A /32 is a single host route with 1 address.

What is a wildcard mask?

A wildcard mask is the bitwise inverse of the subnet mask, used in Cisco access lists and OSPF network statements. The wildcard for 255.255.255.0 is 0.0.0.255. The calculator shows it for every IPv4 block and also accepts a wildcard mask as input.

Does the CIDR calculator support IPv6?

Yes. Enter an IPv6 prefix such as 2001:db8:abcd:12::/64 to get the first and last address, the expanded form, the total number of addresses and how many /64 subnets fit inside. IPv6 has no broadcast address, so every address in the block is counted.

What happens if I enter an address with host bits set, like 192.168.1.130/25?

The calculator masks it to the real network, 192.168.1.128/25, shows a note, and calculates the block from there. Many routers and cloud consoles reject a CIDR with host bits set, so use the corrected network address in configuration.