Back to Networking Examples
Networking Basics · Guide 2

Subnetting, by hand

The Networking Introduction said the subnet mask tells a device “where the street part of the address ends” and left it there. This guide opens it up. You'll learn just enough binary to see what a mask really is, then a shortcut that answers any subnet question with one subtraction. You'll split one network into several smaller ones, and finish with practice problems. Pen and paper is all you need. By the end, /26 will mean something as definite to you as a street address.

The finish line — given one address, you'll work this out in under a minute
Address: 192.168.10.77/26 Mask: 255.255.255.192 Network: 192.168.10.64 Usable: 192.168.10.65 – 192.168.10.126 (62 devices) Broadcast: 192.168.10.127
Time needed ~60 min · hardware pen & paper
Subnetting is where most people decide networking is “maths” and give up. It isn't. It's counting in blocks, and there is one idea underneath all of it. The 💡 Explain it simply prompts are placed on that idea. Say the answers out loud. If you can explain why the block size is 256 minus the mask, you can subnet.
STEP 01

Why cut a network up?

Your home network is one street: 192.168.1.0 with mask 255.255.255.0, room for 254 devices, and everything on it can talk to everything else directly. For a house that's perfect. For a business it isn't. You don't want the guest Wi-Fi on the same street as the accounts computers, or the security cameras next to the laptops.

Subnetting means cutting one network into several smaller ones. Each piece is a subnet: its own street, with its own range of house numbers. A router joins the streets back together, and the router is where you get to decide what may cross from one to another.

At the top, one long street: 192.168.10.0/24, with room for 254 devices. An arrow labelled a longer mask, /26, leads down to a router joining four shorter streets: Office 192.168.10.0/26 with devices .1 to .62, Lab 192.168.10.64/26 with .65 to .126, Wi-Fi 192.168.10.128/26 with .129 to .190, and Cameras 192.168.10.192/26 with .193 to .254. Each has 62 usable addresses.
Same 256 addresses, cut into four streets of 64. Traffic between them goes through the router, where you can control it.

There are three reasons to do it, and you'll hear all three:

  • Security. Devices on different subnets can only reach each other through a router, and the router can have rules. Guests can reach the Internet but not your file server.
  • Less noise. Some messages go to everyone on a street (the ARP question “who is 192.168.1.1?” from the Introduction is one). On a street with 1,000 devices that chatter adds up. Smaller streets, less shouting.
  • Not wasting addresses. A link between two routers needs 2 addresses, not 254. Subnetting lets you hand out exactly as much as each place needs.

The tool that does the cutting is the mask. Make it longer and the street gets shorter. To see why, you need ten minutes of binary.

STEP 02

Binary in ten minutes.

Each of the four numbers in an IP address is called an octet, because a computer stores it as eight bits, eight switches that are each either 0 or 1. Each switch has a fixed value. From left to right they're worth 128, 64, 32, 16, 8, 4, 2 and 1, each one half of the one before. The octet's value is the total of the switches that are on:

Eight boxes labelled with their place values 128, 64, 32, 16, 8, 4, 2 and 1. Below them, 77 in binary: 0 1 0 0 1 1 0 1. The boxes holding a 1 are 64, 8, 4 and 1, which add up to 77. One octet is eight bits, running from 00000000, which is 0, to 11111111, which is 255.
Memorise the top row: 128 64 32 16 8 4 2 1. It's the only table subnetting needs.

Decimal to binary: take the biggest value that fits

To write 77 in binary, walk the row from the left. Does 128 fit in 77? No, write 0. Does 64 fit? Yes, write 1 and 13 is left. 32? No, 0. 16? No, 0. 8 fits into 13: 1, 5 left. 4 fits: 1, 1 left. 2? No, 0. 1 fits: 1, nothing left. Result: 01001101.

Binary to decimal: add up the ones

11000000 has the 128 and the 64 switched on: 128 + 64 = 192. 11111111 is every switch: 128+64+32+16+8+4+2+1 = 255, the biggest an octet can hold, which is why no IP address ever has a number above 255.

The only numbers you'll meet in a mask

Masks always fill in ones from the left, so a mask octet can only ever be one of nine values. Add the place values from the left, one at a time: 0, 128, 192 (128+64), 224 (+32), 240 (+16), 248 (+8), 252 (+4), 254 (+2), 255 (+1). If you see a mask with any other number in it, such as 255.255.255.100, it's a typo.

Try two before moving on: write 168 and 10 in binary. (Answers: 10101000 is 128+32+8; 00001010 is 8+2.)

STEP 03

What a mask really is.

An IP address is 32 bits: four octets of eight. The mask is also 32 bits, and it's simple: a run of 1s followed by a run of 0s. Where the mask has a 1, that bit of the address belongs to the network (the street). Where the mask has a 0, that bit belongs to the host (the house).

