Most Asked Interview Problems·Lesson 2 of 11

Subnetting Numericals

01

What Subnetting Even Means

Before the math, the idea. An is the number that identifies a device on a network — in the common version, IPv4, it's written as four numbers from 0 to 255 separated by dots, like 192.168.1.10. Each of those four numbers is called an because it's stored as 8 bits. Every address secretly splits into two parts: a network part (which network you're on) and a host part (which specific device you are on that network). Subnetting is the act of carving one big network into smaller ones by moving the dividing line between those two parts.

Why split a network at all

Smaller subnets keep local traffic local, improve security by isolating groups, and stop one giant network from wasting addresses. Interviewers use subnetting to test whether you understand how addresses are actually structured.

🏢

A building address and apartment number

Think of an address like '742 Maple Street, Apt 12'. The street part tells you which building — that's the network. The apartment number tells you which unit inside it — that's the host. Subnetting is like splitting one large building into separate wings, each with its own block of apartment numbers.

02

The Subnet Mask

How does a device know where the network part ends and the host part begins? The . It's another 32-bit number where the network bits are 1s and the host bits are 0s. A mask of 255.255.255.0 means 'the first 24 bits are network, the last 8 are host'. Because writing out full masks is tedious, we usually use notation — a slash and the number of network bits — so 255.255.255.0 becomes simply /24. The bigger the number after the slash, the more bits belong to the network and the fewer are left for hosts.

These are the masks you'll meet most often. Notice how each extra network bit halves the number of hosts:

CIDRSubnet maskHost bitsUsable hosts
/24255.255.255.08254
/25255.255.255.1287126
/26255.255.255.192662
/27255.255.255.224530
/28255.255.255.240414
03

The Formulas You Need

Almost every subnetting problem comes down to four quick calculations. If the prefix is /n, then the number of host bits is 32 − n. From there: the total addresses in the subnet are 2^(host bits); the usable hosts are 2^(host bits) − 2 (you subtract two because one address names the network and one is the broadcast); and if you borrow b bits to make subnets, you get 2^b subnets.

The four go-to formulas

  • Host bits = 32 minus the prefix length
  • Total addresses in a subnet = 2 raised to the host bits
  • Usable hosts = 2 raised to the host bits, minus 2 (network + broadcast)
  • Number of subnets = 2 raised to the number of borrowed bits

The two addresses you can't assign

In every subnet, the first address (all host bits 0) is the network address that names the subnet, and the last address (all host bits 1) is the broadcast address that reaches every host at once. Neither can be given to a device — that's the '− 2' in the usable-hosts formula.

04

Worked Example — Split a Network Into Four

Problem: take the network 192.168.1.0/24 and divide it into four equal subnets. To make four subnets you borrow 2 host bits, because 2 raised to 2 equals 4. Those borrowed bits push the prefix from /24 to /26, leaving 6 host bits — so each subnet holds 64 addresses (2 to the 6th) and 62 usable hosts. The subnets step up in blocks of 64: 0, 64, 128, and 192. Here's the full breakdown:

SubnetNetwork addressUsable host rangeBroadcast
1192.168.1.0192.168.1.1 – 192.168.1.62192.168.1.63
2192.168.1.64192.168.1.65 – 192.168.1.126192.168.1.127
3192.168.1.128192.168.1.129 – 192.168.1.190192.168.1.191
4192.168.1.192192.168.1.193 – 192.168.1.254192.168.1.255
05

Worked Example — Which Subnet Is a Host In?

This is the single most common subnetting question: given one address and a mask, find its subnet's boundaries. The trick is the block size — how far apart the subnets are — which equals 256 minus the value of the mask's last octet.

1

You're given the host address 192.168.1.100 with a /26 prefix (mask 255.255.255.192).

What are its network address, broadcast address, and usable host range?

Answer: A /26 has a block size of 256 − 192 = 64, so subnets begin at .0, .64, .128, and .192. The host .100 sits in the .64 block (which spans .64 to .127). So the network address is 192.168.1.64, the broadcast is 192.168.1.127, and usable hosts run from 192.168.1.65 to 192.168.1.126.

06

Worked Example — How Many Bits to Borrow?

Sometimes you're told how many hosts each subnet must hold and asked to find the mask. Work backward from the usable-hosts formula until you have enough room.

2

Each subnet in your design must hold at least 50 devices.

What is the smallest mask (fewest host bits) that works, and how many usable hosts does it give?

Answer: Usable hosts = 2 raised to the host bits, minus 2. Five host bits give 30 (too few). Six host bits give 62, which comfortably covers 50. So you need 6 host bits, making the prefix /26 (32 − 6). It supports 62 usable hosts per subnet.

🚫

"A /26 subnet has 64 addresses, so I can assign all 64 to devices."

You can only assign 62. Every subnet reserves its first address as the network identifier and its last as the broadcast address, so the usable count is always the total minus two.

Q:What's the fastest way to find a subnet's block size in an interview?

A: Take 256 minus the value of the mask's subnetted octet. For a /26 the mask octet is 192, so the block size is 64 — meaning subnets start at 0, 64, 128, and 192. Block size instantly tells you where each subnet begins and ends, which is the key to finding network and broadcast addresses.

Quick Revision Cheat Sheet

Host bits: 32 minus the prefix length

Total addresses: 2 ^ host bits

Usable hosts: 2 ^ host bits minus 2

Block size: 256 minus the mask's subnetted octet

Network address: First address (all host bits 0)

Broadcast address: Last address (all host bits 1)