Addressing, Subnetting, and CIDR
IP addressing is how devices identify and reach each other across networks. Subnetting allows you to divide networks efficiently.
IPv4 Addressing
IPv4 addresses are 32-bit, written in dotted decimal notation (e.g., 192.168.1.10). Each octet is 8 bits (0-255).
Address Classes (Historical)
| Class | Range | Default Mask | Use Case |
|---|---|---|---|
| A | 1.0.0.0 - 126.255.255.255 | /8 (255.0.0.0) | Very large networks |
| B | 128.0.0.0 - 191.255.255.255 | /16 (255.255.0.0) | Medium networks |
| C | 192.0.0.0 - 223.255.255.255 | /24 (255.255.255.0) | Small networks |
| D | 224.0.0.0 - 239.255.255.255 | Multicast | Multicast |
| E | 240.0.0.0 - 255.255.255.255 | Reserved | Experimental |
Classful addressing is mostly obsolete; CIDR is used today.
Private Address Ranges (RFC 1918)
| Range | CIDR | Use Case |
|---|---|---|
| 10.0.0.0 - 10.255.255.255 | 10.0.0.0/8 | Large private networks |
| 172.16.0.0 - 172.31.255.255 | 172.16.0.0/12 | Medium private networks |
| 192.168.0.0 - 192.168.255.255 | 192.168.0.0/16 | Home/small networks |
Special Addresses
| Address | Purpose |
|---|---|
| 127.0.0.0/8 | Loopback (localhost) |
| 169.254.0.0/16 | APIPA/link-local (auto-config failure) |
| 255.255.255.255 | Limited broadcast |
| 0.0.0.0 | Default route / unspecified |
CIDR (Classless Inter-Domain Routing)
CIDR replaced classful addressing, allowing flexible subnet sizes with prefix notation.
Notation: 192.168.1.0/24 means first 24 bits are network, last 8 are host.
CIDR Cheat Sheet
| CIDR | Subnet Mask | Hosts | Notes |
|---|---|---|---|
| /32 | 255.255.255.255 | 1 | Single host |
| /31 | 255.255.255.254 | 2 | Point-to-point links (RFC 3021) |
| /30 | 255.255.255.252 | 2 usable | Point-to-point |
| /29 | 255.255.255.248 | 6 usable | Small networks |
| /28 | 255.255.255.240 | 14 usable | Small networks |
| /27 | 255.255.255.224 | 30 usable | Small networks |
| /26 | 255.255.255.192 | 62 usable | Medium |
| /25 | 255.255.255.128 | 126 usable | Medium |
| /24 | 255.255.255.0 | 254 usable | Common |
| /23 | 255.255.254.0 | 510 usable | Larger |
| /22 | 255.255.252.0 | 1022 usable | Larger |
| /21 | 255.255.248.0 | 2046 usable | Larger |
| /20 | 255.255.240.0 | 4094 usable | Larger |
| /16 | 255.255.0.0 | 65534 usable | Large |
| /8 | 255.0.0.0 | 16M+ usable | Very large |
Usable hosts = 2^(host bits) - 2 (network and broadcast addresses)
Subnetting Example
Problem: Split 192.168.10.0/24 into 4 subnets
Solution: - Need 4 subnets = 2 bits borrowed - New prefix = /26 - Subnets: - 192.168.10.0/26 (0-63) - 192.168.10.64/26 (64-127) - 192.168.10.128/26 (128-191) - 192.168.10.192/26 (192-255)
Each subnet has 62 usable hosts.
VLSM (Variable Length Subnet Masking)
VLSM allows different subnet sizes within the same network, avoiding waste.
Example: Need subnets for different departments with different sizes: - IT: 50 hosts → needs /26 or /25 - Sales: 20 hosts → needs /27 - Management: 5 hosts → needs /29 - Point-to-point links: 2 hosts each → need /30
VLSM lets you allocate efficiently instead of giving everyone the same size.
IPv6 Basics
IPv6 addresses are 128-bit, written in hexadecimal with colons (e.g., 2001:0db8:85a3::8a2e:0370:7334). Much larger address space.
| Feature | IPv4 | IPv6 |
|---|---|---|
| Length | 32-bit | 128-bit |
| Notation | Dotted decimal | Hex colon |
| Addresses | ~4.3 billion | ~340 undecillion |
| NAT | Common | Usually not needed (end-to-end) |
| Auto-config | DHCP or manual | SLAAC (Stateless Address Autoconfiguration) |
| Header | Variable, complex | Fixed 40-byte header |
Key IPv6 Concepts
- Link-local: fe80::/10 (auto-configured, local link only)
- Unique local (ULA): fc00::/7 (private equivalent)
- Global unicast: 2000::/3 (public)
- Multicast: ff00::/8 (replaces broadcast)
- Loopback: ::1/128
Practical Tips
- Memorize common prefixes: /24, /25, /26, /27, /28 are most common
- Use binary when learning: Helps understand why
- Practice with calculators: ipcalc, subnet calculators are fine tools
- Think in powers of 2: 2^n for hosts/subnets
- In cloud: You'll work with VPC CIDRs, subnets, route tables constantly
Related Notes
- OSI TCPIP Models — Where IP fits
- Routing Fundamentals — How packets are routed
- VPC Fundamentals — Cloud addressing
- NAT And PAT — Address translation
Sources
- RFC 1918 (Address Allocation for Private Internets)
- RFC 4632 (Classless Inter-domain Routing)
- RFC 4291 (IP Version 6 Addressing Architecture)
- Kurose & Ross - Computer Networking