IP Subnetting Cheat Sheet

Complete IPv4 and IPv6 subnetting reference. Subnet masks, CIDR notation, binary breakdown, private ranges, VLSM examples, and key formulas.

Cheat Sheet

Quick Reference

IPv4 Address
32 bits (4 octets)
IPv6 Address
128 bits (8 groups)
Max IPv4 Addresses
4,294,967,296
Classful Defaults
A /8 · B /16 · C /24

Key Formulas

These two formulas are the foundation of all subnet calculations.

FormulaExpressionWhat It CalculatesExample (/26)
Usable hosts 2^(32 − prefix) − 2 How many devices can be assigned IPs in a subnet 2^(32−26) − 2 = 62
Number of subnets 2^(borrowed bits) How many subnets are created when splitting a network Splitting /24 → /26 = 2^2 = 4
Block size 256 − mask octet The address increment between subnet boundaries 256 − 192 = 64
Why “− 2” in the host formula? Every subnet reserves two addresses: the first address is the network address (identifies the subnet itself) and the last is the broadcast address (sends to all hosts). Neither can be assigned to devices. Exception: /31 point-to-point links (RFC 3021) use both addresses — no broadcast needed.

Complete IPv4 Subnet Reference Table

All 33 possible IPv4 prefix lengths. Highlighted rows mark classful boundaries (/8, /16, /24).

CIDR Subnet Mask Wildcard Mask Addresses Usable Hosts Class
/32255.255.255.2550.0.0.011Host
/31255.255.255.2540.0.0.122 *P2P
/30255.255.255.2520.0.0.342P2P
/29255.255.255.2480.0.0.786
/28255.255.255.2400.0.0.151614
/27255.255.255.2240.0.0.313230
/26255.255.255.1920.0.0.636462
/25255.255.255.1280.0.0.127128126
/24255.255.255.00.0.0.255256254C
/23255.255.254.00.0.1.255512510
/22255.255.252.00.0.3.2551,0241,022
/21255.255.248.00.0.7.2552,0482,046
/20255.255.240.00.0.15.2554,0964,094
/19255.255.224.00.0.31.2558,1928,190
/18255.255.192.00.0.63.25516,38416,382
/17255.255.128.00.0.127.25532,76832,766
/16255.255.0.00.0.255.25565,53665,534B
/15255.254.0.00.1.255.255131,072131,070
/14255.252.0.00.3.255.255262,144262,142
/13255.248.0.00.7.255.255524,288524,286
/12255.240.0.00.15.255.2551,048,5761,048,574
/11255.224.0.00.31.255.2552,097,1522,097,150
/10255.192.0.00.63.255.2554,194,3044,194,302
/9255.128.0.00.127.255.2558,388,6088,388,606
/8255.0.0.00.255.255.25516,777,21616,777,214A
/7254.0.0.01.255.255.25533,554,43233,554,430
/6252.0.0.03.255.255.25567,108,86467,108,862
/5248.0.0.07.255.255.255134,217,728134,217,726
/4240.0.0.015.255.255.255268,435,456268,435,454
/3224.0.0.031.255.255.255536,870,912536,870,910
/2192.0.0.063.255.255.2551,073,741,8241,073,741,822
/1128.0.0.0127.255.255.2552,147,483,6482,147,483,646
/00.0.0.0255.255.255.2554,294,967,2964,294,967,294

* /31 uses both addresses for hosts per RFC 3021 (point-to-point links only).

Subnet Mask in Binary

Every subnet mask is a sequence of contiguous 1-bits (network) followed by 0-bits (host). Understanding the binary is the key to subnetting.

Example: /24 = 255.255.255.0

1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
0
0
0
0
0
0
0
0
Network bits (24) Host bits (8)

Example: /27 = 255.255.255.224

1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
0
0
0
0
0
Network bits (27) Host bits (5) → 30 usable hosts

Example: /20 = 255.255.240.0

1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
0
0
0
0
0
0
0
0
0
0
0
0
Network bits (20) Host bits (12) → 4,094 usable hosts

Octet Binary Values

