DevTools Logo

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
PrefixMaskHosts
/8255.0.0.016,777,214
/16255.255.0.065,534
/24255.255.255.0254
/28255.255.255.24014
/32255.255.255.2551 (single host)

Address classes (legacy)

Table
ClassRangeDefault mask
A1.0.0.0 – 126.0.0.0/8
B128.0.0.0 – 191.255.0.0/16
C192.0.0.0 – 223.255.255.0/24

Private ranges

Table
RangeCIDR
10.0.0.0 – 10.255.255.25510.0.0.0/8
172.16.0.0 – 172.31.255.255172.16.0.0/12
192.168.0.0 – 192.168.255.255192.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

References