All lessons
Beginner·20 minute read

IPv4 Subnetting in 20 minutes

Short answer

Subnetting splits one IPv4 network into smaller networks by moving the boundary between network bits and host bits. A /n prefix leaves 32 − n host bits, so a subnet holds 2^(32 − n) addresses and 2^(32 − n) − 2 usable hosts, because the first address names the network and the last is the broadcast.

Subnetting is the act of dividing a single IPv4 network into smaller, non-overlapping subnetworks by extending the network mask. This lesson explains how prefix length controls subnet size, why /30 is standard for point-to-point links, and the math every networking learner must memorize.

Open this lab

What a subnet actually is

An IPv4 address is 32 bits long, conventionally written as four decimal octets such as 192.168.10.42. The address is split into two parts: a network portion that identifies which subnet the host lives in, and a host portion that identifies the host within that subnet. The boundary between the two is set by the subnet mask.

When the mask is written in CIDR notation — for example /24 — the number after the slash counts the network bits from the left. /24 means the first 24 bits are network and the last 8 bits are host. That leaves 2^8 − 2 = 254 usable host addresses (the network and broadcast addresses are reserved).

The masks you must memorize

Every networking learner internalizes a small table of common prefixes and their dotted-decimal masks. Here are the ones that show up constantly:

/24  255.255.255.0     254 hosts   typical user LAN
/25  255.255.255.128   126 hosts   half a /24
/26  255.255.255.192    62 hosts   small office
/27  255.255.255.224    30 hosts   small VLAN
/28  255.255.255.240    14 hosts   IoT segment
/29  255.255.255.248     6 hosts   tiny lab
/30  255.255.255.252     2 hosts   point-to-point WAN
/31  255.255.255.254     2 hosts   RFC 3021 PtP
/32  255.255.255.255     1 host    loopback / host route

Why /30 for serial links

A point-to-point WAN link has exactly two endpoints. A /30 gives you four addresses: one network, one broadcast, and two usable hosts. That is a perfect fit and wastes no IP space. Many large WAN designs sit on /30s by default; modern code paths increasingly use /31s (RFC 3021) which save one more address by repurposing the network and broadcast bits as hosts.

Calculating the network address

To find the network a given IP belongs to, perform a bitwise AND between the IP and the mask. For 192.168.10.42 with mask 255.255.255.224 (/27), the network is 192.168.10.32 and the broadcast is 192.168.10.63. Hosts .33 through .62 are usable.

NetForge-AI does this math for you under the hood — but doing it by hand once or twice cements the intuition.

Try it in the lab

Drop two PCs and one switch onto the canvas. Configure 192.168.1.10/24 on PC1 and 192.168.1.20/24 on PC2. Ping. It works. Now change PC2 to 192.168.2.20/24 and ping again — it fails because the destination is no longer in the same subnet, and there is no router to forward the packet. That single change is the entire reason routers exist.

Note: Subnet boundaries are about prefix length, not IP value. 10.0.0.1/8 and 10.255.255.254/8 are in the same /8. 10.0.0.1/24 and 10.0.1.1/24 are not.

Common questions

How many usable hosts are in a /26?
62. A /26 leaves 6 host bits: 2^6 = 64 addresses, minus the network and broadcast addresses.
Why is /30 used on point-to-point links?
A /30 has exactly two usable addresses, one for each end of the link, so it wastes nothing. A /31 (RFC 3021) saves one more by using both addresses as hosts.
How do I find the network address of an IP?
AND the address with the mask, bit by bit. 192.168.10.42 with 255.255.255.224 (/27) gives network 192.168.10.32 and broadcast 192.168.10.63.
Is there a calculator to check my answers?
Yes — the free subnet calculator at /tools/subnet-calculator shows the network, broadcast, host range and mask for any address and prefix, with no sign-up.

Practice this in the lab

Reading helps. Wiring it up yourself and breaking it makes it stick.

Open the lab