An IP address is the layer-3 identity of a host. Understanding how addresses are structured, how subnetting carves a network into smaller blocks, and how routing moves a packet across many networks is core networking knowledge that interviewers use to test whether you can reason with binary and CIDR math, not just recite definitions.
IPv4 structure
An IPv4 address is 32 bits, written as four dotted decimal octets, e.g. 192.168.10.5. Each octet is 8 bits, so values run 0–255. An address is split into a network portion and a host portion; the boundary is set by the subnet mask.
255.255.255.0in binary is11111111.11111111.11111111.00000000— the first 24 bits are network, the last 8 are host.- In CIDR notation this is written
/24: the number after the slash is how many leading bits are the network prefix.
Private vs public ranges
Certain ranges are reserved for private networks (RFC 1918) and are not routable on the public internet — they are what NAT translates:
| Range | CIDR | Size | |-------|------|------| | 10.0.0.0 – 10.255.255.255 | 10.0.0.0/8 | ~16.7M | | 172.16.0.0 – 172.31.255.255 | 172.16.0.0/12 | ~1M | | 192.168.0.0 – 192.168.255.255 | 192.168.0.0/16 | 65,536 |
Also worth knowing: 127.0.0.0/8 is loopback (localhost), 169.254.0.0/16 is link-local (APIPA), and 0.0.0.0/0 means "any address" / the default route.
Subnetting math
Given a CIDR block, three numbers matter and interviewers will ask you to compute them by hand:
- Number of host bits =
32 − prefix. - Total addresses in the block =
2^(host bits). - Usable hosts =
2^(host bits) − 2(subtract the network address and the broadcast address).
The network address is all host bits set to 0; the broadcast address is all host bits set to 1.
Worked example: 192.168.10.0/26
Try it live — edit the CIDR and watch the mask, network, broadcast, host range, and host count update:
Subnet calculator
Type any IPv4 CIDR to see how it splits.
- Network address
- 192.168.10.0/26
- Broadcast address
- 192.168.10.63
- Usable host range
- 192.168.10.1 – 192.168.10.62
- Subnet mask
- 255.255.255.192
- Wildcard mask
- 0.0.0.63
- Total addresses
- 64
- Usable hosts
- 62
Let us do the /26 by hand:
Prefix = 26 bits network, 6 bits host
Mask = 255.255.255.192 (11111111.11111111.11111111.11000000)
Block size = 2^6 = 64 addresses per subnet
Subnets of the 4th octet: .0, .64, .128, .192
For 192.168.10.0/26:
Network = 192.168.10.0
First host = 192.168.10.1
Last host = 192.168.10.62
Broadcast = 192.168.10.63
Usable hosts = 64 - 2 = 62
The trick for the "which subnet does this IP belong to?" question: the block size (64 here) is the increment. 192.168.10.100 falls in the .64–.127 block, so its network is 192.168.10.64/26 and broadcast is 192.168.10.127.
VLSM
Variable Length Subnet Masking lets you carve one block into subnets of different sizes, allocating the largest first. If you have a /24 and need subnets for 100, 50, and 10 hosts, you assign a /25 (126 hosts), then a /26 (62 hosts), then a /28 (14 hosts) from the remaining space — no waste from forcing equal sizes.
Routing basics
A router forwards packets toward their destination using a routing table. Each entry maps a destination CIDR prefix to a next hop (and outgoing interface). The forwarding decision uses longest prefix match: among all entries whose prefix contains the destination, the router picks the most specific (longest prefix).
Destination Next Hop Interface
10.0.0.0/8 192.168.1.1 eth0
10.5.0.0/16 192.168.1.2 eth1
0.0.0.0/0 192.168.1.254 eth0 (default route)
A packet to 10.5.3.7 matches both 10.0.0.0/8 and 10.5.0.0/16; longest prefix match chooses the /16. Anything not matched elsewhere follows the default route 0.0.0.0/0.
- Static routing: entries configured by hand — predictable, but no automatic failover.
- Dynamic routing: protocols exchange reachability. OSPF (link-state, intra-domain) and BGP (path-vector, the protocol that glues the internet's autonomous systems together) are the two names to know.
NAT: how private hosts reach the internet
Network Address Translation lets many private hosts share one public IP. The router rewrites the source IP (and port, for PAT/overload) on the way out and reverses it on the way back, keeping a translation table keyed by the 4-tuple. This is why your laptop's 192.168.x.x can browse the web even though that range is not globally routable — and a big reason IPv4 has survived address exhaustion.
IPv6 in one breath
IPv6 uses 128-bit addresses written as eight groups of hex, e.g. 2001:0db8:85a3::8a2e:0370:7334 (:: compresses one run of zero groups). It removes the need for NAT (the address space is effectively unlimited), bakes in autoconfiguration (SLAAC), and drops broadcast in favor of multicast.
In the interview
- Be fluent with CIDR ↔ mask ↔ host count.
/24= 256 addresses / 254 hosts; each extra bit halves the block. - Compute network, broadcast, and usable range for a given CIDR without hesitation.
- Explain longest prefix match for the forwarding decision, and name OSPF vs BGP.
- Tie NAT to IPv4 exhaustion and private ranges — a very common follow-up.