Each bit position in an octet has a fixed decimal value. This is the basis of all binary-to-decimal conversion.

Bit position76543210
Decimal value1286432168421

Valid Subnet Mask Octets

Only these nine decimal values can appear in a subnet mask octet. Memorize them.

BinaryDecimalNetwork bits in octet
0000000000
100000001281
110000001922
111000002243
111100002404
111110002485
111111002526
111111102547
111111112558

IPv4 Address Classes

Classful addressing is mostly historical, but understanding classes helps when reading legacy documentation or preparing for certifications.

ClassFirst Octet RangeDefault MaskCIDRNetworksHosts/NetPurpose
A1 – 126255.0.0.0/812616,777,214Large orgs
B128 – 191255.255.0.0/1616,38465,534Medium orgs
C192 – 223255.255.255.0/242,097,152254Small orgs
D224 – 239Multicast
E240 – 255Reserved
Note: 127.0.0.0/8 is reserved for loopback. 0.0.0.0/8 is used for “this network” in routing contexts. Neither is assignable.

Private (RFC 1918) Address Ranges

These ranges are not routable on the public internet. Use them freely in internal networks.

RFC 1918 RangeCIDRSubnet MaskTotal AddressesClassCommon Use
10.0.0.010.255.255.25510.0.0.0/8255.0.0.016,777,216AEnterprise, cloud VPCs
172.16.0.0172.31.255.255172.16.0.0/12255.240.0.01,048,576BMid-size networks
192.168.0.0192.168.255.255192.168.0.0/16255.255.0.065,536CHome, small office

Other Special Address Ranges

RangeCIDRPurposeRFC
127.0.0.0/8/8LoopbackRFC 1122
169.254.0.0/16/16Link-local (APIPA)RFC 3927
100.64.0.0/10/10Carrier-grade NAT (CGN)RFC 6598
192.0.2.0/24/24Documentation (TEST-NET-1)RFC 5737
198.51.100.0/24/24Documentation (TEST-NET-2)RFC 5737
203.0.113.0/24/24Documentation (TEST-NET-3)RFC 5737
198.18.0.0/15/15BenchmarkingRFC 2544

Subnetting a /24 Network

The most common real-world scenario. This table shows every possible split of a /24 network.

PrefixSubnet MaskSubnetsHosts/SubnetBlock SizeExample Ranges (192.168.1.x)
/25255.255.255.1282126128.0–.127 , .128–.255
/26255.255.255.19246264.0–.63 , .64–.127 , .128–.191 , .192–.255
/27255.255.255.22483032.0–.31 , .32–.63 , .64–.95 , …
/28255.255.255.240161416.0–.15 , .16–.31 , .32–.47 , …
/29255.255.255.2483268.0–.7 , .8–.15 , .16–.23 , …
/30255.255.255.2526424.0–.3 , .4–.7 , .8–.11 , …
Block size shortcut: Block size = 256 − last non-zero octet of the subnet mask. Subnet boundaries always fall on multiples of the block size. For /26: 256 − 192 = 64, so subnets start at .0, .64, .128, .192.

VLSM — Variable Length Subnet Masking

VLSM lets you assign different prefix lengths to different segments, avoiding wasted address space. Always allocate the largest subnet first.

Practical Example

Given: 192.168.10.0/24. Requirements: Engineering (50 hosts), Sales (25 hosts), Management (10 hosts), WAN link (2 hosts).

SegmentHosts NeededPrefixAssigned SubnetUsable RangeBroadcast
Engineering50/26192.168.10.0/26.1 – .62.63
Sales25/27192.168.10.64/27.65 – .94.95
Management10/28192.168.10.96/28.97 – .110.111
WAN Link2/30192.168.10.112/30.113 – .114.115
Remaining space: After these allocations, 192.168.10.116/30 through 192.168.10.255 is still available for future growth.

Supernetting (Route Aggregation)

Supernetting combines multiple contiguous networks into a single larger CIDR block. This reduces routing table size.

Example: Aggregating 4 × /24 Networks

