Cidr / - 1 bits in subnet mask Magic number(increments) = 256 - last interesting octet in mask S = Subnet bits. Example 255.255.192.0 = 1.1.1100000.0, so S = 2 squared H = power of 2, then subtract 2(broadcast and network) = Host bits. So 255.255.192.0 = 14 to the power of 2 - 2 = 16382
CIDR: To quickly find cidr if subnet mask known, count 1’s in subnet mask. So 255.255.192 = 18 = 11111111.11111111.11000000.0000000
1 1 1 1 1 1 1 1 128 64 32 16 8 4 2 1
Subnetting
Core Concepts
- Subnetting allows network administrators to divide a single network into multiple smaller networks (subnets) for better organization, security, and efficient IP address utilization
- Key principle: Borrowing bits from the host portion to create additional network segments
- CIDR (Classless Inter-Domain Routing) notation expresses network prefix length as
/xwhere x = number of consecutive 1 bits in subnet mask
CIDR Calculation Methods
Method 1: Counting 1-bits in Subnet Mask
- Count all consecutive 1 bits from left to right in binary subnet mask
- Example:
255.255.192.0=11111111.11111111.11000000.00000000= /18 CIDR
Method 2: Quick Binary Reference
- Each octet position represents powers of 2: 128, 64, 32, 16, 8, 4, 2, 1
- Add values where 1-bits exist to verify subnet mask accuracy
Magic Number Method
- Magic Number = 256 - Last Interesting Octet
- “Interesting octet” = rightmost octet in subnet mask that isn’t 255 or 0
- Magic number determines subnet increment values and network boundaries
- Example:
255.255.192.0→ Magic Number = 256 - 192 = 64 - Networks increment by 64: 0.0, 64.0, 128.0, 192.0
Subnet and Host Calculations
Subnet Bits (S)
- S = number of bits borrowed from host portion for subnetting
- Number of subnets = 2^S
- Example:
/18mask on Class B network borrows 2 bits → 2² = 4 subnets
Host Bits (H)
- H = remaining bits available for host addressing
- Number of hosts per subnet = 2^H - 2
- Subtract 2 for network address and broadcast address (unusable for hosts)
- Example:
/18leaves 14 host bits → 2¹⁴ - 2 = 16,382 hosts per subnet
Vocabulary
| Term | Definition |
|---|---|
| CIDR | Classless Inter-Domain Routing - method for allocating IP addresses using prefix notation |
| Magic Number | Increment value calculated as 256 minus the interesting octet |
| Interesting Octet | Rightmost subnet mask octet that contains both 1s and 0s |
| Network Address | First address in subnet range (all host bits = 0) |
| Broadcast Address | Last address in subnet range (all host bits = 1) |
| Subnet Mask | 32-bit value distinguishing network portion from host portion |
Practical Examples
Example 1: 192.168.1.0/26
- Subnet mask:
255.255.255.192 - Magic number: 256 - 192 = 64
- Subnets: .0, .64, .128, .192
- Hosts per subnet: 2⁶ - 2 = 62 hosts
- Use case: Small office networks requiring isolation between departments
Example 2: 10.0.0.0/22
- Subnet mask:
255.255.252.0 - Magic number: 256 - 252 = 4 (in third octet)
- Networks: 10.0.0.0, 10.0.4.0, 10.0.8.0, 10.0.12.0
- Hosts per subnet: 2¹⁰ - 2 = 1,022 hosts
- Use case: Medium enterprise networks with multiple VLANs
Notes
- Always verify calculations by ensuring network + broadcast addresses don’t overlap between subnets
- When subnetting, the network grows vertically (more subnets) at the expense of horizontal growth (fewer hosts per subnet)
- VLSM (Variable Length Subnet Masking) allows different subnet sizes within the same major network for optimal address utilization
- For CCNA exam: Practice identifying subnet boundaries quickly using magic number method
- Common mistake: Forgetting to subtract 2 from host calculations for network and broadcast addresses
- Zero subnets and all-ones subnets are valid in modern networking (older Cisco IOS versions disabled by default)
- Use
ip subnet-zerocommand on legacy equipment to enable subnet 0 usage