What is CIDR notation?
Definition
CIDR is the notation and allocation scheme that writes a block of IP addresses as an address followed by a prefix length, such as 203.0.113.0/24.
Everything after the slash is bit arithmetic. Once you can do it in your head, an allowlist entry, a whois answer or a firewall rule stops needing a calculator. The number counts the leading bits that every address in the block shares. The bits left over are free to vary, and each one left over doubles the size of the block.
CIDR replaced the old class A, B and C boundaries, which only allowed blocks of 8, 16 or 24 fixed bits. RFC 4632 lets a prefix be any length, so a network can be sized to what it needs and neighbouring blocks can be announced as one route. Aggregation is the same arithmetic run backwards: 198.51.100.0/25 and 198.51.100.128/25 differ only in their 25th bit, so together they are 198.51.100.0/24, and Python’s ipaddress.collapse_addresses() returns exactly that single network when given the two halves.
One address, read bit by bit
Take 203.0.113.77/26. Written in binary, the first 26 bits are the network and the last 6 are the host part:
203.0.113.77/26
11001011.00000000.01110001.01|001101
<------- 26 network bits ------->|<- 6 host bits ->
host bits all 0 203.0.113.64 first address of the block
host bits all 1 203.0.113.127 last address of the block
size 2^6 = 64 addresses
The same rule runs over 128 bits for IPv6, so the size of any block is 2 to the power of (32 minus the prefix) for IPv4 and (128 minus the prefix) for IPv6. Python’s standard library does the arithmetic and is the quickest way to check your own. This is the real output on Python 3.15.0:
import ipaddress
n = ipaddress.ip_network("203.0.113.64/26")
print(n.num_addresses, n.netmask, n[0], n[-1])
print(ipaddress.ip_network("203.0.113.77/24", strict=False))
ipaddress.ip_network("203.0.113.77/24")
64 255.255.255.192 203.0.113.64 203.0.113.127
203.0.113.0/24
ValueError: 203.0.113.77/24 has host bits set
The last line matters more than it looks. 203.0.113.77/24 is a host written with its network’s prefix, which is how interface addresses are often shown, but it is not a block. A strict parser refuses it. A lenient one rounds it down to 203.0.113.0/24, which may be far wider than the single address you meant to allow. When a control panel accepts a range, read back what it stored.
Sizes you will meet
| Prefix | Family | Size | Where it turns up |
|---|---|---|---|
/32 |
IPv4 | 1 address | One host in an allowlist or firewall rule |
/31 |
IPv4 | 2 addresses | Point-to-point links, where RFC 3021 lets both be used |
/29 |
IPv4 | 8 addresses | Six usable hosts once the network and broadcast addresses are set aside |
/24 |
IPv4 | 256 addresses | The route returned for 1.1.1.1 in the lookup below |
/10 |
IPv4 | 4,194,304 addresses | 100.64.0.0/10, the shared space reserved for carrier-grade NAT |
/128 |
IPv6 | 1 address | One IPv6 host |
/64 |
IPv6 | 18,446,744,073,709,551,616 addresses | One IPv6 subnet, because RFC 4291 fixes interface identifiers at 64 bits |
/48 |
IPv6 | 65,536 subnets of /64 | The end-site size RFC 3177 once recommended; RFC 6177 left the choice to operators |
Where proxy work runs into it
Allowlists. Providers that authorise by source address take a /32 for one machine. If your traffic leaves through a NAT pool or a cloud range, you list the range instead, and every host inside it gains access. That trade is covered under IP whitelisting.
Bypass lists. A range in no_proxy works in some clients and silently fails in others. curl and Go match an address against the network; CPython’s urllib compares strings, so 10.0.0.0/8 never matches 10.1.2.3 and the request goes to the proxy. The guide to proxy environment variables has the tested behaviour per client.
Reading an exit address. Registries and routing databases record the block an address belongs to and the network that announces it:
$ whois -h whois.radb.net 1.1.1.1 | grep -E '^(route|origin|source):'
route: 1.1.1.0/24
origin: AS13335
source: APNIC
route: 1.1.1.0/24
origin: AS13335
source: RADB
route: 1.1.1.0/24
origin: AS13335
source: RPKI # Trust Anchor: apnic
Three databases hold a route object for the same /24, all naming the same origin ASN. That block is the unit a reputation system can act on in one step, and it says nothing about how many of its 256 addresses any provider actually holds. Counting how your own addresses fall into blocks is a subnet question, and the checks worth running before you buy are in residential vs datacenter vs ISP vs mobile.
The whois output above was captured on 21 October 2026 against whois.radb.net, filtered to three fields. Route objects change when networks re-announce space, so run the query again rather than relying on this copy.
Frequently asked questions
How do I work out how many addresses a CIDR block holds?
Is 192.168.1.10/24 a valid CIDR block?
What is the difference between CIDR notation and a subnet mask?
Sources
- RFC 4632: Classless Inter-domain Routing (CIDR), the prefix notation and aggregation plan
- RFC 4291: IP Version 6 Addressing Architecture, 64-bit interface identifiers
- RFC 3021: Using 31-Bit Prefixes on IPv4 Point-to-Point Links
- RFC 6177: IPv6 Address Assignment to End Sites, replacing the /48 recommendation of RFC 3177
- RFC 6598: IANA-Reserved IPv4 Prefix for Shared Address Space, 100.64.0.0/10
- Python documentation: ipaddress, IPv4/IPv6 manipulation library
- RADb: the routing registry queried for the route objects shown