What is CIDR and how to read /24 notation
CIDR is how you write an IP network together with its size: 192.168.1.0/24. Here is what that number means, how to work with it and why it replaced classes.
The idea in one sentence
CIDR (Classless Inter-Domain Routing) describes a network by its first address and the number of bits that make up the network part. In 192.168.1.0/24, the first 24 bits (192.168.1) identify the network and the remaining 8 number the devices within it.
The number after the slash is called the prefix or prefix length. The bigger it is, the smaller the network: a /24 has 256 addresses, a /25 half that (128) and a /23 twice as many (512).
How to work out the size of a block
An IPv4 address has 32 bits. If the prefix is /n, 32 − n bits are left for devices, so the block has 2 to the power of (32 − n) addresses:
- /32: 1 address (a single device).
- /30: 4 addresses, 2 usable (links between routers).
- /29: 8 addresses, 6 usable.
- /28: 16 addresses, 14 usable.
- /27: 32 addresses, 30 usable.
- /26: 64 addresses, 62 usable.
- /24: 256 addresses, 254 usable (the typical home or office network).
- /16: 65,536 addresses.
- /8: 16,777,216 addresses.
Two are subtracted because the first address identifies the network and the last is the broadcast address. The exception is /31, which uses both its addresses on point-to-point links (RFC 3021).
From prefix to subnet mask
The subnet mask says the same as the prefix, but written as an address: network bits set to 1 and host bits set to 0. A /24 is 24 ones followed by 8 zeros, that is, 11111111.11111111.11111111.00000000, which in decimal is 255.255.255.0.
- /8 = 255.0.0.0
- /16 = 255.255.0.0
- /20 = 255.255.240.0
- /24 = 255.255.255.0
- /26 = 255.255.255.192
- /28 = 255.255.255.240
- /30 = 255.255.255.252
A shortcut: in the octet where the network part ends, the mask is 256 minus the block size in that octet. A /26 makes blocks of 64 in the last octet, so the mask ends in 256 − 64 = 192.
How to find which network an IP belongs to
To find the network of 192.168.1.130/26, divide the last octet by the block size (64) and take the lower multiple: 130 lies between 128 and 191, so the network is 192.168.1.128/26, the first host 192.168.1.129, the last 192.168.1.190 and the broadcast 192.168.1.191.
In binary it is an AND operation between the IP and the mask, which is what a router does for every packet. The subnet calculator shows all these values, binary included, so you can check your work.
Why CIDR replaced classes
Until 1993, networks could only come in three sizes: class A (/8), B (/16) or C (/24). A company that needed 2,000 addresses got a whole class B with 65,536 and wasted the rest. At the same time, Internet routing tables grew out of control, because every class C was a separate route.
CIDR made it possible to give each organization a block of just the right size (a /21 for those 2,000 addresses) and to group many adjacent networks into a single route (summarization). The whole Internet works this way today, and the same notation is used in IPv6: 2001:db8::/32, /48, /64.
Frequently asked questions
What does /24 mean in an IP address?
That the first 24 bits are the network part. It is equivalent to the mask 255.255.255.0 and to a block of 256 addresses, 254 of which can be assigned to devices.
Is CIDR the same as subnetting?
They are related: CIDR is the notation and the system of variable-size blocks; subnetting is splitting a network into smaller subnets, which are described with CIDR notation.
What is a supernet?
A block that groups several adjacent networks, for example 192.168.0.0/22 for the four /24s from 192.168.0.0 to 192.168.3.0. It is used to advertise one route instead of several.
How do I convert an arbitrary range into CIDR notation?
It has to be split into aligned power-of-two blocks. The IP range to CIDR tool does it automatically and gives you the shortest list.