CIDR Notation

Thirdpen

CIDR Notation

CIDR, or Classless Inter-Domain Routing, is the modern way we allocate IP addresses and route internet traffic. Think of it as a flexible and efficient way to define the size of a network, much like specifying not just a street name, but also how many houses are on it.

Before CIDR, IP addresses were grouped into rigid classes (Class A, B, and C). This system was wasteful. For instance, a small organization needing 300 addresses would have to be assigned a Class B block, which contains 65,536 addresses, leaving the vast majority unused. CIDR was introduced to solve this problem.

At its core, CIDR notation combines an IP address with a number, like this: 192.168.1.0/24.

  • 192.168.1.0 is the network address.
  • /24 is the "prefix length." It tells us how many bits of the IP address are used for the network portion.

An IP address is a 32-bit number. The prefix length specifies how many of those 32 bits, from left to right, define the network itself. The remaining bits are available to be assigned to individual devices (hosts) on that network.


Anatomy of a CIDR Notation

Let's break down 192.168.1.0/24. The /24 prefix means the first 24 bits identify the network. This leaves the remaining 8 bits (32 total - 24 network = 8 host) to identify individual computers, servers, or other devices.

Use the calculator below to see how the prefix length changes the network. Adjust the slider to see how the IP address is split between the network and host portions.


How Network Details are Calculated

From a single CIDR notation, we can determine several key properties of a network:

  1. Subnet Mask: This is a 32-bit number that "masks" the IP address to reveal the network address. The CIDR prefix is just a shorthand for the subnet mask. A /24 prefix means 24 ones followed by 8 zeros in binary, which translates to 255.255.255.0.

  2. Network Address: This is the very first address in the range and is used to identify the network itself. It's calculated by performing a bitwise AND operation between the IP address and the subnet mask. In the network address, all host bits are 0.

  3. Broadcast Address: This is the very last address in the range. Packets sent to this address are delivered to all devices on the network. In the broadcast address, all host bits are 1.

  4. Usable Host Range: These are the IP addresses that can be assigned to devices. It's the range between the network address and the broadcast address. The first address is Network Address + 1, and the last is Broadcast Address - 1.


Prefix Length and Network Size

The CIDR prefix directly controls the size of a network. A smaller prefix number means fewer network bits and more host bits, resulting in a larger network. A larger prefix number means more network bits and fewer host bits, creating a smaller network.

This interactive chart shows the relationship between the CIDR prefix and the number of available IP addresses for hosts.

By replacing the rigid classful system, CIDR allows for finely tuned allocation of IP addresses, which minimizes waste and improves the efficiency of routing on the internet. It's a fundamental concept that makes today's complex and massive networks possible.

Sign in to ask follow ups

Sign In to continue