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.
| Prefix | Mask | Host bits | Total | Usable |
|---|---|---|---|---|
| /24 | 255.255.255.0 | 8 | 256 | 254 |
| /25 | 255.255.255.128 | 7 | 128 | 126 |
| /26 | 255.255.255.192 | 6 | 64 | 62 |
| /27 | 255.255.255.224 | 5 | 32 | 30 |
| /28 | 255.255.255.240 | 4 | 16 | 14 |
| /29 | 255.255.255.248 | 3 | 8 | 6 |
| /30 | 255.255.255.252 | 2 | 4 | 2 |
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.
/24| Subnet mask | 255.255.255.0 |
|---|---|
| Wildcard | 0.0.0.255 |
| Network address | 192.168.1.0 |
| First usable host | 192.168.1.1 |
| Last usable host | 192.168.1.254 |
| Broadcast | 192.168.1.255 |
| Next network | 192.168.2.0 |
| Usable hosts | 254 (of 256) |
Worked example 1 — the most common question
"Given 192.168.1.0/24, what is the last usable host in the /26?"
- /26 → host bits = 32 − 26 = 6
- Total addresses = 2^6 = 64
- Block size = 64, so subnets are 192.168.1.0, 192.168.1.64, 192.168.1.128, 192.168.1.192
- The /26 containing .1 is 192.168.1.0/26 → network .0, broadcast .63
- First usable .1, last usable .62
"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.
| Subnet | Network | First host | Last host | Broadcast |
|---|---|---|---|---|
| 1 | 192.168.0.0/26 | .1 | .62 | .63 |
| 2 | 192.168.0.64/26 | .65 | .126 | .127 |
| 3 | 192.168.0.128/26 | .129 | .190 | .191 |
| 4 | 192.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:
| Need | Prefix | Usable |
|---|---|---|
| 2 | /30 | 2 |
| 6 | /29 | 6 |
| 14 | /28 | 14 |
| 30 | /27 | 30 |
| 62 | /26 | 62 |
| 126 | /25 | 126 |
| 254 | /24 | 254 |
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:
| Field | Why you care |
|---|---|
| IPv4 Address | Is it static, DHCP, or APIPA? |
| Subnet Mask | Confirms the prefix |
| Default Gateway | Where traffic leaves the subnet |
| DHCP Server | Who handed out the address |
| DNS Servers | Why 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
| Mistake | Why it is wrong |
|---|---|
| Forgetting to subtract 2 | Network and broadcast are unusable |
| Assuming /24 always means 254 hosts | Only true for the specific /24 you are looking at |
| Confusing subnet mask with wildcard | Wildcard is the inverse — used in ACLs |
| Using the broadcast as a gateway | Never assignable to a host |
| Forgetting /31 and /32 exist | /32 is a single host, /31 is a point-to-point link |
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
Next
Port Testing — named directly in your JD.