Homelab · Guide · By Mohammed Almuhanna · Updated

Subnetting Explained: IPs, CIDR, and Subnet Masks

Subnetting is how you carve one IP network into smaller, separate networks. People see the binary and bounce off, but the idea is simple. Every address has a network part and a host part, and subnetting just moves the line between them. Stop memorizing mask tables. Learn the one thing that moves the line and let a calculator do the arithmetic. I subnet my own homelab so my IoT junk cannot reach the NAS, and that alone pays for the effort. What follows is what each piece means and how to actually split a network.

IP addresses and networks

An IPv4 address is four numbers separated by dots, like 192.168.1.10. Each number is an octet, ranging from 0 to 255, because each octet is eight bits. So the full address is 32 bits.

Part of the address identifies the network and part identifies the host (a single device) on that network. Two devices on the same network share the same network part and differ only in the host part. That shared network part is what lets them talk to each other directly without a router.

Home and lab networks use private ranges that are reserved for internal use and never routed on the public internet:

Most home routers hand out addresses from 192.168.0.0/24 or 192.168.1.0/24.

The subnet mask

This is the part that does the work. The subnet mask tells a device which bits of an address are the network part and which are the host part. The classic mask 255.255.255.0 means the first three octets (the 255s) are the network and the last octet (the 0) is the host.

Applied to 192.168.1.10 with mask 255.255.255.0, the network is 192.168.1.0 and the host number is 10. Any other address starting with 192.168.1. is on the same network. Change that third octet to 192.168.2.10 and you are on a different network that needs a router to reach.

Under the hood a 255 means all eight bits in that octet are network bits, and a 0 means all eight are host bits. The mask is just a run of 1 bits followed by a run of 0 bits, which is why CIDR can describe it with a single number.

CIDR notation

CIDR is just shorthand for the same mask, and it is what I use everywhere because it is faster to read. It writes the network size as a slash followed by the count of network bits. 192.168.1.0/24 means the first 24 bits are the network, leaving 8 bits for hosts. Since 24 bits is exactly the first three octets, /24 is the same thing as the mask 255.255.255.0.

A smaller number means fewer network bits, which means more host bits, which means a bigger network. A larger number means a smaller network. Common equivalences:

CIDRSubnet maskTotal addressesUsable hosts
/16255.255.0.065,53665,534
/24255.255.255.0256254
/26255.255.255.1926462
/30255.255.255.25242

So /16 is a large network with room for tens of thousands of hosts, /24 is the familiar home network, and /26 is a quarter of a /24.

Network address, broadcast, and usable hosts

In a normal subnet you do not get to use every address. Two are reserved. The first address is the network address, the name of the subnet itself. The last address is the broadcast address, used to reach every host at once. Everything in between is available for actual devices.

That is why usable hosts is normally two fewer than the total. The formula is:

usable hosts = 2^(host bits) - 2

The two exceptions are point-to-point links. A /31 gives both addresses to the two ends (RFC 3021), and a /32 is a single host with no network or broadcast to spare, which is why the subnet calculator handles those two cases on their own.

A /24 has 8 host bits, so 2^8 = 256 total addresses and 254 usable. In 192.168.1.0/24 the network address is 192.168.1.0, the broadcast is 192.168.1.255, and hosts run from 192.168.1.1 to 192.168.1.254.

Why subnet

This is the part that actually matters, so here is where I'd spend the effort. A flat network where everything can talk to everything is the default, and it is fine until a cheap smart plug gets compromised and now it is sitting on the same network as your NAS. Splitting one flat network into several smaller ones buys you real things in a homelab.

A worked example

Here is the whole thing on one network. Take 192.168.1.0/24 and split it into /26 subnets. Going from /24 to /26 borrows 2 host bits, and 2 bits give 4 combinations, so you get four subnets. Each /26 holds 64 addresses (62 usable). The four subnets:

SubnetRangeNetworkBroadcastUsable hosts
192.168.1.0/26.0 - .63192.168.1.0192.168.1.63.1 - .62
192.168.1.64/26.64 - .127192.168.1.64192.168.1.127.65 - .126
192.168.1.128/26.128 - .191192.168.1.128192.168.1.191.129 - .190
192.168.1.192/26.192 - .255192.168.1.192192.168.1.255.193 - .254

You could now assign the first /26 to trusted machines, the second to IoT, the third to a guest network, and the fourth to lab VMs, each isolated behind its own VLAN.

To do this for any network without the arithmetic, drop a network into the subnet calculator and it lays out the network address, broadcast, mask, and host range instantly, for IPv4 or IPv6.

Common questions

What does CIDR notation like /24 mean?

CIDR writes the network size as a slash followed by the count of network bits. So /24 means the first 24 bits are the network, leaving 8 bits for hosts, which is the same as the mask 255.255.255.0. A smaller number means more host bits and a bigger network; a larger number means a smaller one.

Why is usable hosts always two fewer than the total?

Inside any subnet two addresses are reserved: the first is the network address that names the subnet, and the last is the broadcast address used to reach every host at once. Everything in between is available for devices. The formula is usable hosts = 2^(host bits) - 2.

How many usable hosts does a /24 have?

A /24 has 8 host bits, so 2^8 = 256 total addresses and 254 usable. In 192.168.1.0/24 the network address is 192.168.1.0, the broadcast is 192.168.1.255, and hosts run from 192.168.1.1 to 192.168.1.254.

Why would I subnet a home network?

Splitting one flat network into smaller ones buys you segmentation, so a cheap smart plug cannot reach your NAS, plus security control at the router or firewall between subnets, less broadcast noise, and a clean mapping to VLANs on a managed switch.