Routelearn.net
Course menu

Course 8: RoutingLesson 1.4 (3 of 12 in this course)52 of 91 in the CCNA series

Administrative distance and metric

How a router chooses between routes learned from different sources, and between paths from the same source.

Intermediate · 7 min read

Administrative distance (AD) is a value from 0 to 255 that a router uses to rank how trustworthy a route's source is when it learns the same prefix from more than one source; the lowest value wins. The metric is then used to choose between routes from the same source.

In simple terms: If two sources give the router different directions to the same place, it believes the one it trusts more. A lower number means more trust.

A real-life situation

You ask two people for directions. One is a local taxi driver; the other is a tourist. Even if the tourist's route sounds shorter, you trust the taxi driver. Then, if the taxi driver gives you two routes, you take the shorter one. A router does exactly this, in that order.

What they are

Sometimes a router learns the same prefix (same network, same length) in more than one way. It needs a tie-breaker. There are two:

  • Administrative distance (AD): how much the router trusts the source of a route. It is a number from 0 to 255. Lower is better. It compares routes from different sources, for example a static route against an OSPF route.
  • Metric: the "cost" of a path, calculated by one routing protocol. Lower is better. It compares paths learned from the same protocol. Each protocol measures it differently.
Route sourceDefault ADMetric it uses
Connected0-
Static10
eBGP (external BGP)20Path attributes, not one number
EIGRP (internal)90Bandwidth and delay
OSPF110Cost, based on bandwidth
IS-IS115Cost
RIP120Hop count (number of routers)
EIGRP (external)170Bandwidth and delay
iBGP (internal BGP)200Path attributes
Unknown / unreachable255Never used

The order of decisions

  1. Longest prefix match picks which network to use (the “Longest prefix match” lesson).
  2. If several sources offer that exact prefix, the lowest AD goes into the routing table.
  3. If one protocol offers several paths, the lowest metric wins.
  4. If metrics are equal, the router keeps both paths and shares traffic across them. This is called equal-cost multi-path (ECMP).
10.0.12.0/3010.0.23.0/3010.0.13.0/30 (backup)PC1192.168.1.10R1R2R3Server192.168.3.10
  1. 1. Via R2, from OSPF: R1 learns 192.168.3.0/24 through R2 with AD 110.
  2. 2. Via the backup link, from RIP: the same /24, one hop away, but RIP's AD is 120. Fewer hops doesn't help: different sources are compared by AD only.
  3. 3. Result: the OSPF route is installed. The RIP route waits in the background and is used only if the OSPF route disappears.

Why it works this way

Metrics can't be compared across protocols. An OSPF cost of 3 and a RIP hop count of 1 measure different things, like comparing kilometres with minutes. So the router first asks "which source do I trust?", using AD, and only then "which path is cheapest?", using the metric from that one source.

The default values follow a simple idea: the more the router knows first-hand, the more it trusts the route. A connected network (AD 0) is a fact. A route someone typed in (AD 1) is a strong statement. Routes heard from protocols come next.

You can change the AD of a static route by adding a number at the end of the command. The “Floating static routes” lesson uses this to build a backup route that stays hidden until it's needed.

How to verify it

Both numbers appear in brackets as [AD/metric]. This output is based on Cisco documentation, not run on a lab device.

Example output · based on Cisco documentation; exact format varies by platform and software version
R1#show ip route 192.168.3.0
Routing entry for 192.168.3.0/24
  Known via "ospf 1", distance 110, metric 3, type intra area
  Last update from 10.0.12.2 on GigabitEthernet0/1, 00:12:31 ago
  Routing Descriptor Blocks:
  * 10.0.12.2, from 3.3.3.3, 00:12:31 ago, via GigabitEthernet0/1
      Route metric is 3, traffic share count is 1
"distance 110" is the AD, "metric 3" the OSPF cost. In the full table the same route reads O 192.168.3.0/24 [110/3] via 10.0.12.2. The RIP route doesn't appear at all, because only the winner is installed.

Check yourself

Predict · scenario 1

R1 has a static route and an OSPF route for exactly 10.5.0.0/16. Which is installed?

Predict · scenario 2

OSPF offers two paths to the same network: cost 20 and cost 20. What does the router do?

Predict · scenario 3

OSPF offers 10.1.0.0/16 and RIP offers 10.1.1.0/24. Where does a packet to 10.1.1.9 go?