CIDR (Classless Inter-Domain Routing) is a method for allocating IP addresses and routing Internet Protocol packets. It offers a more compact and efficient way to represent a subnet mask, replacing the older classful network design. Understanding CIDR is essential for modern network administration.
The CIDR Format
You will often see networks notated using the CIDR format, where an IP address is followed by a slash and a number. For example, a subnet like 10.42.3.0 with a subnet mask of 255.255.255.0 is written as 10.42.3.0/24. This single notation includes both the network address and the prefix length.
The number after the slash indicates how many bits of the IP address are used for the network prefix. This is a common task when configuring networking on a system like an Ubuntu server, where you might define an interface with an ubuntu subnet cidr address.
CIDR Subnetting and Host Calculation
An IPv4 address consists of 4 bytes, which is a total of 32 bits. The CIDR prefix determines the split between the network portion and the host portion of the address. For effective cidr subnetting, you need to know how to calculate the number of available hosts.
Let's take the example 123.12.24.0/23. This means the first 23 bits are the network prefix. To find the number of available hosts:
- Subtract the CIDR prefix from the total number of bits (32):
32 - 23 = 9. This leaves 9 bits for the host portion. - Calculate the total number of addresses in the subnet:
2^9 = 512. - Subtract 2 from the total. One address is reserved for the network itself, and one is for the broadcast address. This leaves
512 - 2 = 510usable host addresses.
Another common example is a /30 network, which provides 32 - 30 = 2 host bits. This results in 2^2 = 4 total addresses, leaving just 2 usable addresses, making it ideal for point-to-point links.