zaro

How Do CIDR Ranges Work?

Published in Network Addressing 4 mins read

CIDR, or Classless Inter-Domain Routing, is a fundamental networking method that enhances IP address allocation efficiency and improves routing across the internet by providing a flexible way to define network boundaries.

What is CIDR?

Before CIDR, IP addresses were rigidly categorized into "classes" (A, B, C), which led to significant waste of IP addresses and cumbersome routing tables. Introduced in the early 1990s, CIDR revolutionized IP address management by allowing network administrators to create variable-sized network blocks, overcoming the limitations of classful addressing.

A CIDR IP address appends a suffix value stating the number of network address prefix bits to a normal IP address. This suffix, also known as the prefix length or CIDR mask, dictates how many bits from the left-hand side of an IP address identify the network, and how many identify individual hosts within that network.

For instance, 192.0.2.0/24 is an IPv4 CIDR address where the first 24 bits, or 192.0.2, constitute the network address. This means:

  • Network Portion: The bits defined by the prefix length (e.g., 24 bits in /24) identify the specific network. All devices within this CIDR block belong to the same logical network.
  • Host Portion: The remaining bits (e.g., 32 total bits - 24 network bits = 8 host bits for IPv4) are used to assign unique addresses to individual devices (hosts) on that network.

The number of host bits directly determines the size of the network: a smaller prefix length (e.g., /8) creates a larger network with more potential host IP addresses, while a larger prefix length (e.g., /30) defines a smaller network with fewer available host addresses.

Understanding CIDR Notation

Let's break down a common CIDR block, such as 192.168.1.0/24, to see how it works:

  • 192.168.1.0: This is the base IP address for the network.
  • /24: This is the CIDR prefix length. It signifies that the first 24 bits of the 32-bit IPv4 address are allocated to the network part.

In binary, an IPv4 address has 32 bits. A /24 prefix implies:

  • 24 bits are for the network (192.168.1.xxx).
  • 8 bits are for the hosts (32 - 24 = 8).

The total number of IP addresses within a CIDR block is calculated as 2^(number of host bits). From this total, two addresses are reserved:

  • The network address (where all host bits are 0).
  • The broadcast address (where all host bits are 1).

Therefore, the number of usable host addresses is 2^(number of host bits) - 2.

Example: 192.168.1.0/24

  • Network Address: 192.168.1.0
  • Broadcast Address: 192.168.1.255
  • Usable IP Range: 192.168.1.1 to 192.168.1.254
  • Number of Usable Hosts: 2^8 - 2 = 256 - 2 = 254

Key Benefits of CIDR

CIDR is indispensable in modern networking due to its numerous advantages:

  1. Efficient IP Address Allocation: CIDR allows for a more granular and flexible distribution of IP addresses, preventing the waste of large address blocks that was common with classful addressing. This efficiency is critical in mitigating IPv4 address exhaustion.
  2. Route Aggregation (Supernetting): One of CIDR's most significant benefits is the ability to aggregate multiple smaller networks into a single, larger routing table entry. For example, 192.168.0.0/24, 192.168.1.0/24, 192.168.2.0/24, and 192.168.3.0/24 could be summarized as 192.168.0.0/22. This significantly reduces the size of routing tables on internet routers, improving performance and efficiency.
  3. Flexible Subnetting: Network administrators can easily divide a large IP range into smaller, variable-sized subnets, tailoring network segments precisely to specific organizational or departmental requirements without being constrained by fixed class boundaries.

Common CIDR Prefixes and Host Counts

Understanding how the prefix length directly impacts the number of available IP addresses is essential for network design.

CIDR Prefix Subnet Mask Total Addresses Usable Host Addresses
/8 255.0.0.0 16,777,216 16,777,214
/16 255.255.0.0 65,536 65,534
/24 255.255.255.0 256 254
/27 255.255.255.224 32 30
/30 255.255.255.252 4 2

Note: While IPv6 uses 128-bit addresses, the principle of CIDR with prefix lengths remains the same.

Practical Applications of CIDR

CIDR is a cornerstone of modern network architecture and internet operation:

  • Internet Service Providers (ISPs): ISPs widely use CIDR to allocate IP address blocks to their customers and to aggregate routes, optimizing traffic flow across the internet backbone.
  • Cloud Computing: Cloud providers (e.g., AWS, Azure, GCP) rely heavily on CIDR to define Virtual Private Clouds (VPCs) and their subnets. When you create a VPC, you specify a CIDR block (e.g., 10.0.0.0/16) and then subdivide it into smaller CIDR blocks for individual subnets.
  • Enterprise Networks: Organizations leverage CIDR to design and manage their internal networks, segmenting them into appropriately sized subnets for different departments, applications, or geographical locations.
  • Firewall Rules: CIDR blocks are frequently employed in firewall configurations to permit or deny network traffic from entire ranges of IP addresses, streamlining security policy management.

By grasping the mechanics of CIDR ranges, network professionals can effectively design, manage, and secure complex network infrastructures.