Course contents

Chapter 8: RoutingLesson 3 of 16

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

Technical definition

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.

Two tie-breakers: AD and metric

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

Installation and forwarding are different decisions

Diagram
Build the routes first; choose a matching route when the packet arrives
Build the routes first; choose a matching route when the packet arrives
Build the routes first; choose a matching route when the packet arrivesFor the same prefix 192.168.3.0/24, default OSPF administrative distance 110 is preferred over RIP 120, assuming usable routes. The installed /24 can coexist with an installed static /16. Packet forwarding then selects the matching /24 rather than /16, even though the static /16 has lower administrative distance.1 · Route installationSame prefix: 192.168.3.0/24OSPF AD 110 vs RIP AD 120Prefer usable OSPF /24AD compares sources for this prefix.2 · Packet forwardingDestination: 192.168.3.10Installed /16 and /24 both matchUse /24: longest matching prefixDo not compare AD again per packet.Lower AD does not make a shorter prefix win.A static /16 and an OSPF /24 can both be installed.
A simplified route-source comparison. Protocol best-path rules and usable next-hop checks apply before installation. Metrics from different protocols are not compared as one common scale.

Each protocol selects candidate paths using its own rules. For the same prefix, administrative distance helps the routing table choose between sources. Usable equal-cost paths may be installed when the protocol and configured multipath limits allow it.

Diagram
R1 hears about 192.168.3.0/24 two ways
R1 hears about 192.168.3.0/24 two ways
10.0.12.0/3010.0.23.0/3010.0.13.0/30 (backup)PC1IP 192.168.1.10R1R2R3ServerIP 192.168.3.10

Device key: PC1 (computer) · R1, R2, R3 (router)

Lines show the example’s network connections. Thick links: uplinks/WAN, as labelled. The coloured path and envelope follow the current step; its text identifies the sender, receiver and traffic type.

Reading the addresses

IP labels identify interfaces or destinations. Subnet labels identify networks; /n is the prefix length. A router ID (RID) identifies a routing process and need not be a reachable interface.

An IP address alone is not a URL. A web URL includes a scheme such as https://; an address on a router or printer does not imply a website.

  • PC1: IP 192.168.1.10
  • Server: IP 192.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 a RIP hop can't be weighed against an OSPF cost

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.

In practice, AD earns its keep during migrations. When a second routing protocol is switched on next to the old one, the source with the lower AD quietly takes over every prefix both of them know, which is worth predicting before the change rather than discovering after.

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.

Finding [AD/metric] in the routing table

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.

Test yourself on AD and metrics

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?

Cisco reference: Route installation, administrative distance and forwarding.