CIDR (Classless Inter-Domain Routing) – CIDR notation is a compact representation of an IP address and its associated network mask. This helps us define IP ranges.
What is an IP Address?
An IPv4 address is a 32-bit numerical identifier assigned to each device participating in a computer network that uses the IPv4 protocol for communication. IPv4 addresses are typically represented as four decimal numbers separated by periods, e.g., 192.168.0.1.
What is a Subnet Mask?
A subnet mask is a 32-bit number that is used to divide an IP address into two parts: the network address and the host address. The network address identifies the network to which the device belongs, and the host address identifies the specific device on the network.
The network bits are set to 1, and the host bits are set to 0. For example, a subnet mask for a Class C network could be 255.255.255.0.
Subnet masks are used to subnet networks, which is the process of dividing a large network into smaller, more manageable networks.
Subnet masks are typically represented in dotted decimal notation, similar to IP addresses. For example, the subnet mask 255.255.255.0 would divide an IP address into the following two parts:
Network address: 192.168.1.0
Host address: 192.168.1.1 – 192.168.1.255
This subnet mask would create a network with 256 possible host addresses.
The subnet mask basically allows part of the underlying IP to get additional next values from the base IP.
Example:
192.168.0.0/32 = give only 1 IP = 2^0 = 192.168.0.0
192.168.0.0/31 = give only 2 IPs = 2^1 = 192.168.0.0 – 192.168.0.1
192.168.0.0/30 = give only 4 IPs = 2^2 = 192.168.0.0 – 192.168.0.3
192.168.0.0/29 = give only 8 IPs = 2^3 = 192.168.0.0 – 192.168.0.7
…
192.168.0.0/24 = give only 8 IP = 2^8 = 192.168.0.0 – 192.168.0.255
The simple math to know which power of 2 for submask will be 32 – submask
Example submask 16
Will be 32 – 16 = 16
2^16 = 65,536
192.168.0.0/16 = give only 65,536 IPs = 2^16 = 192.168.0.0 – 192.168.255.255
192.168.0.0/0 = allows all IPs = 0.0.0.0 = 255.255.255.255
Use https://www.ipaddressguide.com/cidr to calculate your ips ranges.
Conclusion
CIDR notation is a compact, efficient way to represent IP addresses and their associated network masks. It’s an essential concept for anyone working in networking, DevOps, or cloud computing. With a bit of practice, interpreting and using CIDR notation will become second nature.
Hope this helps you get started on your journey to understanding CIDR notation in IPv4!