Skip to main content

IP Addressing & Subnetting

This is the single most tested topic in the whole process. If you master one thing, master this.

The rule​

A subnet mask determines which part of an address is the network and which part is the host.

  • Number of network bits = the number after the slash in CIDR.
  • Number of host bits = 32 minus that.
  • Total addresses = 2^(host bits).
  • Usable hosts = 2^(host bits) − 2, because the first is the network address and the last is the broadcast address.
PrefixMaskHost bitsTotalUsable
/24255.255.255.08256254
/25255.255.255.1287128126
/26255.255.255.19266462
/27255.255.255.22453230
/28255.255.255.24041614
/29255.255.255.248386
/30255.255.255.252242
Memorise this one table

Nine rows, and you can answer every subnetting question. /30 is worth remembering specially — two usable addresses is exactly what a router-to-router link uses, which is why it shows up so often in routing questions.

The calculator​

Drag the prefix slider. Try to predict the answer before you look.

IPv4 subnet calculator
/24
Subnet mask255.255.255.0
Wildcard0.0.0.255
Network address192.168.1.0
First usable host192.168.1.1
Last usable host192.168.1.254
Broadcast192.168.1.255
Next network192.168.2.0
Usable hosts254 (of 256)

Worked example 1 — the most common question​

"Given 192.168.1.0/24, what is the last usable host in the /26?"

  1. /26 → host bits = 32 − 26 = 6
  2. Total addresses = 2^6 = 64
  3. Block size = 64, so subnets are 192.168.1.0, 192.168.1.64, 192.168.1.128, 192.168.1.192
  4. The /26 containing .1 is 192.168.1.0/26 → network .0, broadcast .63
  5. First usable .1, last usable .62
Do not misread the question

"Last usable host in the /26" is asking about the subnet that contains the address you were given. If they ask about the network itself, the answer differs. Re-read before answering.

Worked example 2 — splitting a network​

"Split 192.168.0.0/24 into four equal subnets."

Each subnet needs 2^2 = 4 blocks worth of space: 256 ÷ 4 = 64 → /26.

SubnetNetworkFirst hostLast hostBroadcast
1192.168.0.0/26.1.62.63
2192.168.0.64/26.65.126.127
3192.168.0.128/26.129.190.191
4192.168.0.192/26.193.254.255

Worked example 3 — the shortest prefix for a host count​

"How many hosts do I need /24 to support? Give the shortest prefix."

Work up from /30 until usable ≥ your requirement:

NeedPrefixUsable
2/302
6/296
14/2814
30/2730
62/2662
126/25126
254/24254
Tip

Interviewers like this because it tests whether you think in ranges rather than memorising them.

Borrowed bits​

The jump from a /24 to the next subnet is called borrowing host bits for network bits.

/24 ──────────── 1 bit ──▶ /25
/24 ──────────── 2 bits ──▶ /26
/24 ──────────── 3 bits ──▶ /27

What you need on a Windows machine​

ipconfig /all

Read out loud in an interview:

FieldWhy you care
IPv4 AddressIs it static, DHCP, or APIPA?
Subnet MaskConfirms the prefix
Default GatewayWhere traffic leaves the subnet
DHCP ServerWho handed out the address
DNS ServersWhy name resolution works or fails
ipconfig /release # drop the DHCP lease
ipconfig /renew # request a new one
ipconfig /flushdns # clear the resolver cache

Common mistakes​

MistakeWhy it is wrong
Forgetting to subtract 2Network and broadcast are unusable
Assuming /24 always means 254 hostsOnly true for the specific /24 you are looking at
Confusing subnet mask with wildcardWildcard is the inverse — used in ACLs
Using the broadcast as a gatewayNever assignable to a host
Forgetting /31 and /32 exist/32 is a single host, /31 is a point-to-point link
Bonus points

Mention RFC 3021: a /31 on a router-to-router link has two usable addresses because the "all ones" and "all zeros" host addresses are treated as valid. Saying that unprompted is a strong signal.

Drill yourself​

Subnetting readiness
0 / 5 complete

Next​

Port Testing — named directly in your JD.

Was this page helpful?