Interview questions
Explain what a subnet is and what /24 means.
How I'd answer:
"An IP address has a network part and a host part. The CIDR suffix says how many leading bits are the
network part. /24 means the first 24 bits identify the network and the last 8 bits identify the device,
so the subnet has 2⁸ = 256 addresses, 254 usable, because the all-zeros host address names the network
and the all-ones is broadcast. Devices in the same subnet talk directly on the local network; anything
outside goes through the default gateway. In the cloud, subnets are how you separate tiers — for example,
public subnets for load balancers and private subnets for app servers and databases."
Combines: Ch 4, 5, 7, 11.
Design the IP layout for a VPC with web, app and database tiers across two availability zones.
How I'd answer:
"I'd take a /16, like 10.0.0.0/16, which gives 65,536 addresses and room for 256 /24 subnets. First
I'd check it doesn't overlap with our office network or any other VPC we might peer with, because
overlapping ranges can never be connected.
Then six subnets, one per tier per zone: 10.0.1.0/24 and 10.0.2.0/24 public for load balancers, with a
default route to the internet gateway; 10.0.11.0/24 and 10.0.12.0/24 private for app servers;
10.0.21.0/24 and 10.0.22.0/24 private for databases. The gaps leave room to add subnets later. If we'll
run Kubernetes, I'd make the app subnets bigger, like /20, because every pod takes an IP. In AWS each
subnet loses 5 addresses to reservations, so a /24 gives 251."
Combines: Ch 5, 6, 7, 11. (The zone and load-balancer vocabulary is built out in DevOps (coming soon) and AWS (coming soon).)
Your laptop is connected to Wi-Fi but can't open any website. How do you debug it, layer by layer?
How I'd answer:
"I'd go bottom-up. First, do I have a real IP address? ipconfig getifaddr en0 — if it's 169.254.x.x,
DHCP failed, so the problem is between me and the router. If I have a normal address, can I reach my
gateway? ping 192.168.1.1 — if not, it's a local network issue. If the gateway works, can I reach a
public IP directly, like ping 8.8.8.8? If that works but websites don't, it's probably DNS — the
name-to-address lookup — which I'd check with nslookup google.com. If even the public IP fails,
traceroute 8.8.8.8 shows where the path stops: at my router, at the ISP, or beyond."
Combines: Ch 6, 7, 9 (and DNS from Networking 3: DNS, HTTP and HTTPS).
A packet goes from your laptop to a server across the internet. Which addresses change along the way?
How I'd answer: "The IP addresses — source and destination — stay the same end to end, because they identify the two endpoints. The MAC addresses change at every hop: MAC is link-layer, only meaningful on one LAN, so each router strips the old frame and builds a new one addressed to the next hop's MAC, which it finds with ARP. The TTL also decreases by one at each router. The one exception to 'IP stays the same' is NAT at the edge of a private network, which rewrites the source address — that's covered with transport."
Combines: Ch 2, 3, 7, 8.
What is longest prefix match?
How I'd answer:
"When a router has several routes that match a destination, it picks the most specific one — the route
with the longest prefix. If it has 10.0.0.0/8 and 10.1.0.0/16, a packet to 10.1.2.3 matches both,
and it uses the /16. The 0.0.0.0/0 default route matches everything but is the least specific, so it's
only used when nothing else matches. It's the same idea as sorting mail: a rule for a neighbourhood beats a
rule for the city."
Combines: Ch 5, 7.