As a network grows, putting every device into one large network can become difficult to manage. We may want to divide a large network into smaller, organized networks.
This is where Subnetting comes in.
Subnetting is the process of dividing a larger IP network into smaller logical networks called subnets.
CIDR (Classless Inter-Domain Routing) is a notation and addressing method that allows networks to be represented using a prefix length, such as /24, /26, or /30.
Let's understand both with a simple example.
Why Do We Need Subnetting?
Suppose an organization has a network with hundreds of devices.
Instead of keeping everything in one network:
Main Network
├── PC
├── PC
├── Printer
├── Server
├── PC
├── ...
└── Many more devices
We can divide it into smaller networks:
Main Network
│
├── Subnet 1 → HR
├── Subnet 2 → Finance
├── Subnet 3 → IT
└── Subnet 4 → Management
This makes the network easier to organize, manage, and control.
Benefits of Subnetting
Better organization
More efficient use of IP addresses
Smaller broadcast domains in IPv4
Easier network management
Can help with security and traffic control
Understanding an IPv4 Address
An IPv4 address contains 32 bits, divided into four octets.
For example:
192.168.1.10
In binary:
11000000.10101000.00000001.00001010
A subnet mask tells us which bits represent the network portion and which represent the host portion.
For example:
IP Address:
192.168.1.10
Subnet Mask:
255.255.255.0
The subnet mask can also be written using CIDR notation:
192.168.1.10/24
What Does /24 Mean?
The /24 is called the CIDR prefix length.
It means:
The first 24 bits are the network prefix, and the remaining 8 bits are available for the host portion.
An IPv4 address has 32 bits:
Network Prefix Host
<------ 24 ------> <---8--->
So:
/24 → 24 network bits + 8 host bits
The corresponding subnet mask is:
255.255.255.0
Common CIDR Prefixes
Here are some commonly encountered IPv4 prefixes:
CIDR | Subnet Mask | Total Addresses |
|---|---|---|
| 255.0.0.0 | 16,777,216 |
| 255.255.0.0 | 65,536 |
| 255.255.255.0 | 256 |
| 255.255.255.128 | 128 |
| 255.255.255.192 | 64 |
| 255.255.255.224 | 32 |
| 255.255.255.240 | 16 |
| 255.255.255.248 | 8 |
| 255.255.255.252 | 4 |
For traditional IPv4 subnets, some addresses have special purposes, so the number of usable host addresses can be smaller than the total number of addresses.
CIDR Notation
Before CIDR, IPv4 addressing was commonly described using fixed Class A, B, and C network classes.
CIDR removed this restriction by allowing flexible prefix lengths.
For example:
192.168.1.0/24
means:
Network:
192.168.1.0Prefix length:
24Host bits:
8
But we can also have:
192.168.1.0/26
Here:
Network bits:
26Host bits:
6
This gives us a smaller subnet.
Subnetting Example
Let's say we have:
192.168.1.0/24
A /24 network has:
32 - 24 = 8 host bits
Therefore:
2⁸ = 256 total addresses
If we divide this network into /26 subnets, we are using 2 additional bits for the subnet prefix:
/24 → /26
Now there are:
32 - 26 = 6 host bits
So each /26 subnet contains:
2⁶ = 64 total addresses
The original /24 can therefore be divided into 4 /26 subnets:
Subnet | Address Range |
|---|---|
1 | 192.168.1.0 – 192.168.1.63 |
2 | 192.168.1.64 – 192.168.1.127 |
3 | 192.168.1.128 – 192.168.1.191 |
4 | 192.168.1.192 – 192.168.1.255 |
For example, in the first traditional IPv4 subnet:
Network Address: 192.168.1.0
Usable Hosts: 192.168.1.1 – 192.168.1.62
Broadcast Address: 192.168.1.63
So it provides 62 traditional usable host addresses.
Network Address and Broadcast Address
In a typical IPv4 subnet, two addresses have special purposes.
Network Address
The network address identifies the subnet itself.
For:
192.168.1.0/26
the network address is:
192.168.1.0
Broadcast Address
The broadcast address is used to send traffic to all hosts on the IPv4 subnet.
For the same subnet:
192.168.1.63
is the broadcast address.
Therefore:
192.168.1.0/26
Network → 192.168.1.0
Host Range → 192.168.1.1 – 192.168.1.62
Broadcast → 192.168.1.63
How to Calculate Hosts
For a normal IPv4 subnet, the number of host bits is:
Host bits = 32 − Prefix Length
The total number of addresses is:
2^(Host bits)
For example, /26:
Host bits = 32 - 26
= 6
Therefore:
Total addresses = 2⁶
= 64
Traditionally, 2 addresses are reserved for the network and broadcast addresses:
Usable hosts = 64 - 2
= 62
There are special cases such as
/31point-to-point networks and/32host routes where this traditional-2rule does not apply.
CIDR and Routing
CIDR is not only useful for subnetting. It is also important in routing.
For example:
10.0.0.0/8
represents a large address block.
A more specific network could be:
10.1.0.0/16
Routers use prefixes to determine which destinations belong to which networks.
CIDR also allows route aggregation, where multiple networks can sometimes be represented by a single larger prefix. This helps keep routing tables more manageable.
Subnetting vs CIDR
These terms are closely related, but they are not exactly the same.
Subnetting | CIDR |
|---|---|
Divides a network into smaller networks | Uses flexible prefix lengths |
Focuses on network organization | Used for addressing and routing |
Can create | Represents networks using |
Helps manage IP address space | Also enables route aggregation |
A simple way to remember it:
Subnetting = Divide a network
CIDR = Describe networks using flexible prefixes
Conclusion
Subnetting is the process of dividing a larger IP network into smaller networks, while CIDR provides a flexible way to represent IP networks using prefix lengths such as /24, /26, or /30.
The most important formulas to remember for IPv4 are:
Host bits = 32 − Prefix Length
Total addresses = 2^(Host bits)
For a typical subnet:
Usable hosts = Total addresses − 2
Once you understand these basics, you can move on to more advanced subnetting problems, including VLSM, subnet calculations, and route aggregation.