CIDR calculator for IPv4 and IPv6 subnets
This CIDR calculator takes an address and prefix length and works out everything you need to plan or debug a subnet: the netmask, the wildcard mask, the network and broadcast addresses, the first and last usable host, the number of addresses, and whether the block is private or public. It also shows the mask and address in binary and the block as an integer range.
What CIDR notation means
Classless Inter-Domain Routing (CIDR, RFC 4632) writes a network as address/n, where n is how many leading bits belong to the network. The remaining 32 − n bits number the hosts inside it. CIDR replaced the fixed class A, B and C sizes in 1993, so a block can have any size that is a power of two.
Worked example: 192.168.10.37/26
Address: 192.168.10.37
CIDR notation: 192.168.10.0/26
Netmask: 255.255.255.192
Wildcard mask: 0.0.0.63
Network address: 192.168.10.0
Broadcast address: 192.168.10.63
First usable host: 192.168.10.1
Last usable host: 192.168.10.62
Total addresses: 64
Usable hosts: 62
Scope: Private (RFC 1918)
Step by step: /26 means 26 one-bits, so the last octet of the mask is 11000000 = 192. The block size is 232−26 = 64, which splits the last octet into ranges starting at 0, 64, 128 and 192. The host .37 falls in the first range, so the network is .0 and the broadcast is .63. Excluding those two leaves .1 to .62: 62 usable hosts.
The formulas
- Netmask: n one-bits followed by 32 − n zero-bits.
- Wildcard mask: the inverse of the netmask, or 255 minus each mask octet. Cisco ACLs and OSPF statements use it.
- Network address: address AND netmask.
- Broadcast address: network OR wildcard.
- Usable hosts: 232−n − 2 for prefixes up to /30.
| Prefix | Netmask | Addresses | Usable hosts |
|---|---|---|---|
| /8 | 255.0.0.0 | 16,777,216 | 16,777,214 |
| /16 | 255.255.0.0 | 65,536 | 65,534 |
| /20 | 255.255.240.0 | 4,096 | 4,094 |
| /24 | 255.255.255.0 | 256 | 254 |
| /27 | 255.255.255.224 | 32 | 30 |
| /29 | 255.255.255.248 | 8 | 6 |
| /30 | 255.255.255.252 | 4 | 2 |
The /31 and /32 special cases
A /31 has only two addresses. RFC 3021 allows both to be used on point-to-point links, since such a link needs no broadcast address, so the calculator reports 2 usable hosts; the "broadcast" line simply shows the upper address. A /32 is a single address, used for loopback interfaces, host routes and one-address firewall or security-group rules, and counts as 1 usable host.
Private ranges and scope
RFC 1918 reserves three blocks for private networks: 10.0.0.0/8 (16,777,216 addresses), 172.16.0.0/12 (172.16.0.0 to 172.31.255.255) and 192.168.0.0/16. The scope line also recognizes loopback (127.0.0.0/8), link-local (169.254.0.0/16), carrier-grade NAT (100.64.0.0/10, RFC 6598) and multicast (224.0.0.0/4). The class line is shown for reference only; classes no longer affect routing.
IPv6 prefixes
Enter a block such as 2001:db8:abcd:12::/64 to get the network, first and last address, expanded form and total count, here 18446744073709551616 (264). IPv6 has no broadcast address, so there is no usable-host subtraction.
Common mistakes
- Host bits in a network ID. 192.168.10.37/26 describes a host, not a network. The calculator shows the real network, 192.168.10.0/26; many routers and cloud consoles reject the unaligned form.
- Non-contiguous masks. A mask such as 255.0.255.0 is rejected, because a netmask must be ones followed by zeros.
- Mixing up mask and wildcard. 0.0.0.63 in an ACL is not the same as the netmask 255.255.255.192.
- Cloud reservations. Providers keep some addresses for themselves; AWS, for instance, reserves five in every VPC subnet, so a /28 gives you 11 hosts there, not 14.
To see the AND operation bit by bit, convert the address with IP to Binary or try the AND calculator. For IPv6 bit patterns, use IPv6 to Binary. All calculations run in your browser.