IP addresses uniquely identify devices on a network. Understanding addressing and subnetting is fundamental to network design and troubleshooting.
IPv4 Addressing
32-bit addresses written in dotted decimal notation: 192.168.1.1
Private Address Ranges (RFC 1918)
| Class | Range | CIDR | Hosts |
|---|---|---|---|
| A | 10.0.0.0 - 10.255.255.255 | 10.0.0.0/8 | 16,777,214 |
| B | 172.16.0.0 - 172.31.255.255 | 172.16.0.0/12 | 1,048,574 |
| C | 192.168.0.0 - 192.168.255.255 | 192.168.0.0/16 | 65,534 |
Special Addresses
127.0.0.0/8- Loopback (localhost)169.254.0.0/16- Link-local (APIPA, when DHCP fails)0.0.0.0- Default route / “any address”255.255.255.255- Broadcast
CIDR Notation
Classless Inter-Domain Routing replaced classful addressing. The /n suffix indicates the number of network bits.
| CIDR | Subnet Mask | Hosts |
|---|---|---|
| /32 | 255.255.255.255 | 1 |
| /24 | 255.255.255.0 | 254 |
| /16 | 255.255.0.0 | 65,534 |
| /8 | 255.0.0.0 | 16,777,214 |
Quick mental maths: Hosts = 2^(32-n) - 2 (subtract network and broadcast addresses)
Subnetting
Dividing a network into smaller segments for:
- Security isolation
- Reduced broadcast domains
- Efficient IP allocation
Subnetting Example
Given 192.168.1.0/24, create 4 subnets:
- Need 2 additional bits (2^2 = 4 subnets)
- New prefix: /26 (24 + 2)
- Each subnet: 64 addresses (62 usable)
| Subnet | Network | Usable Range | Broadcast |
|---|---|---|---|
| 1 | 192.168.1.0/26 | .1 - .62 | .63 |
| 2 | 192.168.1.64/26 | .65 - .126 | .127 |
| 3 | 192.168.1.128/26 | .129 - .190 | .191 |
| 4 | 192.168.1.192/26 | .193 - .254 | .255 |
IPv6 Addressing
128-bit addresses written in hexadecimal: 2001:0db8:85a3:0000:0000:8a2e:0370:7334
Shorthand rules:
- Leading zeros can be omitted:
2001:db8:85a3:0:0:8a2e:370:7334 - One group of consecutive zeros can be replaced with
:::2001:db8:85a3::8a2e:370:7334
Common IPv6 Ranges
::1/128- Loopbackfe80::/10- Link-localfc00::/7- Unique local (like private IPv4)2000::/3- Global unicast (public)
NAT (Network Address Translation)
Translates private IPs to public IPs at the network boundary.
- SNAT (Source NAT) - Outbound traffic, many-to-one
- DNAT (Destination NAT) - Inbound traffic, port forwarding
- PAT (Port Address Translation) - Multiple hosts share one public IP via ports
NAT breaks end-to-end connectivity but conserves IPv4 addresses. IPv6 was designed to eliminate the need for NAT.
References
- CIDR Report - Global routing table statistics
- ipcalc - Online subnet calculator
- RFC 1918 - Private Addresses
- RFC 4291 - IPv6 Addressing