The slash number is just how many 1s the mask has. /24 is 24 ones then 8 zeros, which written out in octets is 255.255.255.0. /26 is 26 ones then 6 zeros: three octets of 255, and the fourth is 11000000, which is 192. So /26 = 255.255.255.192. Here's 192.168.10.77/26 with every bit on show:

192.168.10.77 written as 32 bits, with the /26 mask below it: 26 ones then 6 zeros. A dividing line after bit 26 separates the network part from the 6-bit host part. With all six host bits set to 0 the address is 192.168.10.64, the network address. With all six set to 1 it is 192.168.10.127, the broadcast address.
The first 26 bits (blue) are the street and are the same for every device on it. The last 6 bits (amber) are the house number.

Six host bits means the house number can be anything from 000000 to 111111, which is 64 combinations (2 × 2 × 2 × 2 × 2 × 2 = 26 = 64). So a /26 street is 64 addresses long. A /24 has 8 host bits, 28 = 256 addresses. Every bit you add to the mask halves the street; every bit you take away doubles it.

You've met the inside-out version

If you did Part 3 of the Cisco 1921 guide, you typed access-list 10 permit 192.168.10.0 0.0.0.255. That 0.0.0.255 is a wildcard mask: the subnet mask with every bit flipped. For a /26 it's 0.0.0.63. Same information, written the other way round, used only in access lists.

STEP 04

The four numbers of every subnet.

Every subnet question is really asking for the same four things. Look at the bottom two rows of the diagram in Step 03: they're the first two.

NumberHow to get itFor 192.168.10.77/26
Network addresshost bits all 0: the first address in the subnet. Names the street itself; no device uses it.192.168.10.64
Broadcast addresshost bits all 1: the last address in the subnet. A packet sent here goes to every device on the street; no device uses it as its own.192.168.10.127
Usable rangeeverything in between: network + 1 up to broadcast − 1..65 – .126
Usable hosts2host bits − 226 − 2 = 62

The router for a subnet takes one of the usable addresses, by convention usually the first. On the 192.168.10.64/26 street that would be 192.168.10.65, and it's what every device on the street has as its default gateway.

💡 Explain it simply

A /26 has 64 addresses, but only 62 devices can use them. A friend thinks that's a waste. Explain where the other two went and why you can't have them.

Reveal a plain-language answer

Two of the 64 are reserved names, not houses. The first one, all host bits 0, is the name of the street itself: when a router says “192.168.10.64/26 is out that port”, it means the whole street, so no single device can be called that. The last one, all host bits 1, means “everybody on this street”: it's the megaphone address. If a laptop took it, every message meant for everyone would land on that one laptop. So every subnet, whatever its size, gives up exactly two addresses: one for its name and one for its megaphone.

STEP 05

The shortcut: block size.

Writing out 32 bits every time works, but nobody does it. There's a shortcut that gives the same answer with one subtraction. It works because subnets always start on a multiple of their own size.

  1. Find the interesting octet: the first mask octet that isn't 255. For 255.255.255.192 it's the fourth.
  2. Block size = 256 − that number. 256 − 192 = 64. Every subnet is 64 addresses long.
  3. Count up in blocks from 0: 0, 64, 128, 192. Those are the network addresses of every possible subnet.
  4. Find the block your address sits in. 77 is between 64 and 128, so it's in the block that starts at 64.
  5. Read off the four numbers. Network is the block start (.64). Broadcast is one below the next block (.127). Usable is everything in between (.65–.126). Hosts: block size − 2 = 62.
A number line from 0 to 255 cut into four blocks of 64 because 256 minus 192 is 64: .0 to .63, .64 to .127, .128 to .191 and .192 to .255. A marker shows 77 in the second block. That block is enlarged: .64 is the network address, .65 to .126 are the 62 usable addresses, and .127 is the broadcast.
The whole method in one picture: cut the octet into blocks, find the block the address is in, and read off its first and last numbers.

One more, start to finish. 10.0.0.45/28: a /28 is 28 ones, so the fourth mask octet has four ones, 128+64+32+16 = 240, and the mask is 255.255.255.240. Block size 256 − 240 = 16. Count in 16s: 0, 16, 32, 48. 45 sits in the block starting at 32. Network 10.0.0.32, usable .33–.46, broadcast 10.0.0.47, 16 − 2 = 14 hosts.

💡 Explain it simply

Why does “256 minus the mask number” give you the size of each subnet? Explain it without the word “binary” if you can.

Reveal a plain-language answer

An octet has 256 possible values, 0 to 255. The mask number says how much of that octet is taken up by the street name. With 192, the street part uses up “192 worth”, and what's left over for house numbers is the rest: 256 − 192 = 64. So each street gets 64 house numbers. A bigger mask number takes more for the street and leaves less for houses, so the blocks get smaller: 224 leaves 32, 240 leaves 16, 252 leaves only 4. The subtraction is literally “what the street didn't use”.

