Short answer
CIDR notation writes an IP range as an address, a slash and a number, like 192.168.1.0/24. The number is the prefix length: how many leading bits are fixed for the network. The remaining bits number the addresses, so an IPv4 /24 holds 232−24 = 256 addresses.
How to read a CIDR block
Take 111.221.48.0/24, a real range used by a Malaysian ISP. An IPv4 address is 32 bits, written as four 8-bit numbers. The /24 says the first 24 bits, that is the first three numbers 111.221.48, are fixed. The last 8 bits are free, so the block runs from:
- first address:
111.221.48.0 - last address:
111.221.48.255 - size: 28 = 256 addresses
- equivalent subnet mask:
255.255.255.0
An address belongs to a block when its first n bits match. 111.221.48.163 is inside 111.221.48.0/24; 111.221.49.10 is not. The address part of a block should have all its free bits set to zero: 8.8.8.5/24 is usually normalised to 8.8.8.0/24.
The formula
The size of any block is 2 to the power of the free bits:
- IPv4: addresses = 232 − prefix
- IPv6: addresses = 2128 − prefix
Each step of one in the prefix halves or doubles the block: a /23 is two /24s, a /25 is half a /24. In a classic local network the first address (network) and the last (broadcast) are not given to devices, so a /24 has 254 usable host addresses. The exceptions are /31 (two addresses for a point-to-point link, RFC 3021) and /32 (exactly one address).
Common IPv4 sizes
| Prefix | Addresses | Subnet mask | Typical use |
|---|---|---|---|
| /8 | 16,777,216 | 255.0.0.0 | Early allocations to very large organisations |
| /16 | 65,536 | 255.255.0.0 | A large ISP or university block |
| /20 | 4,096 | 255.255.240.0 | A medium ISP or hosting block |
| /22 | 1,024 | 255.255.252.0 | A common minimum allocation from registries today |
| /24 | 256 | 255.255.255.0 | Smallest block normally routed on the internet; a typical LAN |
| /26 | 64 | 255.255.255.192 | A small office or cloud subnet |
| /28 | 16 | 255.255.255.240 | A small block of static IPs from an ISP |
| /30 | 4 | 255.255.255.252 | Older point-to-point links (2 usable) |
| /31 | 2 | 255.255.255.254 | Point-to-point links |
| /32 | 1 | 255.255.255.255 | A single host, e.g. in firewall rules |
IPv6 prefixes: /32, /48, /56 and /64
IPv6 addresses are 128 bits, so the same notation describes far bigger blocks. The convention is that the last 64 bits identify a device and the first 64 identify the network:
| Prefix | Size | Typical use |
|---|---|---|
| /32 | 65,536 × /48 | Allocation from a registry to an ISP, e.g. 2001:4860::/32 (Google) |
| /48 | 65,536 × /64 | A site or business; the smallest IPv6 block normally routed on the internet |
| /56 | 256 × /64 | A common assignment to a home customer |
| /64 | 264 ≈ 18.4 quintillion addresses | One subnet (one LAN); required for automatic address setup (SLAAC) |
| /128 | 1 | A single address |
So in IPv6 you count subnets, not addresses: a home with a /56 can run 256 separate /64 networks. The range 2001:db8::/32 is reserved for documentation, like the examples in this article.
Why CIDR exists
Before 1993 IPv4 used fixed classes: class A (a /8), class B (a /16) and class C (a /24). An organisation needing 2,000 addresses had to take a whole class B with 65,536, wasting most of it. CIDR (Classless Inter-Domain Routing, RFC 1518/1519, now RFC 4632) allowed blocks of any size and let ISPs aggregate many customer blocks into one announcement, which slowed both IPv4 exhaustion and the growth of routing tables.
Where you will see CIDR
Firewall rules, cloud security groups, VPN configs and BGP announcements all use CIDR. On this site every routed block has its own prefix page, for example 8.8.8.0/24 for Google's DNS, with its range, the ASN that announces it and where its addresses are seen. In the API the block containing an address is connection.route.
To check sizes and membership in code, Python's standard library is enough:
import ipaddress
net = ipaddress.ip_network("111.221.48.0/24")
net.num_addresses # 256
ipaddress.ip_address("111.221.48.163") in net # True
ipaddress.ip_network("2001:db8::/48").num_addresses == 2**80 # True [ FAQ ]
Frequently asked questions
How many IP addresses are in a /24?
A /24 holds 256 IPv4 addresses (2 to the power of 8). In a traditional local network 254 of them can be given to devices, because the first is the network address and the last is the broadcast address.
What does /32 mean?
In IPv4, /32 means all 32 bits are fixed, so it is exactly one address. In IPv6, /32 is a large block of 2 to the power of 96 addresses, the typical size a registry allocates to an ISP.
What is the difference between CIDR notation and a subnet mask?
They carry the same information in different forms. /24 is the same as the mask 255.255.255.0 and /26 is the same as 255.255.255.192. CIDR is shorter and also works for IPv6, which does not use dotted masks.
Why do ISPs give IPv6 customers a /56 or /48 instead of one address?
Each IPv6 subnet is expected to be a /64, so a single address is not enough for a home or office with more than one network. A /56 gives 256 subnets and a /48 gives 65,536.
Last updated · All articles · API docs