Subnetting is one of the most important yet confusing topics in computer networking. For beginners, subnetting often feels difficult because it involves IP addresses, subnet masks, and calculations. However, once you understand the logic step by step, subnetting becomes simple and predictable.
This guide explains subnetting basics, subnet masks, CIDR, and IP subnetting calculations in a clear and structured way. It is ideal for beginners and for network engineer interview preparation.
What Is Subnetting?
Subnetting is the process of dividing a large network into smaller logical networks called subnets. Each subnet works as an independent network while still being part of a larger network.
In simple terms, subnetting helps organize IP addresses efficiently and allows better control over network traffic.
Why Subnetting Is Important
Subnetting is essential for modern network design and management.
It helps to:
- Reduce network congestion
- Improve performance
- Increase security through isolation
- Use IP addresses efficiently
- Simplify troubleshooting and management
Without subnetting, large networks become slow, insecure, and difficult to manage.
Key Concepts You Must Know Before Subnetting
Before performing subnet calculations, it is important to understand a few basic networking terms.
IP Address
An IP address uniquely identifies a device on a network, such as 192.168.1.10.
Subnet Mask
A subnet mask defines which part of the IP address represents the network and which part represents hosts.
Example:
255.255.255.0
Network ID
The first address in a subnet that identifies the network itself.
Broadcast Address
The last address in a subnet, used to communicate with all devices in that subnet.
Host Addresses
The usable IP addresses assigned to devices within the subnet.
Understanding Subnet Masks
A subnet mask works by masking the network portion of an IP address.
Common Subnet Masks
- 255.0.0.0 → Class A
- 255.255.0.0 → Class B
- 255.255.255.0 → Class C
The subnet mask directly affects how many hosts and subnets are available.
What Is CIDR?
CIDR (Classless Inter-Domain Routing) is a modern IP addressing method that replaces class-based subnetting. It allows flexible subnet sizes and better IP utilization.
Example:
192.168.1.0/24
Here, /24 means the first 24 bits are used for the network, and the remaining bits are used for hosts.
Subnetting Basics Explained Step by Step
Now let’s break subnetting into simple, beginner-friendly steps.
Step 1: Identify the Given IP Address and Subnet Mask
The first step is to identify the IP address and subnet mask.
Example:
IP Address: 192.168.1.0
Subnet Mask: 255.255.255.0 or /24
This tells us we are working with a Class C–type network, where 24 bits represent the network portion.
Step 2: Determine the Number of Subnets or Hosts Needed
Subnetting problems usually ask one of the following:
- How many subnets are required
- How many hosts are required per subnet
This requirement helps decide how many bits must be borrowed from the host portion.
Step 3: Borrow Bits from the Host Portion
Each borrowed bit doubles the number of subnets.
Example:
- Borrow 1 bit → 2 subnets
- Borrow 2 bits → 4 subnets
- Borrow 3 bits → 8 subnets
This step is critical in subnet calculation.
Step 4: Calculate the New Subnet Mask
Borrowing bits increases the subnet mask value.
Example:
- Original subnet: /24
- Borrow 2 bits → /26
New subnet mask:
255.255.255.192
This new mask defines the size of each subnet.
Step 5: Calculate the Number of Hosts per Subnet
Use the formula:
Hosts = 2ⁿ − 2
Where n is the number of remaining host bits.
Example:
- /26 leaves 6 host bits
- Hosts = 2⁶ − 2 = 62 usable hosts
Two addresses are reserved for the network ID and broadcast address.
Step 6: Identify Subnet Ranges
Subnet ranges are calculated using the block size.
Block size formula:
256 − subnet mask value
Example:
256 − 192 = 64
Subnet ranges:
- 192.168.1.0 – 192.168.1.63
- 192.168.1.64 – 192.168.1.127
- 192.168.1.128 – 192.168.1.191
- 192.168.1.192 – 192.168.1.255
Each range represents one subnet.
Subnetting Example Explained
Let’s look at a complete subnetting example.
Given:
IP Address: 192.168.10.0/26
Results:
- Number of subnets: 4
- Hosts per subnet: 62
Subnet Breakdown:
- Network ID: 192.168.10.0
- First usable host: 192.168.10.1
- Last usable host: 192.168.10.62
- Broadcast address: 192.168.10.63
The same pattern repeats for each subnet.
Common Subnetting Mistakes Beginners Make
Some common mistakes include:
- Forgetting to subtract network and broadcast addresses
- Miscalculating block size
- Confusing CIDR notation with subnet mask
- Relying only on class-based thinking
Regular practice helps avoid these errors.
Subnetting in Real-World Networks
Subnetting is widely used in practical environments such as:
- Office and enterprise networks
- VLAN-based network designs
- Cloud VPC and subnet planning
- Firewall and VPN configurations
- High availability and load-balanced systems
Subnetting improves both performance and security.
Subnetting Interview Questions
Interviewers frequently test subnetting concepts.
Common questions include:
- How many hosts are available in a /27 network?
- What is the subnet mask for /23?
- How many subnets are created by borrowing 3 bits?
- Find the broadcast address for a given subnet
Clear step-by-step logic matters more than memorization.
Conclusion
Subnetting may seem difficult at first, but when broken down step by step, it becomes logical and easy to understand. By learning subnet masks, CIDR notation, and basic calculations, beginners can confidently design and troubleshoot networks. Subnetting is a foundational networking skill and a must-know topic for interviews, enterprise networking, and cloud infrastructure.