If you have ever stared at 192.168.1.0/26 in a firewall rule and quietly guessed, this is CIDR notation explained from the ground up. CIDR (Classless Inter-Domain Routing) notation is a compact way to describe a block of IP addresses: the part before the slash is the starting address, and the number after the slash tells you how many leading bits of the address are fixed. Everything else - netmasks, ranges, "how many hosts fit in a /26" - falls out of that one idea.
By the end of this post you will be able to read any CIDR block, compute its range by hand, and know why the notation exists at all. When you want to check your work, our free IP subnet calculator does the math for IPv4 and IPv6 instantly, no signup needed.
CIDR notation explained: what /24 actually means
An IPv4 address is 32 bits, conventionally written as four octets of 8 bits each. The /24 in 192.168.1.0/24 is the prefix length: the number of leading bits that are fixed and shared by every address in the block. The remaining bits (32 minus the prefix length) are free to vary - those are the host bits.
For /24, the first 24 bits (the first three octets) are fixed and the last 8 bits vary:
192.168.1.0/24
fixed: 192.168.1. (24 bits)
varies: 0-255 (8 bits)
So 192.168.1.0/24 means "every address from 192.168.1.0 through 192.168.1.255". The address count is always 2 raised to the number of host bits: 2^8 = 256 addresses.
Two conventions to know for IPv4 subnets: the first address in a block is the network address and the last is the broadcast address, and neither is normally assigned to a host. That is why a /24 has 256 addresses but 254 usable hosts. (This applies to subnets on a LAN; a CIDR block in an allowlist or a routing table is just a range, and all 256 addresses count.)
Netmasks and CIDR: the same thing, two spellings
Before CIDR notation, the same information was written as a netmask: a 32-bit value with ones for the fixed bits and zeros for the host bits. /24 and 255.255.255.0 are literally the same 24 ones written two different ways. Here is the table worth internalizing:
| Prefix | Netmask | Addresses | Usable hosts | Typical use |
|---|---|---|---|---|
| /8 | 255.0.0.0 | 16,777,216 | 16,777,214 | Huge legacy allocations |
| /16 | 255.255.0.0 | 65,536 | 65,534 | Large private networks |
| /20 | 255.255.240.0 | 4,096 | 4,094 | Cloud VPC subnets |
| /24 | 255.255.255.0 | 256 | 254 | The classic LAN subnet |
| /26 | 255.255.255.192 | 64 | 62 | Splitting a /24 in four |
| /28 | 255.255.255.240 | 16 | 14 | Small server segments |
| /30 | 255.255.255.252 | 4 | 2 | Point-to-point links |
| /32 | 255.255.255.255 | 1 | 1 (host) | A single address |
The pattern in the last octet of the netmask (0, 192, 240, 252, 255) is just the leading bits filling in: 192 is 11000000, 240 is 11110000, 252 is 11111100. A /32 is a single address - when a firewall rule says 203.0.113.7/32, it means exactly that one IP. Halve the addresses each time the prefix grows by one; that is the whole trick.
If you need to move between representations - dotted decimal, binary, hex, integer - the IP converter shows the same address in all of them side by side, which makes the bit patterns much easier to see.
Worked example: computing the range of 192.168.1.0/26
Take 192.168.1.0/26 and work it out by hand.
Step 1: count the host bits. 32 - 26 = 6 host bits, so the block contains 2^6 = 64 addresses.
Step 2: find the block boundaries. The first 26 bits are fixed. The first three octets (24 bits) are fully fixed at 192.168.1, and 2 more fixed bits sit at the top of the last octet. That means the last octet counts through blocks of 64: 0, 64, 128, 192. Our block starts at .0, so:
- Network address:
192.168.1.0 - Last address (broadcast):
192.168.1.63 - Usable host range:
192.168.1.1to192.168.1.62(62 hosts)
Step 3: sanity-check membership. Is 192.168.1.100 inside 192.168.1.0/26? No - 100 falls in the next block of 64, which is 192.168.1.64/26 (addresses .64 through .127). This is exactly the mistake that leads to allowlist entries that silently do not match; the boundaries are powers of two, not round decimal numbers.
That is the entire method: host bits give you the size, and the block starts at a multiple of that size. Run the same block through the IP calculator and you will see the identical network address, broadcast, netmask, and host count - use it to verify your hand-math until the pattern sticks.
Why CIDR replaced classful addressing
Until 1993, IPv4 addresses came in three fixed sizes determined by their leading bits: Class A (/8, about 16.7M addresses), Class B (/16, 65,536), and Class C (/24, 256). The granularity was terrible. An organization with 300 hosts was too big for a Class C and got a Class B - wasting more than 65,000 addresses - and there were only 16,384 Class B networks to hand out. Address space was running out, and the global routing table was growing at an unsustainable rate because every network needed its own route entry.
CIDR, standardized in what is now RFC 4632, fixed both problems by making the prefix length explicit and arbitrary. Registries could allocate a /19 or /22 - right-sized blocks - and routers could aggregate routes: instead of advertising 256 separate /24s, a provider advertises one /16 that covers them all. Prefix length also drives routing decisions today via longest-prefix match: when multiple routes cover an address, the most specific (longest) prefix wins. The "classless" in the name is the point - the address itself no longer implies its size.
You still see the classful ghost in words like "a class C" (people mean a /24), but no modern equipment thinks in classes.
CIDR in IPv6
IPv6 uses identical notation with 128-bit addresses, and the numbers are pleasantly boring: the near-universal convention (RFC 4291) is that a single subnet is a /64 - 64 bits of network prefix, 64 bits of interface identifier. Stateless address autoconfiguration (SLAAC) depends on that split, so subnets smaller than /64 are rare on LANs. Above that, ISPs typically delegate a /56 or /48 to a site, which then carves out /64s per subnet. Nobody talks about usable-host subtraction in IPv6; a /64 holds 2^64 addresses and exhaustion within a subnet is not a practical concern.
Where developers actually meet CIDR
You do not need to be a network engineer to hit CIDR weekly:
- Cloud security groups and firewall rules.
0.0.0.0/0means "everything" (all 32 bits vary);10.0.0.0/8is the RFC 1918 private range; that one open/0rule is the classic audit finding. - Allowlists and rate limiting. Office IPs, partner integrations, and webhook sources are usually specified as CIDR blocks, and off-by-one boundary mistakes (see the /26 example above) are the usual failure mode.
- VPC and subnet planning. Choosing between a /20 and a /24 per subnet decides how many instances fit and how much room you leave for growth.
- IP intelligence data. CIDR is how networks are announced and registered. In The IP API's lookup response, the
asn.networkfield is the CIDR prefix the address is announced under, andcompany.routeis the registered route - for8.8.8.8both come back as8.8.8.0/24, alongsidecompany.networkgiving the same block as an explicit range (8.8.8.0 - 8.8.8.255). Reading those fields is just reading CIDR. The full response shape is in the API documentation, and if you want to understand who announces those prefixes and why, see our explainer on what an ASN is.
Check your work, then automate it
CIDR stops being intimidating the moment you internalize one sentence: the prefix length is the number of fixed bits, and everything else is powers of two. Practice with the IP calculator until block boundaries feel obvious, and when you need network data programmatically - the announced prefix, route, and organization behind any IP - sign up for a free API key. The free tier includes 1,000 requests per day, no card required.