JuniorNetworking

How does a host decide where to send a packet? Explain routing tables, the default gateway, and longest-prefix match.

What they are really testing: Whether you understand the basic forwarding decision every device makes. Misconfigured routes and missing default routes are a common cause of "the instance has no internet".

A real interview question

How does a host decide where to send a packet? Explain routing tables, the default gateway, and longest-prefix match.

What most people say

drag me

The packet goes to the router and the router sends it to the internet.

It skips the decision logic entirely: the routing-table lookup, local-versus-remote, the default route, and longest-prefix match. That logic is exactly what you need when an instance cannot reach the internet.

The follow-ups they ask next

  • An instance in a subnet cannot reach the internet though the security group is open. What route do you check?

    The subnet route table: it needs a 0.0.0.0/0 route to an internet gateway (public) or NAT gateway (private). No default route means no path out.

  • Two routes match a destination, a /16 and a /24. Which is used?

    The /24: longest-prefix match always picks the most specific route, regardless of order.

What the interviewer is listening for

  • Describes the routing-table lookup
  • Knows 0.0.0.0/0 is the default route
  • Knows longest-prefix match picks the most specific

What sinks the answer

  • "It just goes to the router"
  • Unaware of the default route concept
  • Thinks route order, not specificity, decides

If you genuinely do not know

Say this instead of freezing. Reasoning out loud from what you do know beats silence every single time, and a good interviewer is listening for exactly that.

The host [looks up the destination in its routing table]. If it is [on the same subnet it delivers directly via ARP], otherwise [it sends to a router]. The [default route 0.0.0.0/0 points at the gateway and catches everything unmatched]. When routes overlap, [longest-prefix match wins, most specific route]. For a no-internet instance I check [the subnet has a 0.0.0.0/0 route to an internet/NAT gateway].

Keep going with networking

All 336 cloud engineer questions

Knowing the answer is not the same as recalling it under pressure

Sign in to send the questions you fumble to spaced recall, so they come back right before you would forget them, and learn the concepts behind them with hands-on labs.

Start free