← Module 03 · Layer 3: Network

IPv4 Addressing, CIDR & VLSM

An IP (Internet Protocol) address is only half the story. The other half is the mask that decides where the network ends and the host begins.

Short answer: A prefix sets the subnet boundary. A /26 leaves 6 host bits, giving 64 addresses and ordinarily 62 usable hosts. VLSM uses different prefix lengths inside one parent block so each subnet fits its requirements.

Before this: OSI and TCP/IP and switches and routers.

Network bits and host bits

An IPv4 address is 32 bits, written as four decimal bytes like 192.168.10.37. On its own, that number doesn't tell you anything about which network the device is on. You need a second number, the subnet mask, to split those 32 bits into a network portion and a host portion.

Think of a whole office building's street address as the network part, and each individual unit number as the host part. 192.168.10.0/24 means the first 24 bits are the "building," and the remaining 8 bits are free for up to 254 "units" inside it.

CIDR replaced fixed classes

IPv4 originally split addresses into fixed-size classes (A, B, C), each with a mask baked into the address range itself. That was inflexible, and wasteful for anyone who needed a network with, say, 40 hosts, but not 254. CIDR (Classless Inter-Domain Routing) replaced that with the /prefix notation you actually use today: the number after the slash is just how many bits are network bits, period, independent of any class.

CIDR prefixSubnet maskUsable hosts
/24255.255.255.0254
/25255.255.255.128126
/26255.255.255.19262
/27255.255.255.22430
/28255.255.255.24014
/30255.255.255.2522 (point-to-point link)

VLSM: Sizing each subnet to what it actually needs

VLSM (Variable Length Subnet Masking) allows different-sized subnets inside the same address block. Suppose the main office needs 50 host addresses, a branch needs 25, and a router link needs 2, including any interface and gateway addresses. Giving all three a /26 would waste space. Instead, allocate a /26, a /27, and a /30, largest first. In the building analogy, each subnet is a wing with its own range of unit numbers; a small wing doesn't need as many numbers as a large one.

10.0.1.0 / 24, 256 total addresses to divide up 10.0.1.0/26 62 hosts, main office 10.0.1.64/27 30 hosts, branch office 10.0.1.96/30 2 hosts, WAN link The rest of the /24 (10.0.1.100 onward) stays free for the next subnet that needs carving out
Same original block, three differently sized subnets, each one no bigger than it needs to be.

Worked allocation: boundaries matter

A /26 advances in blocks of 64, a /27 in blocks of 32, and a /30 in blocks of 4. Start each subnet on a matching boundary. The network address identifies the wing; the broadcast address reaches the whole wing. Neither is an ordinary host address.

RequirementNetwork/prefixUsable rangeBroadcastCapacity
50 hosts10.0.1.0/2610.0.1.1 to 10.0.1.6210.0.1.6362
25 hosts10.0.1.64/2710.0.1.65 to 10.0.1.9410.0.1.9530
2 hosts10.0.1.96/3010.0.1.97 to 10.0.1.9810.0.1.992

The allocation consumes 100 of the parent's 256 addresses, leaving 156 unallocated. The remainder is not one CIDR subnet: 10.0.1.100/30, 10.0.1.104/29, 10.0.1.112/28, and 10.0.1.128/25 cover it without overlaps. A new /27 cannot start at .100; its next aligned start is .128.

Check one host's configuration

For 10.0.1.70/27, the last mask byte is 224. Bitwise AND gives 70 & 224 = 64, so the host belongs to 10.0.1.64/27. Its ordinary usable range is .65 through .94. A default gateway of .65 fits; .97 belongs to the router-link subnet instead.

SymptomCheckInterpretation
A host can reach some neighbors but not othersCompare address, prefix, and gateway on both hostsA mismatched mask changes which destinations are treated as on-link. It is one possible cause, not proof by itself.
A proposed subnet overlaps anotherCalculate each network through broadcast rangeDisjoint ranges, not different-looking prefix labels, establish separate allocations.
THE RULE THAT TRIPS PEOPLE UP

Ordinary IPv4 subnets reserve the first address for the network and the last for broadcast. A /30 therefore has 4 total addresses and 2 usable. Two exceptions matter: a /31 on a supported point-to-point link uses both addresses as endpoints (RFC 3021), and a /32 identifies one address, often as a host route or loopback address. Do not apply the "subtract two" rule blindly to these prefixes.

Continue with longest prefix match, ARP and on-link delivery, or inter-VLAN routing.