CIDR to IP Range
Convert CIDR notation to IP range
CIDR notation like 192.168.1.0/24 represents a block of IP addresses. The number after the slash is the prefix length — it tells you how many addresses are in the block.
What is CIDR?
CIDR (Classless Inter-Domain Routing, pronounced “cider”) is a method for allocating IP addresses and routing IP packets. Introduced in 1993 to replace the rigid classful addressing system, CIDR allows network administrators to define address blocks of any size using a compact notation that combines an IP address with a prefix length.
A CIDR block is written as an IP address followed by a forward slash and a number: 192.168.1.0/24. The number after the slash (the prefix length) indicates how many bits of the address are fixed as the network portion. The remaining bits identify individual hosts within that network.
Before CIDR, organizations had to choose between a Class C network (256 addresses), a Class B network (65,536 addresses), or a Class A network (16.7 million addresses). A company needing 1,000 addresses would receive an entire Class B — wasting over 64,000 addresses. CIDR eliminated this waste by allowing blocks of any power-of-two size.
How Prefix Length Works
The prefix length determines the split between the network portion and the host portion of an address. A longer prefix means more bits are reserved for the network (smaller block), while a shorter prefix means fewer network bits (larger block).
For IPv4 (32-bit addresses), the prefix can range from /0 (the entire internet — 4.3 billion addresses) to /32 (a single host).
The number of addresses in a CIDR block is calculated as: 2^(32 - prefix_length)
For example, a /24 block provides 2^(32-24) = 2^8 = 256 addresses. Of these, the first address is the network address (e.g., 192.168.1.0) and the last is the broadcast address (e.g., 192.168.1.255), leaving 254 usable host addresses.
Calculating Address Ranges
To convert a CIDR block to an IP range, you need to determine the network address (first IP), the broadcast address (last IP), and the usable range in between.
Here is the step-by-step calculation for 192.168.1.0/24:
- Convert the IP to binary: 192.168.1.0 =
11000000.10101000.00000001.00000000 - Apply the mask: The first 24 bits are the network portion (fixed). The remaining 8 bits are the host portion (variable).
- Network address: Set all host bits to 0 =
11000000.10101000.00000001.00000000= 192.168.1.0 - Broadcast address: Set all host bits to 1 =
11000000.10101000.00000001.11111111= 192.168.1.255 - Usable range: 192.168.1.1 through 192.168.1.254 (254 hosts)
Quick Reference Table
| Prefix | Subnet Mask | Total Addresses | Usable Hosts | Typical Use |
|---|---|---|---|---|
/8 | 255.0.0.0 | 16,777,216 | 16,777,214 | Major ISPs, large enterprises |
/16 | 255.255.0.0 | 65,536 | 65,534 | Corporate campus networks |
/24 | 255.255.255.0 | 256 | 254 | Standard LAN segment |
/28 | 255.255.255.240 | 16 | 14 | Small department, DMZ |
/30 | 255.255.255.252 | 4 | 2 | Point-to-point router link |
/32 | 255.255.255.255 | 1 | 1 | Single host route |
The /24 is by far the most common block size in practice. It provides 254 usable addresses, which is sufficient for most LAN segments while being easy to manage and remember.
Supernetting and Aggregation
CIDR also enables supernetting (route aggregation) — combining multiple smaller blocks into a single larger one to reduce the size of routing tables. For example, four contiguous /24 blocks (192.168.0.0/24 through 192.168.3.0/24) can be aggregated into a single /22 block (192.168.0.0/22).
This is the reverse of subnetting: instead of dividing a block into smaller pieces, you merge adjacent blocks into a larger one. ISPs use supernetting extensively to keep the global routing table manageable — without it, core routers would need millions of additional entries.
Common Use Cases
- Firewall rules: CIDR blocks define which IP ranges are allowed or denied access to services (e.g., allow
10.0.0.0/8for internal traffic) - Cloud networking: AWS VPCs, Azure VNets, and GCP VPCs all use CIDR blocks to define virtual network address spaces
- IP address planning: Network architects use CIDR to allocate address space efficiently across departments, data centers, and regions
- Access control lists: Router ACLs use CIDR to match traffic from specific networks for filtering or quality-of-service policies
- BGP routing: Internet service providers advertise CIDR blocks via BGP to announce the IP prefixes they are responsible for
- Whitelisting: API services and SaaS platforms accept CIDR ranges to restrict access to known client networks
Try These Examples
A /24 block covers 256 addresses (192.168.1.0 to 192.168.1.255). The first 24 bits are the network portion, leaving 8 bits (2^8 = 256) for host addresses. Usable hosts: 254 (excluding network and broadcast addresses).
192.168.1.0/24 IPv4 addresses are 32 bits long, so the prefix length must be between 0 and 32. A /33 prefix exceeds the total bit length and is invalid.
10.0.0.0/33