STEP 06

Splitting a network: plan it yourself.

Now reverse the question. Instead of “which subnet is this address in?”, it's “I have 192.168.10.0/24; how do I cut it up?” This is the part you'll actually do in real life. Every bit you borrow from the host part doubles the number of subnets and halves their size:

Split a /24 intoPrefixMaskBlockUsable hosts each
1 (no split)/24255.255.255.0256254
2/25255.255.255.128128126
4/26255.255.255.1926462
8/27255.255.255.2243230
16/28255.255.255.2401614
32/29255.255.255.24886
64/30255.255.255.25242

The subnets don't all have to be the same size. Say a small business needs a guest Wi-Fi for up to 100 phones, an office network for 50 computers, and a lab with 20 machines. Pick the smallest block that fits each (remember the −2):

  • Guest Wi-Fi, 100 → a /26 (62) is too small, so /25 (126).
  • Office, 50 → /26 (62).
  • Lab, 20 → /27 (30).

Then lay them out largest first, each starting right after the one before. Because the blocks shrink in halves, each one automatically lands on a multiple of its own size, which is the rule every subnet must follow:

A to-scale bar of all 256 addresses in 192.168.10.0/24, split largest first. Guest Wi-Fi 192.168.10.0/25, addresses .1 to .126 usable, broadcast .127. Office 192.168.10.128/26, usable .129 to .190, broadcast .191. Lab 192.168.10.192/27, usable .193 to .222, broadcast .223. Addresses 224 to 255 are left free.
Three different sizes from one /24, with a quarter spare. Laying out largest first is what keeps every block on a legal boundary.

This is called VLSM (variable-length subnet masking), which is a long name for “not every subnet has to be the same size”. The spare .224–.255 could later become another /27, or two /28s, or eight /30s for links between routers.

Why not start the office at .100?

Because .100 isn't a multiple of 64, a /26 can't start there. A subnet's network address must be a multiple of its block size: /26s can only start at 0, 64, 128 or 192. Give a Cisco router ip route 192.168.10.100 255.255.255.192 … and it refuses with Inconsistent address and mask. Largest first means you never have to think about it.

STEP 07

When the interesting octet isn't the last.

Everything so far used masks longer than /24, where only the last octet changes. Bigger networks, the kind companies and cloud providers use, have masks shorter than /24, and then the interesting octet is the third one. The method doesn't change. You just apply it one octet to the left.

10.20.37.200/20:

  1. /20 = 8 + 8 + 4, so two octets of 255 and four ones in the third: 128+64+32+16 = 240. Mask 255.255.240.0.
  2. Interesting octet: the third. Block size 256 − 240 = 16.
  3. Count in 16s in the third octet: 0, 16, 32, 48… The address's third octet is 37, which is in the block starting at 32.
  4. Network: third octet 32, and everything after it 0: 10.20.32.0.
  5. Broadcast: third octet one below the next block (47), everything after it 255: 10.20.47.255.
  6. Usable: 10.20.32.1 to 10.20.47.254. Hosts: 4 + 8 = 12 host bits, 212 − 2 = 4,094.

The only new thing is that the fourth octet comes along for the ride: all 0s at the network end and all 255s at the broadcast end.

STEP 08

Check your answers on the computer.

Do it by hand first; that's how you learn it. Then let a computer confirm you're right. Python (installed on every Mac and Linux machine, and a free download for Windows) has subnetting built in:

Terminal / PowerShell — any address you like
python3 -c "import ipaddress as i; n=i.ip_interface('192.168.10.77/26').network; print(n.network_address, n.broadcast_address, n.num_addresses-2)"
192.168.10.64 192.168.10.127 62

Network, broadcast, usable hosts: the same three numbers you worked out in Step 05. On Windows, if python3 isn't found, try py in its place. Many Linux distributions also have ipcalc (sudo apt install ipcalc), which prints the whole breakdown including the binary.

Now subnet your own network

Run ipconfig (Windows) or ip addr (Linux) as you did in the Introduction, and take your own address and mask. Work out your network address, broadcast and usable range by hand. For almost every home network the mask is 255.255.255.0, so the answer is quick: network is your first three octets with .0, broadcast ends in .255, and there are 254 usable. Then check it with the Python line.

Where you'll type this for real

On a router, the mask goes wherever an address does: ip address 192.168.10.65 255.255.255.192. Cisco IOS wants the dotted mask, not the slash, which is why Step 02's list of nine mask values is worth memorising. The Cisco VLANs guide gives each VLAN its own subnet: subnetting and VLANs almost always go together.

STEP 09

Practice problems.