NetworkBinary (3rd octet)
10.1.0.0/2400000000
10.1.1.0/2400000001
10.1.2.0/2400000010
10.1.3.0/2400000011

First 22 bits are identical → Summary route: 10.1.0.0/22

Aggregation rules: Networks must be contiguous, the count must be a power of 2, and the first network must be evenly divisible by the block size. Summary prefix = original prefix − log₂(count).

IPv6 Subnetting Quick Reference

IPv6 uses 128-bit addresses. The standard interface prefix for SLAAC is /64 — this is not optional on most LANs.

PrefixTypical UseAvailable /64 Subnets
/128Single host (loopback)
/64Standard LAN subnet1
/56End-site allocation (residential ISP)256
/48Standard site allocation65,536
/32ISP allocation4,294,967,296

Common IPv6 Prefixes

PrefixPurpose
::1/128Loopback
::/0Default route
fe80::/10Link-local
fc00::/7Unique local (ULA — like RFC 1918)
2000::/3Global unicast (public)
ff00::/8Multicast

Powers of 2 — Quick Lookup

You need these constantly when calculating subnets and host counts. Worth memorizing up to 2¹⁶.

2ⁿValue2ⁿValue
2⁰12⁹512
22¹⁰1,024
42¹¹2,048
82¹²4,096
2⁴162¹³8,192
2⁵322¹⁴16,384
2⁶642¹⁵32,768
2⁷1282¹⁶65,536
2⁸2562²⁴16,777,216

Step-by-Step: How to Subnet

Follow these steps to subnet any network from scratch.

Step 1 — Determine host requirements

List all network segments and how many hosts each one needs.

Step 2 — Find the right prefix length

For each segment, find the smallest n where 2ⁿ − 2 ≥ required hosts. The prefix is 32 − n.

Step 3 — Calculate network details

  • Block size = 2n (where n = host bits)
  • Network address = first address in the block
  • First usable = network address + 1
  • Last usable = broadcast − 1
  • Broadcast = last address in the block

Step 4 — Verify

  • No overlapping ranges between subnets
  • Host count ≥ requirement for each segment
  • All subnets fit within the original network

Worked Example: 192.168.1.0/26

Network
192.168.1.0
First Usable
192.168.1.1
Last Usable
192.168.1.62
Broadcast
192.168.1.63
Usable Hosts
62
Next Subnet
192.168.1.64

FAQ

What is the difference between a subnet mask and a wildcard mask?
A wildcard mask is the bitwise inverse of the subnet mask. Where the subnet mask has a 1, the wildcard has a 0, and vice versa. Wildcard masks are used in Cisco ACLs and OSPF configurations. To convert: 255.255.255.255 − subnet mask = wildcard mask. For example, subnet mask 255.255.255.192 → wildcard 0.0.0.63.
When should I use /31 vs /30 for point-to-point links?
/30 gives you 4 addresses (2 usable) — the traditional choice. /31 (RFC 3021) gives you 2 addresses with both usable, saving address space. Most modern routers support /31. Use /31 when both endpoints support it; use /30 for legacy equipment.
What is CIDR notation?
CIDR (Classless Inter-Domain Routing) uses a slash followed by the number of network bits. /24 means the first 24 bits identify the network. CIDR replaced classful addressing (A/B/C) to allow more flexible allocation of IP address space. A /24 is equivalent to the old Class C subnet mask 255.255.255.0.
Why is /64 the standard for IPv6 LANs?
IPv6 SLAAC (Stateless Address Autoconfiguration) requires exactly 64 bits for the interface identifier. The host portion is derived from the device’s MAC address (via EUI-64) or generated randomly (privacy extensions). Using anything other than /64 on a LAN breaks SLAAC. This is by design — IPv6 has enough address space that conserving at the subnet level is unnecessary.
How do I quickly find the network address from an IP and prefix?
Perform a bitwise AND between the IP address and the subnet mask. In practice, for the “interesting octet” (where the mask is not 255 or 0), divide the host octet by the block size and round down. For 192.168.1.200/26: block size = 64, so 200 ÷ 64 = 3.125 → 3 × 64 = 192. Network address = 192.168.1.192.