Subnetting means taking one larger network and dividing it into smaller, self-contained networks called subnets. Say a company has a single block of address space, like 192.168.1.0/24. It can split that block up to give separate ranges to different departments, floors, or VLANs, instead of putting every device on one flat network.
The guided series
This page is the overview. To learn to subnet by hand, work through these short lessons in order. Each one has worked answers to check yourself against and ends with the practice drill.
- Subnet masks and CIDR: Read a mask in binary, convert between /prefix and dotted mask, count hosts.
- A step-by-step method: Five steps that find the network, broadcast and host range of any address.
- Worked examples: /24, /25, /26: The method on the prefixes you meet most, one step at a time.
- Harder examples: /20 and /27: When the interesting octet is the third, and when blocks get small.
- Network, broadcast and usable hosts: Is this address usable? Same subnet? Which prefix fits 500 hosts?
- VLSM for a real office: Plan a whole office from one /23: users, phones, guests, servers and links.
- Find the mistake: Spot the error in someone else's answer, the way a reviewer would.
Why subnet at all?
- Smaller broadcast domains. Every device on the same subnet shares broadcast traffic (ARP requests, DHCP discovery, and so on). Fewer devices per subnet means less broadcast noise and better performance.
- Isolation and security. Traffic between subnets has to pass through a router. This gives you a natural point to apply access control, like keeping a guest Wi-Fi subnet from reaching internal servers. Subnetting alone doesn't isolate anything: a router forwards between its subnets by default, so the isolation comes from the ACLs or firewall policies you add there.
- Efficient use of address space. Instead of wasting a large block of addresses on a department with only 10 devices, subnetting lets you size each network to roughly match what it actually needs.
Think of one big open-plan office divided into separate rooms. Everyone can still reach everyone else through the hallway (the router), but noise and traffic inside one room no longer spill into every other room.
The subnet mask and prefix length
A subnet mask marks which bits of an IPv4 address are the network portion and which are the host portion. A 1 marks a network bit, a 0 marks a host bit. 255.255.255.0 in binary is 24 ones followed by 8 zeros. That's why it's also written as the CIDR prefix /24: the number after the slash simply counts the leading 1 bits.
| Prefix | Subnet mask | Host bits | Usable hosts |
|---|---|---|---|
/24 | 255.255.255.0 | 8 | 254 |
/25 | 255.255.255.128 | 7 | 126 |
/26 | 255.255.255.192 | 6 | 62 |
/27 | 255.255.255.224 | 5 | 30 |
/28 | 255.255.255.240 | 4 | 14 |
/29 | 255.255.255.248 | 3 | 6 |
/30 | 255.255.255.252 | 2 | 2 |
That last column follows 2ⁿ − 2, where n is the number of host bits. You subtract 2 for the reserved network and broadcast addresses on every subnet up to /30 (/31 and /32 are exceptions). The CIDR Calculator converts between prefix and mask instantly. The Wildcard Mask Calculator shows the inverted form of a mask, used in access lists and OSPF configuration.
On real equipment you will meet both forms. Routing tables and most modern configs show the prefix length, while Cisco's ip address command still takes the dotted mask.
Splitting one network into equal subnets
The core move in subnetting is borrowing host bits to create more network bits. Take 192.168.1.0/24 and borrow 2 bits from the host portion to make it a /26. Those 2 borrowed bits give 2² = 4 equal-sized subnets, each with 2⁶ − 2 = 62 usable hosts:
| Subnet | Network address | Usable range | Broadcast |
|---|---|---|---|
| 1 | 192.168.1.0/26 | .1 – .62 | 192.168.1.63 |
| 2 | 192.168.1.64/26 | .65 – .126 | 192.168.1.127 |
| 3 | 192.168.1.128/26 | .129 – .190 | 192.168.1.191 |
| 4 | 192.168.1.192/26 | .193 – .254 | 192.168.1.255 |
Enter 192.168.1.0/26 into the Subnet Calculator. It will show you the full breakdown: network address, broadcast address, and usable host range, for any address and prefix you give it.
Borrow bits and watch the /24 split
Use the controls below to borrow more or fewer bits from 192.168.1.0/24 and watch it split into equal subnets in real time.
Borrow 2 host bits from 192.168.1.0/24 to create 4 subnets of /26 each.
192.168.1.0/26
192.168.1.64/26
192.168.1.128/26
192.168.1.192/26
192.168.1.0 – 63192.168.1.64 – 127192.168.1.128 – 191192.168.1.192 – 255HR, Finance and IT sharing one /24
A small office needs three separate networks: HR, Finance, and IT. Each gets its own subnet, so traffic between them passes through the router, where rules can control it, and they all share one 192.168.1.0/24 block:
Read in arrow direction. Labels describe each stage or hop; connectors show the sequence, not a complete physical cabling plan or time to scale.
Devices within HR can talk to each other directly, without a router. If Finance needs to reach a file server on the IT subnet, that traffic has to pass through the router. That's exactly where a network administrator would apply a rule to allow or block it.
VLSM: subnets of different sizes
Splitting into equal subnets is simple, but it wastes space when departments need very different numbers of hosts. VLSM (Variable Length Subnet Masking) solves this by giving each subnet only as many host bits as it actually needs. The standard approach: sort requirements largest-first. Then allocate each one starting from the next free address, sized to the smallest power of two that fits.
For example, start from 192.168.1.0/24 with three requirements: Sales needs 50 hosts, Engineering needs 25, and Guest Wi-Fi needs 10:
| Department | Hosts needed | Allocated block | Usable hosts |
|---|---|---|---|
| Sales | 50 | 192.168.1.0/26 | 62 |
| Engineering | 25 | 192.168.1.64/27 | 30 |
| Guest Wi-Fi | 10 | 192.168.1.96/28 | 14 |
Each block is sized to its actual need, instead of every department getting an identical, mostly-empty /26. You don't need to do this by hand. The VLSM Calculator takes a base network and a list of named requirements, and produces exactly this kind of allocation table.
Doing it in your head: the block size
- Number of subnets =
2raised to the number of bits you borrow. - Block size is the gap between each subnet's network address. It equals
256minus the first octet of the subnet mask that is not 255. For a/26mask (255.255.255.192), that's256 − 192 = 64. That's exactly the spacing in the four-subnet table above (.0, .64, .128, .192).