IP addressing & routing

Computer Networks ยท 10 interview questions

An IPv4 address is 32 bits, split into a network portion and a host portion. CIDR notation writes the split explicitly โ€” /24 means the first 24 bits identify the network โ€” replacing the rigid old class system with arbitrary boundaries and far less waste.

Routers forward packets by longest prefix match: among all matching routes in the table, the most specific wins. Routing tables are built either statically or by protocols โ€” OSPF within an organisation, BGP between them, which is what makes the global internet cohere.

NAT exists because IPv4 addresses ran out. A router rewrites private source addresses to one public address, tracking the mapping by port so replies can be translated back. It works, but it breaks the end-to-end model and makes inbound connections awkward โ€” one of the main motivations for IPv6.

IP addressing & routing interview questions

What does /24 mean in CIDR notation?
The first 24 bits are the network portion, leaving 8 bits for hosts โ€” 256 addresses, of which 254 are usable since the first is the network address and the last is broadcast.
What is a subnet mask for?
It marks which bits are network and which are host. ANDing an address with the mask yields the network address, which is how a host decides whether a destination is local or must go via the gateway.
Which IPv4 ranges are private?
10.0.0.0/8, 172.16.0.0/12 and 192.168.0.0/16. They aren't routable on the public internet and are reused inside countless networks, which is why NAT is needed.
How does a router choose between overlapping routes?
Longest prefix match โ€” the most specific route wins. A packet matching both 10.0.0.0/8 and 10.1.2.0/24 follows the /24, because more matching bits means a more precise route.
How does NAT work?
The router rewrites the private source address to its public one and records the mapping, usually keyed by source port. Replies are matched against the table and rewritten back. Many hosts share one public address.
Why are inbound connections hard through NAT?
The mapping is created by outbound traffic, so there's no entry for an unsolicited inbound packet and the router doesn't know which internal host to send it to. Port forwarding, UPnP or hole punching work around it.
What does the TTL field do?
It's decremented by each router and the packet is discarded at zero, which stops packets circulating forever in a routing loop. Traceroute exploits it by sending packets with increasing TTLs to reveal each hop.
What does IPv6 change beyond address length?
128-bit addresses remove the need for NAT, the header is simplified and fixed-length for faster forwarding, fragmentation is pushed to endpoints, and address autoconfiguration is built in.
What's the difference between OSPF and BGP?
OSPF is an interior protocol, routing within one organisation by computing shortest paths from a shared link-state map. BGP is exterior, routing between organisations by exchanging paths and applying policy โ€” the best BGP route is often chosen for business reasons, not distance.
What is IP fragmentation and why is it avoided?
Splitting a packet too large for a link's MTU into fragments reassembled at the destination. Losing one fragment destroys the whole packet, and it complicates firewalls, so path MTU discovery is preferred.

You'll forget most of this by next week

That's not a discipline problem, it's how memory works. In the app these come back on an expanding schedule โ€” right before you'd lose them.

Start free for 7 days