Subnetting — Dividing Networks into Smaller, Efficient Networks¶
Subnetting is the process of dividing a large IP network into multiple smaller, manageable networks called subnets. It improves network performance, enhances security, simplifies management, and optimises IP address utilisation. Subnetting is one of the most important skills in networking and is frequently tested in networking certifications and technical interviews. Every Linux administrator, DevOps engineer, Cloud Architect, Platform Engineer, Site Reliability Engineer (SRE), and Network Engineer should master subnetting.
Learning Path¶
Course Progress
What You'll Learn¶
After completing this lesson, you'll be able to:
- Understand what subnetting is
- Explain why subnetting is required
- Divide networks into smaller subnets
- Calculate network, broadcast, and host addresses
- Determine the number of hosts and subnets
- Perform manual subnetting calculations
- Design enterprise subnetting schemes
Prerequisites¶
Complete:
Why Learn Subnetting?¶
Suppose an organisation has:
This network supports:
But the company has three departments:
- HR
- Finance
- Engineering
Should all 254 hosts be in the same network?
Instead, we divide the network into smaller subnetworks.
This process is called Subnetting.
What is Subnetting?¶
Subnetting is the process of dividing a larger network into multiple smaller networks.
Example:
Before:
After:
One large network becomes four smaller networks.
Why Do We Need Subnetting?¶
Subnetting provides several benefits:
- Better IP address utilisation
- Reduced broadcast traffic
- Improved security
- Easier network management
- Better performance
- Simplified troubleshooting
- Logical separation of departments
Real-World Example¶
An office contains:
- HR
- Finance
- Engineering
- Management
Instead of placing everyone in one network:
Create separate subnets:
Each department has its own subnet.
Important Terms¶
Before learning subnetting, understand these terms:
- Network Address
- Broadcast Address
- Host Address
- Subnet Mask
- Prefix Length
Network Address¶
The first address in every subnet.
Example:
Network Address:
It identifies the subnet and cannot be assigned to a host.
Broadcast Address¶
The last address in every subnet.
Example:
Broadcast:
Packets sent to this address reach all hosts within the subnet.
Host Addresses¶
The addresses between the network and broadcast addresses.
Example:
Usable Hosts:
Broadcast:
How Subnetting Works¶
Subnetting borrows bits from the host portion of an IP address.
Original:
Network Bits:
Host Bits:
Borrow 2 bits:
Now:
Host Bits
Number of Subnets¶
Formula:
Borrow:
Calculation:
Number of Hosts¶
Formula:
Host Bits:
Calculation:
Subnetting Example¶
Original Network:
Borrow:
Result:
Subnet 1¶
Hosts:
Broadcast:
Subnet 2¶
Hosts:
Broadcast:
Subnet 3¶
Hosts:
Broadcast:
Subnet 4¶
Hosts:
Broadcast:
Subnet Increment¶
The increment is calculated as:
Example:
Calculation:
Subnet increments:
Common CIDR Values¶
| CIDR | Mask | Hosts |
|---|---|---|
| /24 | 255.255.255.0 | 254 |
| /25 | 255.255.255.128 | 126 |
| /26 | 255.255.255.192 | 62 |
| /27 | 255.255.255.224 | 30 |
| /28 | 255.255.255.240 | 14 |
| /29 | 255.255.255.248 | 6 |
| /30 | 255.255.255.252 | 2 |
Manual Subnetting Steps¶
Given:
Step 1:
Determine subnet mask:
Step 2:
Calculate increment:
Step 3:
Network addresses:
Each network supports:
Enterprise Example¶
Company:
Subnets:
Each department receives an appropriately sized subnet.
Cloud Perspective¶
Cloud providers require subnetting when designing networks.
Example:
VPC:
Subnets:
Kubernetes Perspective¶
Kubernetes clusters divide large Classless Inter-Domain Routing (CIDR) blocks into smaller node-level subnets.
Example:
Cluster:
Node 1:
Node 2:
Each node manages its own Pod IP range.
Linux Perspective¶
Display IP addresses and subnet prefixes.
Example:
Display routing information.
Hands-on Lab¶
Task 1¶
Determine the subnet mask for:
Task 2¶
Subnet:
into:
Write:
- Network Address
- First Host
- Last Host
- Broadcast Address
Task 3¶
Calculate the usable hosts for:
Task 4¶
Calculate the increment for:
Task 5¶
Design subnetworks for:
- HR (40 Hosts)
- Finance (25 Hosts)
- Engineering (100 Hosts)
- Servers (10 Hosts)
Task 6¶
Use:
Identify the CIDR notation of your Linux interface.
Task 7¶
Draw a network diagram showing four departments connected through a router, each using its own subnet.
Task 8¶
Given:
Divide it into 8 equal subnets and list:
- Network Address
- First Host
- Last Host
- Broadcast Address
Linux Commands¶
| Command | Purpose |
|---|---|
ip addr | Display IP address and prefix |
ip route | Display routing table |
hostname -I | Display assigned IP address |
ping | Test connectivity |
Common Mistakes¶
❌ Assigning the network address to a host.
✅ Reserve the first address for the network.
❌ Assigning the broadcast address to a host.
✅ Reserve the last address for broadcasts.
❌ Forgetting the subnet increment.
✅ Always calculate the block size first.
❌ Using oversized subnets.
✅ Choose subnet sizes based on actual host requirements.
❌ Overlapping subnet ranges.
✅ Ensure every subnet has a unique address range.
Best Practices¶
- Allocate subnets based on current and future requirements.
- Reserve space for network growth.
- Document all subnet allocations.
- Avoid overlapping networks.
- Separate departments using dedicated subnets.
- Use private address ranges for internal networks.
Interview Questions¶
Beginner¶
- What is subnetting?
- Why is subnetting required?
- What is a network address?
- What is a broadcast address?
Intermediate¶
- How do you calculate the number of hosts in a subnet?
- Explain how subnet increments are determined.
- Divide a
/24network into four equal subnets. - Why does subnetting reduce broadcast traffic?
Architect Level¶
- Design a subnetting plan for a company with multiple departments.
- Explain subnetting strategies for cloud VPCs.
- How would you subnet a Kubernetes cluster network?
Summary¶
In this lesson, you learned:
- What subnetting is
- Why subnetting is important
- Network, broadcast, and host addresses
- Borrowing host bits
- Subnet calculations
- Subnet increments
- Enterprise, cloud, and Kubernetes subnet design
Subnetting is one of the most valuable networking skills. It enables efficient IP address allocation, improves performance by reducing broadcast domains, enhances security through network segmentation, and forms the basis of enterprise, cloud, and Kubernetes network design.
Key Takeaways¶
- Subnetting divides a large network into smaller subnetworks.
- Borrowing host bits creates additional subnets.
- Every subnet has a network address and a broadcast address.
- Usable hosts are calculated using 2^(Host Bits) − 2.
- Proper subnetting improves scalability, security, and network efficiency.