Free tech learning for everyone, from basics to pro

Routing & SwitchingNetworking SecurityBeginner

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:

  1. Prefix length: "Which route in the table matches this destination most specifically?" A /27 always beats a /24, whatever their sources.
  2. Administrative distance (AD): "Two sources offer the same prefix. Which source do I trust more?"
  3. Metric: "One protocol offers several paths to the same prefix. Which is best?"
How a router chooses one routeLongest prefixmost specific winsAdministrativedistancemost trusted sourceMetricbest within aprotocolEqual costload share (ECMP)
Figure 1. Prefix length is compared at forwarding time; AD and metric decide what gets into the table in the first place.

Default administrative distances on Cisco IOS

SourceAD
Connected interface0
Static route1
EIGRP summary route5
External BGP (eBGP)20
Internal EIGRP90
OSPF110
IS-IS115
RIP120
External EIGRP170
Internal BGP (iBGP)200
Unusable255

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 150 under OSPF, or distance eigrp 90 160 under 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-NAME changes 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?
The RIP /24, because the longest prefix match is chosen first, regardless of administrative distance.
What is the default AD of eBGP and iBGP routes on Cisco IOS?
eBGP 20, iBGP 200.
How do you make a static route act only as a backup?
Give it a higher administrative distance than the dynamic route, making it a floating static route.

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.
Tracks your learning on this device only. See your progress on the learning paths.
Verified author✓ Valid
Issued to
Mohamed Fayas
Role
Founder of FM TecHub
Credentials
CCNABTEC HND Network EngineeringBEng (Hons) Computer Networking & Cloud Security
Issuer
FM TecHub · fmtechub.com

He writes practical, plain-English guides on networking, security and cloud.

More about the author →

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.

Email updates: coming soon

New notes, tools and security news from FM TecHub by email, explained simply. Free. We're not collecting email addresses yet; see our privacy policy.

PortServiceStatus
SMTP/25Email updatesopening soon

Meanwhile, stay connected: