Subnet Masks and CIDR: Complete IP Subnetting Guide
Master network subnetting and CIDR notation. Learn how subnet masks divide networks, calculate IP ranges, understand CIDR notation, and design efficient network architectures. Essential for understanding IP addressing and managing network infrastructure.
What is a Subnet Mask?
A subnet mask is a 32-bit number that divides an IP address into network and host portions. It determines which part of the IP address identifies the network and which part identifies the specific device on that network.
IP Address + Subnet Mask Breakdown
Binary Representation
Common Subnet Masks
CIDR Notation Explained
Classless Inter-Domain Routing (CIDR) is a compact way to specify IP addresses and their subnet masks. Instead of writing "255.255.255.0", you write "/24" - the number of network bits.
CIDR Notation Format
CIDR Quick Reference Table
| CIDR | Subnet Mask | Usable Hosts | Total IPs |
|---|---|---|---|
| /30 | 255.255.255.252 | 2 | 4 |
| /29 | 255.255.255.248 | 6 | 8 |
| /28 | 255.255.255.240 | 14 | 16 |
| /27 | 255.255.255.224 | 30 | 32 |
| /26 | 255.255.255.192 | 62 | 64 |
| /25 | 255.255.255.128 | 126 | 128 |
| /24 | 255.255.255.0 | 254 | 256 |
| /16 | 255.255.0.0 | 65,534 | 65,536 |
| /8 | 255.0.0.0 | 16,777,214 | 16,777,216 |
Calculating Subnet Ranges
Understanding how to calculate network address, broadcast address, and usable host range is essential for subnet planning.
Example: 192.168.10.0/24
Key Addresses Explained
Subnetting Examples
Example 1: Dividing a /24 Network
You have 192.168.1.0/24 and need to create 4 smaller subnets. Each subnet needs at least 50 hosts.
Example 2: Point-to-Point Links
Connecting two routers directly only needs 2 IP addresses. Use /30 to minimize waste.
Example 3: VLSM (Variable Length Subnet Masking)
Different departments need different numbers of IPs. Use different subnet sizes efficiently.
Private IP Address Ranges
RFC 1918 defines private IP ranges that can be used internally without coordination with IANA. These are never routed on the public internet.
Subnet Planning Best Practices
1. Plan for Growth
Always allocate more IPs than currently needed. A network that needs 20 devices today might need 50 tomorrow. Use /26 (62 hosts) instead of /27 (30 hosts).
2. Use Hierarchical Addressing
Organize subnets logically by location, department, or function. Makes management and troubleshooting easier.
3. Document Everything
- •Maintain a subnet allocation spreadsheet or IPAM tool
- •Record subnet purpose, VLAN ID, and gateway address
- •Note date created and who requested it
- •Track IP assignments within each subnet
4. Avoid Overlap
Never create overlapping subnets. Use a subnet calculator to ensure no conflicts. Overlapping subnets cause routing failures and connectivity issues.
5. Reserve Ranges for Special Use
- •.1: Typically the gateway/router
- •.2-.10: Network infrastructure (switches, APs)
- •.11-.99: Static assignments (servers, printers)
- •.100-.254: DHCP pool for workstations
Supernetting (Route Aggregation)
Supernetting is the opposite of subnetting - combining multiple networks into a single, larger network. Used to reduce routing table size and simplify network management.
Supernetting Example
Benefits
- ✓Smaller routing tables
- ✓Faster routing lookups
- ✓Reduced router memory usage
- ✓Less BGP update traffic
Requirements
- •Networks must be contiguous
- •Must be powers of 2
- •Requires CIDR support
- •Careful planning needed
Common Subnetting Mistakes
Forgetting Network and Broadcast Addresses
A /24 network has 256 IPs, but only 254 are usable. Always subtract 2 for network and broadcast addresses.
Not Planning for Growth
Using a /29 (6 hosts) for a department with 5 devices leaves no room for expansion. Plan ahead!
Creating Overlapping Subnets
Ensure new subnets don't overlap existing ones. Use a subnet calculator or IP address management tool.
Wrong Subnet Mask on Devices
If devices have incorrect subnet masks, they won't know which IPs are local vs remote, causing routing issues.
Subnetting Calculation Tips
Quick Formulas
Binary Conversion Shortcuts
| Bit Position | Decimal Value |
|---|---|
| 1st bit | 128 |
| 2nd bit | 64 |
| 3rd bit | 32 |
| 4th bit | 16 |
| 5th bit | 8 |
| 6th bit | 4 |
| 7th bit | 2 |
| 8th bit | 1 |
Last octet: 128 + 64 = 192 (first 2 bits on)