Administrative distance and route selection: how a router picks between OSPF, EIGRP, static and BGP routes
In short: When two routing sources offer the same prefix, the router installs the one with the lowest administrative distance. Within one protocol, the lowest metric wins. At forwarding time the longest matching prefix is always used first. Getting these three ideas in the right order explains most "why did it pick that route?" questions.
Three different questions
Students often mix up three things a router uses to choose a path. They answer different questions:
- Prefix length: "Which route in the table matches this destination most specifically?" A /27 always beats a /24, whatever their sources.
- Administrative distance (AD): "Two sources offer the same prefix. Which source do I trust more?"
- Metric: "One protocol offers several paths to the same prefix. Which is best?"
Default administrative distances on Cisco IOS
| Source | AD |
|---|---|
| Connected interface | 0 |
| Static route | 1 |
| EIGRP summary route | 5 |
| External BGP (eBGP) | 20 |
| Internal EIGRP | 90 |
| OSPF | 110 |
| IS-IS | 115 |
| RIP | 120 |
| External EIGRP | 170 |
| Internal BGP (iBGP) | 200 |
| Unusable | 255 |
Other vendors use different values. Juniper, for example, calls it route preference and uses 10 for OSPF internal routes and 170 for BGP. In a mixed network, never assume the same source wins on both sides.
Seeing it in the table
In show ip route, the numbers in square brackets are [AD/metric]. For example O 10.20.0.0/16 [110/3] via 10.0.0.2 is an OSPF route with AD 110 and cost 3. Only the winning source appears in the routing table; the losers stay in their own protocol databases, ready to take over.
Changing administrative distance
- Floating static routes: add a distance to the end of a static route, such as
ip route 0.0.0.0 0.0.0.0 192.0.2.1 250, so it only appears when the dynamic route disappears. - Per protocol:
distance ospf external 150under OSPF, ordistance eigrp 90 160under EIGRP, changes the values for that process on this router only. - Per source or prefix:
distance 95 10.0.0.2 0.0.0.0 ACL-NAMEchanges the AD of selected routes learned from one neighbour.
Change AD sparingly and document it. Because it is local to one router, uneven changes are a classic cause of routing loops during redistribution.
Real-world example: the backup link that won
A company had OSPF across its MPLS WAN and added a site-to-site VPN as backup, running EIGRP over the tunnel. Within minutes all branch traffic shifted to the slow VPN. Internal EIGRP routes (AD 90) beat the OSPF routes (AD 110) for the same prefixes. The fix was to run OSPF over the tunnel too, with a higher cost, so both paths were compared by metric inside one protocol.
Practice
A router learns 10.5.0.0/16 from OSPF and 10.5.1.0/24 from RIP. Which route is used for traffic to 10.5.1.20?
What is the default AD of eBGP and iBGP routes on Cisco IOS?
How do you make a static route act only as a backup?
Key takeaways
- Longest prefix match decides forwarding; AD and metric decide what enters the table.
- Lower administrative distance means a more trusted routing source.
- Common Cisco defaults: static 1, eBGP 20, EIGRP 90, OSPF 110, iBGP 200.
- AD is local to each router; change it carefully and document why.
Original content written by Mohamed Fayas for FM TecHub. © 2026 FM TecHub. You're welcome to share a link to this page; please don't copy the text elsewhere without permission.