Claude is having a major outage. Status board · Discuss Claude

Cheat sheet

Subnetting cheat sheet

IPv4 subnetting by hand: the prefix and mask table, the block-size method, worked examples for finding a network, sizing for hosts, splitting a block and VLSM, plus the ranges and IPv6 basics worth knowing.

All cheat sheets

How to work out a subnet by hand: the prefix table, one method that works for every question, and worked examples. When you are ready, practise with random questions that show the working.

Prefix, mask and size

The prefix (/26) counts the network bits. The rest are host bits: a subnet has 2host bits addresses, and two of them (the network and the broadcast address) cannot be given to hosts.

Prefix Mask Block size Addresses Usable hosts
/8 255.0.0.0 octet boundary 16,777,216 16,777,214
/9 255.128.0.0 128 in the second octet 8,388,608 8,388,606
/10 255.192.0.0 64 in the second octet 4,194,304 4,194,302
/11 255.224.0.0 32 in the second octet 2,097,152 2,097,150
/12 255.240.0.0 16 in the second octet 1,048,576 1,048,574
/13 255.248.0.0 8 in the second octet 524,288 524,286
/14 255.252.0.0 4 in the second octet 262,144 262,142
/15 255.254.0.0 2 in the second octet 131,072 131,070
/16 255.255.0.0 octet boundary 65,536 65,534
/17 255.255.128.0 128 in the third octet 32,768 32,766
/18 255.255.192.0 64 in the third octet 16,384 16,382
/19 255.255.224.0 32 in the third octet 8,192 8,190
/20 255.255.240.0 16 in the third octet 4,096 4,094
/21 255.255.248.0 8 in the third octet 2,048 2,046
/22 255.255.252.0 4 in the third octet 1,024 1,022
/23 255.255.254.0 2 in the third octet 512 510
/24 255.255.255.0 octet boundary 256 254
/25 255.255.255.128 128 in the fourth octet 128 126
/26 255.255.255.192 64 in the fourth octet 64 62
/27 255.255.255.224 32 in the fourth octet 32 30
/28 255.255.255.240 16 in the fourth octet 16 14
/29 255.255.255.248 8 in the fourth octet 8 6
/30 255.255.255.252 4 in the fourth octet 4 2
/31 255.255.255.254 2 in the fourth octet 2 2 (point-to-point link, RFC 3021)
/32 255.255.255.255 1 (one address) 1 1 (a single host)

The mask octets to know by heart: 128, 192, 224, 240, 248, 252, 254, 255, for 1 to 8 bits. The block size is 256 minus the mask octet.

The method: block size

  1. Write the prefix as a mask, or the mask as a prefix.
  2. Find the octet where the mask is neither 255 nor 0. That octet is where the network ends.
  3. Block size = 256 − the mask in that octet. Networks start at 0 and every multiple of the block size.
  4. The network is the multiple at or below your address in that octet, with 0 in every octet after it.
  5. The broadcast is the next network minus one: the network plus the block size minus 1 in that octet, with 255 in every octet after it.
  6. Usable hosts run from network + 1 to broadcast − 1. There are 2host bits − 2 of them.

Example: 192.168.10.37/26

  1. /26 is the mask 255.255.255.192: 26 network bits, 6 host bits.
  2. The prefix ends in the fourth octet, where the mask is 192. Block size: 256 − 192 = 64.
  3. Networks start at multiples of 64 in that octet. 37 falls in the block 0 to 63.
  4. Network 192.168.10.0, broadcast 192.168.10.63.
  5. Usable: 192.168.10.1 to 192.168.10.62, 26 − 2 = 62 hosts.

Example: 172.16.45.200/20

  1. /20 is the mask 255.255.240.0: 20 network bits, 12 host bits.
  2. The prefix ends in the third octet, where the mask is 240. Block size: 256 − 240 = 16.
  3. Networks start at multiples of 16 in that octet. 45 falls in the block 32 to 47.
  4. Network 172.16.32.0, broadcast 172.16.47.255.
  5. Usable: 172.16.32.1 to 172.16.47.254, 212 − 2 = 4,094 hosts.

