4.3.8 · D3Computer Networks

Worked examples — IPv4 — address format, classes, subnetting, CIDR notation

3,454 words16 min readBack to topic

This page is the "throw everything at it" companion to the parent IPv4 note. The parent gave you the tools; here we drill every kind of question an exam or a real network can ask — every quadrant of the problem space, every degenerate edge, every trap.

Before we start, one promise: we build every idea from bits. If you can count in base 2 (see Binary and Positional Number Systems) you can follow line one to the end.


The scenario matrix

Every IPv4 subnetting problem is one (or a blend) of these cells. Our examples below are labelled with the cell they cover, so by the end no cell is left dark.

# Cell (kind of case) What makes it tricky Covered by
C1 Prefix breaks mid-octet (e.g. /26, /27) block size ≠ whole octet; must find the boundary Ex 1, Ex 3
C2 Prefix on an octet boundary (/8, /16, /24) clean split — sanity anchor Ex 2
C3 "How many subnets" (borrow bits) choosing from a required subnet count Ex 4
C4 Degenerate tiny nets (/30, /31, /32) the "" rule breaks or vanishes Ex 5
C5 Zero / all-ones host (network & broadcast) reserved addresses, off-by-one Ex 1, Ex 3, Ex 8
C6 Aggregation / supernetting (merge blocks) going the other way — fewer network bits Ex 6
C7 Real-world word problem (VLSM) translate English → prefixes Ex 7
C8 Exam twist: is X a valid host? membership test, boundary confusion Ex 8

Example 1 — /26: prefix breaks mid-octet (cells C1, C5)


Example 2 — /16: clean octet-boundary split (cell C2)


Example 3 — /27: another mid-octet cut, and picking a valid subnet address (cells C1, C5)


Example 4 — "I need N subnets": borrowing bits (cell C3)


Example 5 — Degenerate tiny networks /30, /31, /32 (cell C4)


Example 6 — Aggregation / supernetting (cell C6)


Example 7 — Real-world word problem, VLSM (cell C7)


Example 8 — Exam twist: "Is this a valid host?" (cells C8, C5)


Recall Cover-and-recall: the whole matrix in one breath

Mid-octet prefix → find block size , network = largest multiple ≤ host octet. ::: Ex 1, 3 Octet-boundary prefix → no block hunting, just zero/255 the host octets. ::: Ex 2 Need N subnets → smallest with ; new prefix . ::: Ex 4 /31 special rule → 2 usable, no net/broadcast reserved (RFC 3021). ::: Ex 5 Aggregate 4 contiguous aligned /24s → one /22. ::: Ex 6 VLSM word problem → size largest-first, align each on its block. ::: Ex 7 "Valid host?" → fails if it's the network or broadcast address. ::: Ex 8

See also: Subnet Mask and ANDing (how a router extracts the network part), NAT — Network Address Translation (how private ranges reach the Internet), DHCP and APIPA (who hands out these addresses), IPv6 — addressing and notation (what happens when 32 bits run out).