Administrative Distance: How a Router Picks Between Two Sources for One Route
A router may learn the same destination from several places at once — a static route, OSPF, and BGP all offering a path to the same network. Their metrics are not comparable, since a hop count and an OSPF cost measure different things. Administrative distance is the tiebreaker: a number expressing how much the router trusts each source, with lower being more trusted.
The values to know
Directly connected interface: 0. Static route: 1. External BGP: 20. Internal EIGRP: 90. OSPF: 110. IS-IS: 115. RIP: 120. External EIGRP: 170. Internal BGP: 200. Unknown or untrusted: 255, which means the route is never installed.
The ordering encodes a judgement about reliability. A directly connected interface is fact. A static route was configured deliberately by an administrator, so it is trusted next. Among dynamic protocols, those carrying richer information rank above simpler ones, which is why OSPF beats RIP.
Two values reward attention. External BGP at 20 is more trusted than any interior protocol, which surprises people — the reasoning is that a route learned from another autonomous system describes territory your interior protocol has no business claiming. Internal BGP at 200 is the least trusted of the routing protocols, because an iBGP route has already been learned from outside and redistributed internally, so a local interior protocol route to the same prefix is more likely to be correct.
Prefix length comes first
The most important rule in the topic, and the one that trips people up.
Administrative distance only applies when two sources offer routes to the same prefix with the same length. Before AD is consulted at all, the router performs longest prefix match: a more specific route always wins, whatever its source.
So a /24 learned via RIP, administrative distance 120, beats a /16 learned via a static route with distance 1, because /24 is more specific. They are not competing — they are different destinations as far as the forwarding decision is concerned, and both sit in the table simultaneously.
The order is therefore: longest prefix match, then administrative distance, then the protocol's own metric between routes from the same source.
Floating static routes
The practical application worth knowing. A static route configured with a deliberately raised administrative distance — above that of the dynamic protocol covering the same destination — sits inactive while the dynamic route exists.
If the dynamic route disappears because the primary path failed, the static route is the best remaining candidate and installs automatically. When the dynamic route returns, it wins again and the static route steps back.
This is the standard way to configure a backup path over a secondary link or a cellular connection. Set the distance above the primary protocol's — a static route at 130 behind an OSPF-learned route at 110, for instance — and the failover requires no scripting and no intervention. It complements rather than replaces gateway redundancy at the first hop, which is the job of FHRP.
Troubleshooting with it
The classic symptom is a route you configured that does not appear in the routing table. Check whether something with a lower administrative distance is offering the same prefix — the route is there, in the routing information base, simply not selected.
The dangerous version is redistribution. When routes are redistributed between protocols, a route can be learned back from the protocol it was injected into, and if the administrative distances line up badly the router may prefer the returned copy over the original. That produces routing loops and suboptimal paths, and it is why redistribution points need route tagging and filtering — the same family of concerns that split horizon addresses within a single protocol.
Note that administrative distance is local to the router. It is not advertised and does not influence neighbours. Changing it on one device affects only that device's selection, which means inconsistent changes across a network produce asymmetric routing that is genuinely unpleasant to diagnose.
Values also vary slightly between vendors, so check the platform rather than assuming. Note too that administrative distance decides between sources only within one router — choosing between external paths by cost or contract is a policy question handled by BGP.
Exam angles
Know that administrative distance ranks trust in the route source, lower being preferred, and memorize connected 0, static 1, eBGP 20, EIGRP 90, OSPF 110, RIP 120, iBGP 200 and 255 as never installed. Understand that longest prefix match is evaluated before administrative distance, and the protocol metric only between routes from the same source. Recognize a floating static route as one with an increased distance acting as an automatic backup, and know that administrative distance is local and not advertised.
Comments
Post a Comment