IP Addresses & Subnetting Cheat Sheet
IPv4/IPv6 formats, CIDR notation, subnet masks, address classes, and subnet calculation.
Web & Network
ip
ipv4
ipv6
IP addresses identify hosts on a network; subnetting divides a network into smaller segments. CIDR notation expresses a network as an address plus a prefix length that defines the mask.
IPv4 format
code
192.168.1.10
Four octets (0–255), 32 bits total. Written in dotted-decimal.
IPv6 format
code
2001:0db8:0000:0000:0000:0000:0000:0001
2001:db8::1 # compressed
Eight 16-bit groups, 128 bits total. Leading zeros and one run of zeros can be compressed with ::.
CIDR notation
code
192.168.1.0/24
Table
| Prefix | Mask | Hosts |
|---|---|---|
| /8 | 255.0.0.0 | 16,777,214 |
| /16 | 255.255.0.0 | 65,534 |
| /24 | 255.255.255.0 | 254 |
| /28 | 255.255.255.240 | 14 |
| /32 | 255.255.255.255 | 1 (single host) |
Address classes (legacy)
Table
| Class | Range | Default mask |
|---|---|---|
| A | 1.0.0.0 – 126.0.0.0 | /8 |
| B | 128.0.0.0 – 191.255.0.0 | /16 |
| C | 192.0.0.0 – 223.255.255.0 | /24 |
Private ranges
Table
| Range | CIDR |
|---|---|
| 10.0.0.0 – 10.255.255.255 | 10.0.0.0/8 |
| 172.16.0.0 – 172.31.255.255 | 172.16.0.0/12 |
| 192.168.0.0 – 192.168.255.255 | 192.168.0.0/16 |
Subnet calculation
code
network = address & mask
broadcast = address | ~mask
first host = network + 1
last host = broadcast - 1
hosts = 2^(32 - prefix) - 2