skip to content

Two subnets in one private network reach the internet differently — which route table decides that for each subnet?

level: middleimportance: should knowfreq 50%

answer

  1. association first, entries second
  2. one effective table per subnet
  3. not evaluated top to bottom
  4. longest matching prefix wins
  5. default route is the least specific

basics

~20 s

The one table effective for that subnet decides: either a table explicitly associated with it, or the network's default table where nothing was associated. Within a table the most specific matching destination wins, and the default route is simply the least specific entry.

solid answer

~40 s

Exactly one route table is in effect for a subnet at a time. Platforms differ in where routing attaches — some attach a table per subnet, some attach routing at the network level and let a subnet override it — but the effective table is either one explicitly associated or the network's default. So two subnets in one network can behave completely differently: one table may send everything unmatched to the network's internet-facing attachment, another to an address-translating gateway, another nowhere at all. Lookup is by longest match, not by order in the list, so a more specific entry for a partner's range always beats the default route. When filters are identical and behaviour differs, compare associations first, then entries.

code

json · 17 lines
json
[
  {
    "table": "routed-side",
    "routes": [
      { "destination": "10.20.0.0/16", "target": "local" },
      { "destination": "0.0.0.0/0",    "target": "internet-attachment" }
    ]
  },
  {
    "table": "isolated-side",
    "routes": [
      { "destination": "10.20.0.0/16",   "target": "local" },
      { "destination": "198.51.100.0/24", "target": "partner-circuit" },
      { "destination": "0.0.0.0/0",       "target": "translating-gateway-zone-a" }
    ]
  }
]

go deeper

for a junior

Recall that routing belongs to the subnet, not the machine, and that a default route is the entry catching every destination nothing more specific matched.

for a middle

Explain the two rules crisply: association selects the effective table, longest prefix match selects the entry. Be able to say why order in the list is irrelevant.

for a senior

Diagnose in the right order — effective association, then entries, then the health of the target — and treat a shared table as a shared blast radius with a finite entry budget.

for a principal

Own the convention: tables split by routing intent rather than by team, explicit associations in everything provisioned, and a named owner for any entry that sends traffic out a non-default door.

## What a route table actually is A route table is a set of entries, each pairing a **destination prefix** with a **target** — the door a packet matching that prefix leaves by. Typical targets are local delivery inside the network, the network's internet-facing attachment, an address-translating gateway, a link to another network, or a dedicated circuit. Two rules govern it, and both are worth stating explicitly in an interview: - **Association decides which table applies.** A subnet has one effective table. Either you associated one with it, or it uses the network's default — and which of those two is the norm differs by platform, which is exactly why you check rather than assume. - **Longest match decides which entry applies.** The table is not evaluated top to bottom. Every entry whose prefix contains the destination is a candidate, and the most specific one wins. The default route, covering all destinations, is therefore the fallback that catches whatever nothing else matched. ## Why two subnets in one network diverge They diverge because association is per subnet, which is the whole point of the design. A common estate has three shapes in one address range: 1. **A routed subnet** whose table sends unmatched destinations to the network's internet-facing attachment. Workloads here can be reachable and can call out directly. 2. **A translated subnet** whose table sends unmatched destinations to an address-translating gateway. Workloads here call out but cannot be called. 3. **An isolated subnet** whose table carries only the local range. Nothing leaves. Same network, same address plan, three different behaviours — decided entirely by which table each subnet is associated with. That is also the failure mode: a new subnet created without an explicit association silently inherits the network's default table, and whether that default is permissive or bare differs by platform. ## Diagnosing a divergence When two subnets should behave alike and do not, work in this order: 1. **Which table is effective for each subnet?** Not which table someone edited — which one is actually associated. Editing the wrong table is the single most common cause of a change that appears to do nothing. 2. **Do the entries differ?** Compare them side by side, including the more specific ones. A single extra entry for one partner's range sends only that partner's traffic somewhere else, which is why the symptom is often absurdly narrow. 3. **Is the target itself healthy and reachable?** A route pointing at a gateway whose own subnet has no outward route is a valid entry to a dead end. ## The blast radius of a shared table One table associated with many subnets is convenient and is a shared fate: an entry added for one team's partner integration changes the exit door for every subnet associated with it. A route table has a finite number of entries on every platform, so a shared table also accumulates toward that ceiling. Splitting tables by **routing intent** — routed, translated, isolated, partner-facing — rather than by team keeps each table small, keeps its purpose legible, and makes a change reviewable, because the reviewer can see which subnets are affected by reading one association list. ## What routing does not decide - **It does not decide permission.** An entry creates a path. Whether a packet is allowed along that path is a separate filtering decision, and whether the caller may use the service is a third, at the application. - **It does not decide the source address.** That is a property of the target: a translating gateway rewrites it, a direct attachment does not. - **It does not fix itself.** Routing is stated, not discovered: nothing in the platform notices that a subnet is unreachable and adds the missing entry. The answer an interviewer is listening for is two sentences: association picks the table, longest match picks the entry — and then the discipline of checking the effective association before reading any entries.

  • In the second table above, where does traffic to 198.51.100.7 go, and why?
    Out through the partner circuit. Both the /24 and the all-destinations entry contain that address, and the most specific match wins regardless of the order the entries appear in. Everything outside that range still takes the translating gateway.
  • Two teams share one route table and a change for one breaks the other. What is the structural fix?
    Split tables by routing intent — routed, translated, isolated, partner-facing — and associate each subnet with the one matching its purpose. Associations are cheap, and a small table with a stated purpose is reviewable in a way a shared one with accumulated entries is not.
  • A subnet is created and nobody associates a table with it. What governs its traffic?
    The network's default table, which is what a subnet falls back to when no association is made. Whether that default is permissive or carries only the local range differs by platform, so treat it as something to verify rather than assume, and associate explicitly in anything you automate.

saying these in an interview costs you the question

  • Thinks route entries are evaluated in list order
  • Says a subnet can have several tables in effect at once
  • Edits a table without checking which subnets it serves
  • Assumes a new subnet inherits nothing and is isolated
  • Believes a route entry also grants permission