Before diving into CIDR notation and subnet masks, you must understand IP addressing. There are two main versions of IP addresses:
IPv4 (32-bit address)
IPv6 (128-bit address)
For this lesson, we will focus on IPv4.
An IPv4 address consists of 4 octets (32 bits) and is typically written in dotted decimal notation, like this:
192.168.1.1
Each octet (separated by dots) represents 8 bits.
2. What is a Subnet Mask?
A subnet mask defines which portion of an IP address belongs to the networkand which portion belongs to hosts (devices).
It follows the same 32-bit format as an IPv4 address and typically looks like this:
255.255.255.0
In binary, the subnet mask for 255.255.255.0 is:
11111111.11111111.11111111.00000000
The 1s represent the network portion.
The 0s represent the host portion.
Example 1: IP Address and Subnet Mask Pairing
IP Address: 192.168.1.10
Subnet Mask: 255.255.255.0
This means the first three octets (192.168.1) define the network.
The last octet (10) represents the host.
3. What is CIDR Notation?
CIDR (Classless Inter-Domain Routing) notation is a shorthand method to represent an IP address with its subnet mask.
Instead of writing:
We use CIDR notation:
How Does CIDR Work?
The number /24 represents the number of 1s in the subnet mask.
/24 means 24 bits are reserved for the network and the remaining 8 bits are for hosts.
CIDR
Subnet Mask
Network Bits
Host Bits
Total Hosts
/8
255.0.0.0
8
24
16,777,214
/16
255.255.0.0
16
16
65,534
/24
255.255.255.0
24
8
254
/30
255.255.255.252
30
2
2
Formula to calculate total usable hosts:
2H−2
Where H is the number of host bits.
Example for /24, usable hosts are calculate as:
28−2=254
4. Practical Examples: CIDR Subnetting
Example 2: Dividing a Network
You have an IP range: 192.168.1.0/24, and you need to divide it into two subnets.
Original Network:
Divide into Two Subnets:
We need to increase the network bits to split the network.
/25 means 25 bits for the network, leaving 7 bits for hosts.
New Subnets:
Each subnet now has 2^7 - 2 = 126 usable hosts.
Example 3: Smallest Subnet for 5 Devices
If you have 5 devices, you need at least 6 IPs (5 for devices + 1 for the network and broadcast).