CIDR to IP Range

Convert CIDR notation to IP range

Understanding CIDR Notation
TL;DR

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.

CIDR /24 Binary Mask Visualization A diagram showing a 32-bit IPv4 address divided into 24 network bits (highlighted) and 8 host bits, with the subnet mask 255.255.255.0 shown below. 192.168.1.0/24 — Binary Mask 1 1 0 0 0 0 0 0 1 0 1 0 1 0 0 0 0 0 0 0 0 0 0 1 0 0 0 0 0 0 0 0 24 network bits (fixed) 8 host bits Subnet Mask: 255.255.255.0 11111111 11111111 11111111 00000000 255 255 255 0 Network: 192.168.1.0 | Broadcast: 192.168.1.255 Usable range: 192.168.1.1 - 192.168.1.254 (254 hosts) Hosts = 2^(32 - prefix) - 2 = 2^8 - 2 = 254 (subtract network address and broadcast address)

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:

  1. Convert the IP to binary: 192.168.1.0 = 11000000.10101000.00000001.00000000
  2. Apply the mask: The first 24 bits are the network portion (fixed). The remaining 8 bits are the host portion (variable).
  3. Network address: Set all host bits to 0 = 11000000.10101000.00000001.00000000 = 192.168.1.0
  4. Broadcast address: Set all host bits to 1 = 11000000.10101000.00000001.11111111 = 192.168.1.255
  5. Usable range: 192.168.1.1 through 192.168.1.254 (254 hosts)

Quick Reference Table

PrefixSubnet MaskTotal AddressesUsable HostsTypical Use
/8255.0.0.016,777,21616,777,214Major ISPs, large enterprises
/16255.255.0.065,53665,534Corporate campus networks
/24255.255.255.0256254Standard LAN segment
/28255.255.255.2401614Small department, DMZ
/30255.255.255.25242Point-to-point router link
/32255.255.255.25511Single 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/8 for 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

Standard /24 Network Valid

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
Invalid Prefix Length Invalid

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