Subnetting is the practice of dividing a network into smaller networks (subnets). CIDR (Classless Inter-Domain Routing) notation is the modern way to express subnet sizes. Understanding both is essential for network design and troubleshooting.
CIDR Notation
CIDR notation expresses an IP address and its subnet mask in one compact format:
192.168.1.0/24
└────┬────┘ └┬┘
IP address Prefix length (bits for network)
The number after the slash indicates how many bits of the address identify the network. The remaining bits identify individual hosts.
Understanding the Prefix
/24 = 24 bits for network, 8 bits for hosts
= 256 total addresses, 254 usable hosts
/16 = 16 bits for network, 16 bits for hosts
= 65,536 total addresses, 65,534 usable hosts
/8 = 8 bits for network, 24 bits for hosts
= 16,777,216 total addresses
Subnet Masks
A subnet mask is a 32-bit number that separates the network portion from the host portion of an IP address.
CIDR to Subnet Mask Conversion
| CIDR | Subnet Mask | Usable Hosts |
|---|---|---|
| /8 | 255.0.0.0 | 16,777,214 |
| /16 | 255.255.0.0 | 65,534 |
| /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 |
| /32 | 255.255.255.255 | 1 (single host) |
Two addresses are reserved in every subnet: the network address (first) and broadcast address (last). For example, in 192.168.1.0/24, you cannot assign .0 (network) or .255 (broadcast) to hosts.
Calculating Subnets
Key Formulas
# Total addresses in a subnet
2^(32 - prefix) = total addresses
# Usable hosts
2^(32 - prefix) - 2 = usable hosts
# Examples:
/24: 2^(32-24) = 2^8 = 256 total, 254 usable
/27: 2^(32-27) = 2^5 = 32 total, 30 usable
/30: 2^(32-30) = 2^2 = 4 total, 2 usable
Finding Network Boundaries
Given an IP and prefix, find the network address and broadcast address:
Example: 192.168.1.67/26
Step 1: /26 means 64 addresses per subnet (2^6 = 64)
Step 2: Find which block of 64 contains .67
Block 1: .0 - .63
Block 2: .64 - .127 ← .67 is here
Block 3: .128 - .191
Block 4: .192 - .255
Step 3: Results
Network: 192.168.1.64
Broadcast: 192.168.1.127
Usable: 192.168.1.65 - 192.168.1.126
Common Subnet Sizes
| CIDR | Hosts | Common Use |
|---|---|---|
| /30 | 2 | Point-to-point links between routers |
| /29 | 6 | Very small office, ISP allocations |
| /28 | 14 | Small department |
| /27 | 30 | Small office |
| /26 | 62 | Medium department |
| /25 | 126 | Large department |
| /24 | 254 | Most common for LANs |
| /16 | 65,534 | Large enterprise |
Practical Examples
Example 1: Home Network
Network: 192.168.1.0/24
Router: 192.168.1.1
DHCP range: 192.168.1.100 - 192.168.1.200
Reserved: 192.168.1.2 - 192.168.1.99 (servers, printers)
Example 2: Dividing a /24 into Four /26 Subnets
Original: 10.0.0.0/24 (254 hosts)
Divided into four /26 subnets (62 hosts each):
Subnet 1: 10.0.0.0/26 (10.0.0.1 - 10.0.0.62)
Subnet 2: 10.0.0.64/26 (10.0.0.65 - 10.0.0.126)
Subnet 3: 10.0.0.128/26 (10.0.0.129 - 10.0.0.190)
Subnet 4: 10.0.0.192/26 (10.0.0.193 - 10.0.0.254)
Example 3: Point-to-Point Link
Link between Router A and Router B:
Network: 10.255.255.0/30
Router A: 10.255.255.1
Router B: 10.255.255.2
Network: 10.255.255.0 (unusable)
Broadcast: 10.255.255.3 (unusable)
When designing a network, always plan for growth. If you need 50 hosts now, use a /26 (62 hosts) rather than a /27 (30 hosts) to allow room for expansion.