CIDR Notation Explained - Classless Inter-Domain Routing Guide

Understand CIDR notation for IP addressing. Learn how Classless Inter-Domain Routing (CIDR) defines network and host portions with prefixes, enabling efficient IP address allocation.

CIDR Notation Explained

Understanding Classless Inter-Domain Routing (CIDR)

Classless Inter-Domain Routing (CIDR) is a method for allocating IP addresses and routing IP packets. It was introduced to replace the older classful addressing scheme. CIDR allows for more flexible and efficient allocation of IP addresses by using a variable-length prefix to denote the network portion of an IP address.

How CIDR Works: Network and Host Portions

An IP address is a 32-bit number. In CIDR, this 32-bit address is divided into two parts: the network portion and the host portion. The division is determined by a prefix length, indicated by a slash followed by a number (e.g., /24). This number represents the number of bits dedicated to the network portion.

For example, a /16 network prefix means that the first 16 bits of the IP address identify the network, and the remaining 16 bits identify the host within that network.

# Example of a /16 network prefix
# Network bits / Host bits
11111111 11111111 / 00000000 00000000

Subnetting with CIDR Prefixes

CIDR enables subnetting, which is the process of dividing a larger network into smaller subnetworks. The prefix length determines the size of the subnet. A shorter prefix indicates a larger network with more host addresses, while a longer prefix indicates a smaller network with fewer host addresses.

Consider an IP address on the 3.3.3.0 network. If we want to create a subnet with only two usable IP addresses, we would use a /31 prefix.

In binary, the network portion for a /31 prefix would look like this:

# The 32 bit string below represents a /31 network since 31 bits are dedicated to the network portion of the address
# Network bits / Host bits
11111111.11111111.11111111.11111110 / 0

The corresponding subnet mask for a /31 prefix is 255.255.255.254. With only one bit available for the host portion, the only two usable IP addresses in this subnet would be 3.3.3.0 and 3.3.3.1. The IP address 3.3.3.2 would then mark the beginning of the next subnet.

CIDR Prefix Lengths and Address Ranges

The prefix length directly impacts the number of available IP addresses within a network or subnet.

  • A /31 prefix allows for 2 IP addresses (e.g., 3.3.3.0 - 3.3.3.1).
  • A /30 prefix allows for 4 IP addresses (e.g., 3.3.3.0 - 3.3.3.3).
  • A /24 prefix (common for Class C networks) allows for 256 IP addresses (e.g., 192.168.1.0 - 192.168.1.255).
  • A /16 prefix (common for Class B networks) allows for 65,536 IP addresses.
  • A /8 prefix (common for Class A networks) allows for 16,777,216 IP addresses.

Benefits of CIDR

CIDR offers several advantages over classful addressing:

  • Efficient IP Address Utilization: Reduces IP address wastage by allowing networks to be sized precisely as needed.
  • Improved Routing Efficiency: Enables route aggregation, where multiple smaller networks can be represented by a single, larger route, reducing the size of routing tables.
  • Flexibility: Adapts to the diverse needs of networks, from small home networks to large enterprise networks.

External Resources