• Post author:Bhaskar Soni
  • Post published:
  • Post category:Networking
  • Post comments:0 Comments
  • Reading time:4 mins read

When a router learns several paths to the same network, it has to pick one. Two values drive that choice: administrative distance and the routing metric. Administrative distance compares routes learned from different sources, such as a static route versus OSPF. The metric then compares paths learned from the same protocol.

This guide explains both, shows the default Cisco values and walks through real examples, including floating static routes.

administrative distance

How a router chooses a route

A router follows three rules in this order:

  1. Longest prefix match: the most specific route always wins. For example, 10.1.1.0/24 beats 10.1.0.0/16 for traffic to 10.1.1.5, whatever the source.
  2. Administrative distance: if two sources offer the same prefix, the lower administrative distance wins.
  3. Metric: if one protocol offers several paths to the same prefix, the lowest metric wins. Equal metrics can lead to load sharing.

Many learners forget rule 1. In fact, administrative distance only matters when the prefix length is identical.

What is a routing metric?

A metric is the value a routing protocol uses to rank its own paths. Each protocol measures “best” differently:

ProtocolMetricHow it works
RIPHop countCounts routers on the path; 16 means unreachable
OSPFCostReference bandwidth divided by interface bandwidth; lower is better
EIGRPComposite metricUses bandwidth and delay by default (load and reliability optional)
IS-ISMetricDefault of 10 per interface, set by the administrator
BGPPath attributesUses a decision process: weight, local preference, AS path and more

Because each protocol uses a different scale, you cannot compare an OSPF cost of 20 with a RIP hop count of 2. That is exactly why administrative distance exists.

OSPF cost example

By default, Cisco OSPF uses a reference bandwidth of 100 Mbps. As a result, a 100 Mbps link and a 10 Gbps link both get a cost of 1. To fix this, set a higher reference bandwidth on every OSPF router:

router ospf 1
 auto-cost reference-bandwidth 100000

Now a 10 Gbps link costs 10 and a 1 Gbps link costs 100.

What is administrative distance?

Administrative distance (AD) is a number from 0 to 255 that tells a router how trustworthy a route source is. Lower is more trusted. Moreover, it is local to the router and never sent to neighbours.

Default Cisco administrative distance values

Route sourceDefault AD
Connected interface0
Static route1
EIGRP summary route5
External BGP (eBGP)20
Internal EIGRP90
IGRP (obsolete)100
OSPF110
IS-IS115
RIP120
EGP (obsolete)140
On-Demand Routing (ODR)160
External EIGRP170
Internal BGP (iBGP)200
Unknown or unusable255

A route with AD 255 is never installed. Note that other vendors use different defaults. For example, Juniper gives OSPF internal routes a preference of 10.

Worked example

Suppose a router learns 172.16.0.0/16 from two sources:

  • OSPF, with a cost of 30.
  • RIP, with a hop count of 1.

The prefix length is the same, so the router compares AD. OSPF has 110 and RIP has 120. Therefore, the router installs the OSPF route, even though the RIP path looks shorter. You can confirm the choice with show ip route 172.16.0.0, which shows the AD and metric in brackets, such as [110/30].

Floating static routes

You can change the AD of a static route to create a backup path. For instance, this route only appears if the OSPF route disappears:

ip route 0.0.0.0 0.0.0.0 203.0.113.1 120

Here, the static route has an AD of 120. As a result, OSPF (110) wins while it is up. If the OSPF default route is lost, the static route “floats” into the routing table.

Changing administrative distance

You can also change the AD of a whole protocol. For example:

router ospf 1
 distance 105

However, change defaults carefully. Different AD values on different routers can create routing loops during redistribution.

Key takeaways

  • Longest prefix match comes first, then administrative distance, then metric.
  • Administrative distance compares sources; the metric compares paths within one protocol.
  • Lower values win in both cases.
  • Floating static routes use a higher AD to act as backups.

For more practice with Cisco configurations, try our ACL questions and answers.

Sources

Need help with network security? We test routers, firewalls, ACLs and segmentation as part of our VAPT services and hardening audits. Contact us for a quote.

Post author avatar

Bhaskar Soni

Bhaskar Soni is a Security Engineer and the founder of Youngster Company, based in Ahmedabad, Gujarat. He works hands-on with Linux server hardening, vulnerability assessment and penetration testing (VAPT), ISO 27001 compliance and OSINT investigations. He writes practical, tested guides for IT professionals and Indian businesses, and every article on this site is written or reviewed by him.

Leave a Reply