Example: 10.20.137.9/13

  1. /13 is the mask 255.248.0.0: 13 network bits, 19 host bits.
  2. The prefix ends in the second octet, where the mask is 248. Block size: 256 − 248 = 8.
  3. Networks start at multiples of 8 in that octet. 20 falls in the block 16 to 23.
  4. Network 10.16.0.0, broadcast 10.23.255.255.
  5. Usable: 10.16.0.1 to 10.23.255.254, 219 − 2 = 524,286 hosts.

Sizing and splitting

Example: the smallest subnet for 50 hosts

  1. 50 hosts plus the network and broadcast addresses: 52 addresses.
  2. The smallest power of two that is at least 52: 26 = 64 (25 = 32 is too small).
  3. 6 host bits, so 32 − 6 = /26, mask 255.255.255.192: 62 usable, 12 spare.

Example: split 10.1.0.0/24 into 6 subnets

  1. 6 subnets need 3 borrowed bits: 23 = 8 is the smallest power of two that is at least 6 (2 spare).
  2. New prefix: /24 + 3 = /27. Each subnet has 25 = 32 addresses (30 usable).
  3. The subnets step by 32 from 10.1.0.0:
Subnet Network Usable range Broadcast
1 10.1.0.0/27 10.1.0.1 to 10.1.0.30 10.1.0.31
2 10.1.0.32/27 10.1.0.33 to 10.1.0.62 10.1.0.63
3 10.1.0.64/27 10.1.0.65 to 10.1.0.94 10.1.0.95
4 10.1.0.96/27 10.1.0.97 to 10.1.0.126 10.1.0.127
5 10.1.0.128/27 10.1.0.129 to 10.1.0.158 10.1.0.159
6 10.1.0.160/27 10.1.0.161 to 10.1.0.190 10.1.0.191
7 10.1.0.192/27 10.1.0.193 to 10.1.0.222 10.1.0.223
8 10.1.0.224/27 10.1.0.225 to 10.1.0.254 10.1.0.255

Different sizes from one block (VLSM)

When segments need different sizes, give each one only what it needs. Sort the needs from largest to smallest and hand out blocks in that order, so every block starts on a multiple of its own size.

Example: 192.168.50.0/24 for these five segments.

Segment Hosts needed Size Network Usable range
Staff 100 /25 (126 usable) 192.168.50.0/25 192.168.50.1 to 192.168.50.126
Wi-Fi guests 50 /26 (62 usable) 192.168.50.128/26 192.168.50.129 to 192.168.50.190
Printers 20 /27 (30 usable) 192.168.50.192/27 192.168.50.193 to 192.168.50.222
Link to branch A 2 /30 (2 usable) 192.168.50.224/30 192.168.50.225 to 192.168.50.226
Link to branch B 2 /30 (2 usable) 192.168.50.228/30 192.168.50.229 to 192.168.50.230

Everything from 192.168.50.232 to 192.168.50.255 is still free for later. A /30 for each point-to-point link is the traditional choice; many routers also accept a /31 (RFC 3021), which uses two addresses instead of four.

Two hosts, same subnet?

Work out the network of each address with its mask. If the two networks match, the hosts talk directly. If they differ, traffic between them goes through a router (or a layer 3 switch), and a host with the wrong mask will send traffic to its gateway that should have stayed local, or the other way round.

Ranges worth knowing

Range What it is
10.0.0.0/8, 172.16.0.0/12, 192.168.0.0/16 Private addresses (RFC 1918). Not routed on the internet; NAT translates them.
100.64.0.0/10 Shared address space for carrier-grade NAT (RFC 6598). Seen on the WAN side of some ISP routers.
169.254.0.0/16 Link-local (APIPA). A Windows PC gives itself one when DHCP does not answer, which makes it a useful clue.
127.0.0.0/8 Loopback: the machine itself.
224.0.0.0/4 Multicast.

IPv6 in one paragraph

IPv6 addresses are 128 bits, and there is no broadcast address, so nothing is subtracted. A single network segment is a /64: stateless address autoconfiguration (SLAAC) needs it, so you do not size IPv6 segments by host count. Sites are usually given a /48 or a /56 and hand out /64s from it. Worth recognising: fe80::/10 link-local, fc00::/7 unique local (the IPv6 version of private), 2001:db8::/32 reserved for documentation.