2022-05-12

CIDR Notation

What is CIDR Notation

Classless Inter-Domain Routing (CIDR) notation is a method for representing IP addresses and their associated routing prefix. It's an essential component of modern networking, playing a crucial role in the allocation and management of IP addresses.

In the early days of the Internet, IP addresses were distributed in classes (Class A, B, and C). This method, however, proved inefficient as the Internet grew, leading to the rapid exhaustion of available addresses. To tackle this problem, CIDR was introduced in 1993 as a new IP addressing scheme to enhance the allocation efficiency of IP addresses and facilitate advanced routing capabilities.

The term "classless" in CIDR indicates that IP addresses are not strictly divided into classes (as in classful network design), allowing for a more flexible distribution of IP addresses. CIDR is a more adaptable system that can more accurately meet the needs of an organization's network size and configuration. This reduces wasted IP addresses, conserving the overall pool of available addresses.

CIDR Notation Format

In CIDR notation, an IP address is written as four octets, followed by a slash (/), and then a decimal number. The four-octet IP address represents the network address, and the number after the slash indicates the subnet prefix.

The subnet prefix, or the prefix length, denotes the number of bits utilized to represent the network portion of the IP address. This prefix directly corresponds to the subnet mask, a binary number that distinguishes the network and host portions of the IP address. The remaining bits after the prefix are used to represent the hosts or devices within the network.

Let's consider an example to illustrate this concept. In the CIDR notation 192.168.0.0/24, the IP address is 192.168.0.0 and the subnet prefix is 24. This means that the first 24 bits of the IP address are used for network identification, and the remaining 8 bits are used for identifying specific hosts within that network.

CIDR and Subnet Masks

A subnet mask is an integral part of CIDR notation and plays a vital role in IP networking. The subnet mask is a 32-bit number that masks an IP address and divides the IP address into network address and host address. In simple terms, it's used to identify the size of the network and the number of possible hosts within that network.

In the binary form, the subnet mask is a sequence of ones (1) followed by a sequence of zeros (0). The ones cover the network portion of the IP address, while the zeros cover the host portion.

When you see a CIDR notation like 192.168.1.0/24, the /24 is equivalent to the subnet mask 255.255.255.0 in decimal form. Here, 24 represents the number of ones in the subnet mask, indicating that the first 24 bits of the IP address are the network part. The remaining 8 bits (32 total bits minus 24 network bits) are used for different host addresses within that network. This means the network can have 2^8 (256) different addresses, including the network address and the broadcast address.

CIDR and subnet masks are closely related because the number following the slash in CIDR notation is the subnet mask. By using CIDR notation, we can easily determine the subnet mask and thereby understand the network's structure.

CIDR Notation Examples

Here are a few examples.

CIDR Notation Network Address Subnet Prefix Subnet Mask (Decimal)
192.168.1.0/24 192.168.1.0 24 255.255.255.0
10.0.0.0/16 10.0.0.0 16 255.255.0.0
172.16.0.0/12 172.16.0.0 12 255.240.0.0
  • In CIDR notation 192.168.1.0/24, the network part of the IP address uses the first 24 bits, leaving 8 bits for host addresses. This allows for up to 256 (2^8) unique addresses.
  • In CIDR notation 10.0.0.0/16, the network part uses the first 16 bits, leaving 16 bits for host addresses. This allows for up to 65,536 (2^{16}) unique addresses.
  • In CIDR notation 172.16.0.0/12, the network part uses the first 12 bits, leaving 20 bits for host addresses. This allows for up to 1,048,576 (2^{20}) unique addresses.

IP Addresses

An Internet Protocol (IP) address is a unique identifier assigned to each device connected to a computer network that uses the Internet Protocol for communication. There are two versions of IP addresses in use: IPv4 and IPv6. IPv4 addresses are most common and are written in decimal format, divided into four octets and separated by periods, e.g., 192.168.0.1. IPv6 addresses, on the other hand, are written in hexadecimal and separated by colons, e.g., 2001:0db8:85a3::8a2e:0370:7334.

CIDR and IP Version 6 (IPv6)

IPv6 is the most recent version of the Internet Protocol. While IPv4 addresses are 32 bits, allowing for over 4 billion unique addresses, IPv6 addresses are 128 bits long. This provides for a virtually unlimited number of unique addresses, sufficient for many decades to come, even considering the rapid growth of Internet-connected devices.

CIDR notation is just as relevant in IPv6 as it was in IPv4. Just like in IPv4, the CIDR notation for IPv6 comprises an IP address, a slash, and a prefix length. The key difference lies in the address and prefix length: IPv6 addresses are expressed in hexadecimal and separated by colons, and the prefix length can be up to 128.

An example of an IPv6 address in CIDR notation could be 2001:0db8:85a3::/64. Here, 2001:0db8:85a3:: is the IPv6 address, and 64 is the prefix length. The prefix length of 64 indicates that the first 64 bits of the address are used for the network part, leaving the remaining 64 bits for identifying unique hosts within the network.

References

https://whatismyipaddress.com/cidr
https://aws.amazon.com/what-is/cidr/
https://www.digitalocean.com/community/tutorials/understanding-ip-addresses-subnets-and-cidr-notation-for-networking
https://www.hava.io/blog/what-is-cidr-notation

Ryusei Kakujo

researchgatelinkedingithub

Focusing on data science for mobility

Bench Press 100kg!