Work each one on paper with the block-size method before you open the answer. The first four are the everyday kind; the last three are the questions you'll actually be asked on the job.

  1. What are the network, usable range, broadcast and host count of 192.168.1.130/25?

    Show the answer

    Mask 255.255.255.128, block 256 − 128 = 128. Blocks start at 0 and 128; 130 is in the 128 block. Network 192.168.1.128, usable .129–.254, broadcast 192.168.1.255, 126 hosts.

  2. Same four numbers for 172.16.5.200/27.

    Show the answer

    /27 leaves 32 − 27 = 5 host bits. The fourth mask octet has three ones, 128+64+32 = 224: mask 255.255.255.224, block 32. Count in 32s: 160, 192, 224; 200 is in the 192 block. Network 172.16.5.192, usable .193–.222, broadcast 172.16.5.223, 30 hosts.

  3. And 192.168.50.9/30. What is special about this size?

    Show the answer

    Mask 255.255.255.252, block 4. Count in 4s: 0, 4, 8, 12; 9 is in the 8 block. Network 192.168.50.8, usable .9 and .10, broadcast 192.168.50.11, 2 hosts. Exactly two usable addresses is why a /30 is the classic choice for a cable between two routers: one address for each end.

  4. How many usable hosts does a /22 have, and what is its mask?

    Show the answer

    32 − 22 = 10 host bits, 210 − 2 = 1,022 hosts. /22 = 16 + 6, so the third mask octet has six ones: 128+64+32+16+8+4 = 252. Mask 255.255.252.0.

  5. A laptop is 192.168.1.60/26 and a printer is 192.168.1.70/26. Can they talk to each other directly?

    Show the answer

    No. Block size 64: the laptop is in the 0–63 block and the printer is in the 64–127 block. Different subnets, different streets. Their traffic has to go through a router, and if there isn't one, they can't reach each other at all, even plugged into the same switch. This exact mistake, a wrong mask on one device, is one of the most common “it's plugged in but can't see it” faults there is.

  6. A department needs addresses for 500 devices. What's the smallest subnet that fits?

    Show the answer

    Try host bits until 2h − 2 is at least 500: 8 bits gives 254 (too small), 9 bits gives 510. 32 − 9 = /23, mask 255.255.254.0.

  7. You're given 10.0.0.0/24 and need subnets for 60 staff, 25 servers, and 3 point-to-point router links. Plan it.

    Show the answer

    Sizes: staff 60 → /26 (62). Servers 25 → /27 (30). Each router link → /30 (2). Largest first: staff 10.0.0.0/26 (.1–.62), servers 10.0.0.64/27 (.65–.94), then the links 10.0.0.96/30, 10.0.0.100/30 and 10.0.0.104/30. Everything from 10.0.0.108 up is still free. Other valid layouts exist; what matters is that each subnet starts on a multiple of its block size and none overlap.

STEP 10

The cheat sheet.

Once the method is in your head you won't need this, but everyone keeps a copy anyway. The block size is in the octet that the mask changes: the third for /17–/23, the fourth for /25–/30.

PrefixMaskBlock (octet)Usable hosts
/16255.255.0.0—65,534
/20255.255.240.016 (3rd)4,094
/21255.255.248.08 (3rd)2,046
/22255.255.252.04 (3rd)1,022
/23255.255.254.02 (3rd)510
/24255.255.255.0—254
/25255.255.255.128128 (4th)126
/26255.255.255.19264 (4th)62
/27255.255.255.22432 (4th)30
/28255.255.255.24016 (4th)14
/29255.255.255.2488 (4th)6
/30255.255.255.2524 (4th)2

Two you'll see in the wild without the −2: a /32 is a single address, used to mean exactly one device in routing tables and access lists (the L lines in show ip route from the Cisco guides are /32s). A /31 has two addresses and, on router-to-router links only, uses both, because a cable with two ends has no need for a broadcast.

Check yourself

  • You can write any number from 0 to 255 in binary and back
  • You know the nine possible mask octets, 0 through 255, and why there are only nine
  • You can convert between slash and dotted masks (/26 ↔ 255.255.255.192)
  • Given any address and mask, you can find the network, broadcast, usable range and host count
  • You can explain why every subnet loses two addresses
  • You can split a /24 into subnets of different sizes without any overlapping
STEP 11

Where to go next.

You can now read any address and mask and say exactly which street it's on, how long the street is, and where it ends. That is most of what “knowing IP addressing” means. The next step is typing it into a real router.

3

How Wi-Fi works

Networking Basics Guide 3: the radio side of the network. Bands, channels, signal strength, and why your guest Wi-Fi is a subnet.

⬢

Cisco 1921 Router Guide

Configure real subnets on a real router. Part 2 puts a /24 on a port and hands out addresses from it; the VLANs guide gives three departments three subnets on one switch.

1

Networking Introduction

Back to the start if any word on this page didn't click: addresses, gateways, routers versus switches, and how a packet crosses the Internet.