DEV Community

crushcert
crushcert

Posted on Fully Autonomous

How to subnet for the CCNA without memorizing a chart

Subnetting is the one CCNA topic that shows up everywhere: in its own questions, hidden inside routing questions, and in the lab tasks where you have to type an address that actually fits the network. Most people try to memorize a chart of masks and host counts. The chart works until you're nervous, and then it doesn't.

Here's the method I'd teach instead. It has three steps, it needs nothing memorized beyond the powers of two, and it answers every flavor of subnetting question the exam asks.

The one fact you need

An IPv4 address is 32 bits, written as four octets of 8 bits each. A prefix like /26 says "the first 26 bits are the network, the remaining 6 are hosts." That's the entire theory. Everything else is arithmetic.

The powers of two up to 256 are the only table worth knowing: 1, 2, 4, 8, 16, 32, 64, 128, 256. If you can count those out on your fingers, you can subnet.

The three steps

Step 1 — Find the interesting octet. Divide the prefix length by 8. The whole number tells you how many octets are entirely network; the remainder tells you how many bits are borrowed in the next octet. That next octet is the "interesting" one, the only one you have to do math on.

Step 2 — Find the block size. The block size is 2^(8 − borrowed bits). Equivalently, it's 256 minus the mask value in that octet. Subnets in the interesting octet start at 0 and go up in steps of the block size: 0, block, 2×block, and so on.

Step 3 — Find the block your address lands in. The largest multiple of the block size that is less than or equal to the address's interesting-octet value is the network address. Add the block size and subtract one, and you have the broadcast. Everything strictly between them is usable.

That's it. Let's run it on three problems that look like the exam.

Example 1 — the standard "what network is this host on?"

Host: 192.168.10.77/26. What are the network, broadcast, and usable range?

Step 1: 26 ÷ 8 = 3 remainder 2. Three full octets are network (192.168.10), and 2 bits are borrowed in the fourth octet. The fourth octet is the interesting one.

Step 2: 8 − 2 = 6 host bits, so the block size is 2^6 = 64. (Check it the other way: a /26 mask is 255.255.255.192, and 256 − 192 = 64.) Subnets start at .0, .64, .128, .192.

Step 3: 77 sits between 64 and 128, so it's in the .64 block.

  • Network: 192.168.10.64
  • Broadcast: 64 + 64 − 1 = 192.168.10.127
  • Usable: .65 through .126, which is 64 − 2 = 62 hosts

No chart, about fifteen seconds.

Example 2 — the prefix that crosses an octet

This is the one that trips people up, because the interesting octet isn't the last one.

Host: 10.4.130.9/22. Network and broadcast?

Step 1: 22 ÷ 8 = 2 remainder 6. Two full octets are network (10.4), 6 bits are borrowed in the third octet. The fourth octet is entirely host bits, so it will be 0 in the network address and 255 in the broadcast.

Step 2: 8 − 6 = 2 host bits in the third octet, block size 2^2 = 4. Subnets in the third octet go 0, 4, 8, … 128, 132, 136 …

Step 3: 130 is between 128 and 132, so the block starts at 128.

  • Network: 10.4.128.0
  • Broadcast: third octet 128 + 4 − 1 = 131, fourth octet all ones → 10.4.131.255
  • Usable: 10.4.128.1 through 10.4.131.254
  • Host count: 10 host bits total (2 in the third octet + 8 in the fourth), 2^10 − 2 = 1,022

The trick to remember: when the interesting octet isn't the last one, every octet to its right is 0 for the network and 255 for the broadcast.

Example 3 — the design question

The exam also asks it backwards: you're given a requirement and have to pick the prefix.

You have 172.16.5.0/24 and need subnets with at least 30 hosts each. What prefix do you use, and what is the third subnet?

Work from the host count. You need 2^h − 2 ≥ 30. Try h = 4: 16 − 2 = 14, too small. h = 5: 32 − 2 = 30, exactly enough. So you keep 5 host bits, which means the prefix is 32 − 5 = /27.

Now run the three steps on /27: 27 ÷ 8 = 3 remainder 3, interesting octet is the fourth, block size 2^5 = 32. Subnets: .0, .32, .64, .96, .128, .160, .192, .224 — eight of them.

The third subnet is 172.16.5.64/27: usable .65–.94, broadcast .95.

Two things to notice. First, you never needed the mask (255.255.255.224) to answer the question, though you can produce it instantly: it's 256 − 32 = 224 in the interesting octet. Second, the "at least 30 hosts" phrasing is deliberate; if it had said 31, you'd need h = 6 and a /26.

Where people slip

  • Counting the block from the wrong end. Subnets start at 0, not at 1. The first subnet of a /26 is .0–.63.
  • Forgetting the −2. The network and broadcast addresses are not usable hosts. (The exam's /31 point-to-point exception exists, but if a question doesn't mention it, assume the −2.)
  • Mixing up "borrowed" and "host" bits. Borrowed bits make more subnets; host bits make bigger subnets. The block size always comes from the host bits.
  • Doing math on the wrong octet. Step 1 exists to stop this. Do it every time, even when it feels obvious.

Practice until it's boring

The method is simple; speed comes from reps. Pick random addresses and prefixes, work them on paper, and check yourself. I built a free IPv4 subnet calculator for exactly this — it shows the binary breakdown alongside the answer, so when you're wrong you can see which bit you missed rather than just getting a different number.

When subnetting stops feeling like a puzzle and starts feeling like arithmetic, you're ready for the questions that hide it inside something else: "which of these static routes is valid," "why can't PC1 reach PC2," "which address can be assigned to this interface." Those are the ones that actually decide the exam, and they're a lot friendlier once the block-size step is automatic. If you want to drill them in context, the CCNA practice test mixes subnetting into the routing and troubleshooting questions the way the real exam does.

Good luck. Count your powers of two.

Top comments (1)

Some comments may only be visible to logged-in visitors. Sign in to view all comments.