What does this calculator do?
CIDR — Classless Inter-Domain Routing — writes a network as an address followed by a prefix length, such as 10.0.0.0/22. The prefix is the number of leading bits fixed by the network; everything after it addresses hosts. This calculator works in both directions: give it a prefix and it returns the mask, block size, host bits and address count; give it a number of addresses and it returns the smallest prefix whose block holds them. Results are exact integer values, not estimates. Everything is computed in your browser from the values you type. Nothing is looked up on the network — there is no ping, no DNS query, no WHOIS and no geolocation.
Formula
Block size doubles with every host bit, so the sizing question is a base-2 logarithm rounded up.
hostBits = 32 − prefix totalAddresses = 2^hostBits prefix = 32 − ceil(log2(requiredAddresses)) usableHosts = totalAddresses − 2 (ordinary subnets)
How to use it
Pick the mode first — the form then shows only the field that mode needs. In prefix mode enter a whole number from 0 to 32. In address mode enter how many addresses the block must hold; the answer is rounded up to the next power of two, because CIDR blocks only come in powers of two. If you need usable host addresses rather than raw addresses, use the IPv4 Host Calculator instead: it also reserves the network and broadcast addresses.
Worked example
Prefix mode with /24: host bits = 8, block size = 256 addresses, mask 255.255.255.0, 254 usable hosts. Address mode with 500 addresses: ceil(log2 500) = 9 host bits, so the answer is /23 — a 512-address block with 510 usable hosts, the smallest CIDR block that fits 500.
Frequently asked questions
Why does 500 addresses give a 512-address block?
CIDR blocks are always a power of two, so the sizes available around 500 are 256 and 512. The smallest block that can hold 500 addresses is therefore 512, which is /23. The 12 extra addresses stay free for growth.
What is the block increment?
It is the step between consecutive blocks of the same size in the octet that changes. Successive /26 blocks start at .0, .64, .128 and .192 — an increment of 64 in the last octet.
Is /24 the same as 255.255.255.0?
Yes. They are two notations for the same 24 leading 1-bits. CIDR notation is shorter and is what routing tables use; the dotted-decimal mask is what host configuration dialogs usually ask for.
Sources
- RFC 4632 — Classless Inter-Domain Routing (CIDR): the address-block, prefix-length and aggregation model used for every IPv4 subnet result on this page.
- RFC 3021 — Using 31-Bit Prefixes on IPv4 Point-to-Point Links: why a /31 has two usable addresses and no broadcast address, and why /32 is a single host.
- RFC 4291 — IP Version 6 Addressing Architecture: prefix and interface-identifier structure (IPv6 has no broadcast address). IPv6 output follows the canonical text form of RFC 5952.
- Reviewed: 2026-08-10
Related calculators
Last updated: 2026-08-10 · v1.0.0 · Report an error