CIDR Notation & Subnet Masks
Nerd Cafe
1. Understanding IP Addressing and Subnetting
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:
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 network and which portion belongs to hosts (devices). It follows the same 32-bit format as an IPv4 address and typically looks like this:
In binary, the subnet mask for 255.255.255.0
is:
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.
/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:
Where H is the number of host bits.
Example for /24, usable hosts are calculate as:
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).
Find the smallest CIDR block:
/29
gives 2^3 - 2 = 6 usable IPs.Subnet mask:
255.255.255.248
.
Assign the subnet:
Usable IPs:
5. Practical Implementation
Using Linux/macOS Command Line
Find your subnet mask and CIDR:
or
Using Windows Command Line
Look for Subnet Mask and IP Address
Keywords
CIDR notation
, subnet mask
, IPv4 addressing
, network bits
, host bits
, subnetting
, IP address classes
, VLSM
, subnet calculation
, IP range
, prefix length
, network portion
, host portion
, broadcast address
, default subnet masks
, classless addressing
, IP allocation
, routing
, supernetting
, binary notation
, نتورک پلاس
Last updated