First, the longest prefix match wins: a /24 route beats a /16 for an address inside both, whatever their source. If routes to exactly the same prefix come from different sources, the router prefers the more trusted source, which many vendors call administrative distance, so a static route usually beats OSPF. Within one protocol, the lowest metric wins, and equal-cost routes can share the traffic.
Why interviewers ask this
Route selection explains a lot of surprising behaviour, such as traffic ignoring a preferred path or a backup route taking over. Candidates often get the order wrong, assuming administrative distance beats prefix length. Getting the order right, prefix length first, then source preference, then metric, shows you can predict what a router will actually do, which is essential when designing redundancy or troubleshooting.
How to structure your answer
- Explain longest prefix match first.
- Explain source preference, or administrative distance.
- Explain metrics within a protocol.
- Mention equal-cost multipath and a practical example.
Example answer
There are really two stages. When a packet arrives, the router forwards it using the most specific matching route in its table, so if it has 10.0.0.0/8 and 10.1.2.0/24, traffic to 10.1.2.5 follows the /24, wherever either route came from. That is the longest prefix match rule. The second stage decides what goes into the table in the first place. If the router learns exactly the same prefix from more than one source, it prefers the most trusted one. On many platforms that is called administrative distance: directly connected is best, then static, then protocols such as external BGP, OSPF and internal BGP in a set order. Within a single protocol, the metric decides, so OSPF picks the lowest-cost path, and if two paths have equal cost, the router can install both and share traffic across them. Getting the order right matters in practice. I once found a backup static route that someone had added with a more specific prefix, and it quietly pulled traffic away from the primary OSPF path, because the more specific route always wins.
Walking into this interview soon? GhostPilot listens to your live call, spots the question the moment it is asked, and puts a structured answer on your screen in real time. Try it on your next mock, or grab a $29 Session Pass, no subscription, for the real thing.
See how it worksFollow-up questions to expect
- What is a floating static route, and how does it rely on this order?
- How does equal-cost multipath decide which flow uses which path?
- What would happen if you redistributed a default route into OSPF?
Related network engineer questions
Your interviewer will ask their own version of this. Paste your actual job description into the free Question Predictor and get the 20 questions that role is most likely to ask, with what each one is really probing.
Predict my questions