1.5 IPv4 Addressing and Subnetting
Key Takeaways
- An IPv4 address is 32 bits divided into a network portion and host portion by the subnet mask.
- CIDR notation /24 means 24 network bits and 8 host bits (256 addresses, 254 usable).
- The formula for usable hosts per subnet is 2^h - 2 (subtract network and broadcast addresses).
- Private IP ranges: 10.0.0.0/8, 172.16.0.0/12, 192.168.0.0/16 (RFC 1918).
- VLSM (Variable Length Subnet Masking) allows different subnet sizes within the same network.
IPv4 Addressing and Subnetting
Subnetting is arguably the most important skill for the CCNA exam. It appears in questions across every domain. Master subnetting and you'll have a significant advantage.
IPv4 Address Structure
An IPv4 address is a 32-bit number, typically written in dotted decimal notation as four octets separated by dots (e.g., 192.168.1.100).
192.168.1.100 in binary:
11000000.10101000.00000001.01100100
Each octet is 8 bits, with values from 0 to 255.
Subnet Masks and CIDR Notation
A subnet mask identifies which portion of an IP address is the network part and which is the host part:
- Network bits = 1s in the subnet mask (identify the network)
- Host bits = 0s in the subnet mask (identify the individual host)
| Subnet Mask | CIDR | Network Bits | Host Bits | Usable Hosts |
|---|---|---|---|---|
| 255.0.0.0 | /8 | 8 | 24 | 16,777,214 |
| 255.255.0.0 | /16 | 16 | 16 | 65,534 |
| 255.255.255.0 | /24 | 24 | 8 | 254 |
| 255.255.255.128 | /25 | 25 | 7 | 126 |
| 255.255.255.192 | /26 | 26 | 6 | 62 |
| 255.255.255.224 | /27 | 27 | 5 | 30 |
| 255.255.255.240 | /28 | 28 | 4 | 14 |
| 255.255.255.248 | /29 | 29 | 3 | 6 |
| 255.255.255.252 | /30 | 30 | 2 | 2 |
| 255.255.255.254 | /31 | 31 | 1 | 2 (point-to-point) |
| 255.255.255.255 | /32 | 32 | 0 | 1 (host route) |
Key Subnetting Formulas
| Formula | Purpose |
|---|---|
| 2^n | Number of subnets (n = borrowed bits) |
| 2^h - 2 | Usable hosts per subnet (h = host bits) |
| 256 - subnet mask value | Block size (magic number) |
Subnetting Step-by-Step Example
Problem: Given the network 192.168.10.0/26, find the subnet details.
Step 1: Determine the mask /26 = 255.255.255.192
Step 2: Calculate block size 256 - 192 = 64 (each subnet contains 64 addresses)
Step 3: Calculate usable hosts Host bits = 32 - 26 = 6 Usable hosts = 2^6 - 2 = 62
Step 4: List the subnets
| Subnet | Network Address | First Usable | Last Usable | Broadcast |
|---|---|---|---|---|
| 1 | 192.168.10.0 | 192.168.10.1 | 192.168.10.62 | 192.168.10.63 |
| 2 | 192.168.10.64 | 192.168.10.65 | 192.168.10.126 | 192.168.10.127 |
| 3 | 192.168.10.128 | 192.168.10.129 | 192.168.10.190 | 192.168.10.191 |
| 4 | 192.168.10.192 | 192.168.10.193 | 192.168.10.254 | 192.168.10.255 |
Key observations:
- The network address is always the first address in each block (all host bits = 0)
- The broadcast address is always the last address in each block (all host bits = 1)
- Usable addresses are everything in between
Private IPv4 Address Ranges (RFC 1918)
These addresses are not routable on the public internet:
| Range | CIDR | Class | Number of Addresses |
|---|---|---|---|
| 10.0.0.0 - 10.255.255.255 | 10.0.0.0/8 | Class A | 16,777,216 |
| 172.16.0.0 - 172.31.255.255 | 172.16.0.0/12 | Class B | 1,048,576 |
| 192.168.0.0 - 192.168.255.255 | 192.168.0.0/16 | Class C | 65,536 |
Private addresses are used inside organizations and translated to public addresses using NAT (Network Address Translation) to access the internet.
Other Special IPv4 Addresses
| Address/Range | Purpose |
|---|---|
| 127.0.0.0/8 | Loopback (127.0.0.1 is localhost) |
| 169.254.0.0/16 | APIPA (Automatic Private IP Addressing) |
| 0.0.0.0 | Default route / unspecified address |
| 255.255.255.255 | Limited broadcast |
| 224.0.0.0 - 239.255.255.255 | Multicast (Class D) |
On the Exam: If a host has a 169.254.x.x address, it means the DHCP process failed and the host assigned itself an APIPA address. This is a common troubleshooting scenario.
VLSM (Variable Length Subnet Masking)
VLSM allows you to use different subnet mask lengths within the same classful network. This is essential for efficient IP address allocation.
Example: You have 10.0.0.0/24 and need to allocate subnets for:
- LAN A: 100 hosts → needs /25 (126 usable hosts)
- LAN B: 50 hosts → needs /26 (62 usable hosts)
- LAN C: 25 hosts → needs /27 (30 usable hosts)
- WAN Link: 2 hosts → needs /30 (2 usable hosts)
VLSM allocation (start with the largest subnet):
- LAN A: 10.0.0.0/25 (10.0.0.1 - 10.0.0.126)
- LAN B: 10.0.0.128/26 (10.0.0.129 - 10.0.0.190)
- LAN C: 10.0.0.192/27 (10.0.0.193 - 10.0.0.222)
- WAN Link: 10.0.0.224/30 (10.0.0.225 - 10.0.0.226)
On the Exam: VLSM questions often present a network and ask you to efficiently allocate subnets. Always start with the largest subnet first, then work your way down to the smallest. This prevents address overlap.
Powers of 2 Reference Table
Memorize this table—it's the foundation of fast subnetting:
| Power | Value | Host Bits | Usable Hosts | CIDR (from /24) |
|---|---|---|---|---|
| 2^1 | 2 | 1 | 2 (P2P) | /31 |
| 2^2 | 4 | 2 | 2 | /30 |
| 2^3 | 8 | 3 | 6 | /29 |
| 2^4 | 16 | 4 | 14 | /28 |
| 2^5 | 32 | 5 | 30 | /27 |
| 2^6 | 64 | 6 | 62 | /26 |
| 2^7 | 128 | 7 | 126 | /25 |
| 2^8 | 256 | 8 | 254 | /24 |
How many usable host addresses are available in a /27 subnet?
A host has the IP address 172.20.5.100/22. What is the network address?
Which of the following is a private IPv4 address range defined by RFC 1918?