3.2 Determine how a router makes a forwarding decision by default

3.2.a Longest match

3.2.b Administrative distance

3.2.c Routing protocol metric

Let’s say that my router has three active routes

  • 10.5.5.0/24 via 11.11.11.1
  • 10.5.5.0/25 via 11.11.11.2
  • 10.5.5.7/32 via 11.11.11.3

These routes overlap somewhat.

  • 10.5.5.0/24 has a range from 10.5.5.0 to 10.5.5.254
  • 10.5.5.0/25 has a range from 10.5.5.0 to 10.5.5.127
  • 10.5.5.7/32 has a range of a single IP address – 10.5.5.7

If my router receives a packet addressed to 10.5.5.253, which route will it choose?  It will choose the route via 11.11.11.1 because that is the only applicable route.  What if my router receives a packet addressed to 10.5.5.7?  Which route will it choose?  All three routes are applicable, but the router will choose the route through 11.11.11.3. 

Why?  When there are overlapping routes, the router will choose the most specific route.  That is the route with the narrowest network.  This is known as the longest match forwarding decision because the router is selecting the route with the longest network prefix.

The router gives each route an administrative distance.  The administrative distance is a measure of how much the router trusts the source that it learned the route from.

Below is a table that summarizes the administrative distance of each route source (also known as the default distance).  The router learns routes from other routers through protocols such as EIGRP, BGP, or OSPF.

Route SourceDefault Distance Values
Connected interface0
Static route1
Enhanced Interior Gateway Routing Protocol (EIGRP) summary route5
External Border Gateway Protocol (BGP)20
Internal EIGRP90
IGRP100
OSPF110
Intermediate System-to-Intermediate System (IS-IS)115
Routing Information Protocol (RIP)120
Exterior Gateway Protocol (EGP)140
On Demand Routing (ODR)160
External EIGRP170
Internal BGP200
Unknown255

The router will choose the route with the shortest distance.  A router does not believe routes that have a distance of 255 and will not route traffic to them.  As we will learn, we can manually change the administrative distance.  We might want a router to prioritize the use of a route learned from a neighboring router.

Going back to my active routes.  Let’s pretend that

  • 10.5.5.0/24 via 11.11.11.1 has a distance of 1
  • 10.5.5.0/25 via 11.11.11.2 has a distance of 5
  • 10.5.5.7/32 via 11.11.11.3 has a distance of 20

My router receives a packet addressed to 10.5.5.7.  Which route does it choose?  It still chooses 11.11.11.3 (with an administrative distance of 20).  Why?  The router always gives priority to the route with the longest prefix.  If we have multiple routes with the same prefix length, for example

  • 10.5.5.7/32 via 11.11.11.1 has a distance of 1
  • 10.5.5.7/32 via 11.11.11.2 has a distance of 5
  • 10.5.5.7/32 via 11.11.11.3 has a distance of 20

Then it would choose the route with the shortest distance.

What if I have three routes with the same prefix length and the same administrative distance?  Let’s say that the router learned three different routes to the same network via the BGP protocol.  Which one does the router choose?

  • 10.5.5.7/32 via 11.11.11.1 has a distance of 20
  • 10.5.5.7/32 via 11.11.11.2 has a distance of 20
  • 10.5.5.7/32 via 11.11.11.3 has a distance of 20

Well, the protocol must assign a metric to each route.  The metric tells us how efficient the route is.  There are two common ways to measure efficiency – the speed of the connection or the number of routers or “hops” that a packet must pass through in order to reach its destination.

  • 10.5.5.7/32 via 11.11.11.1 has a distance of 20 and a metric of 5
  • 10.5.5.7/32 via 11.11.11.2 has a distance of 20 and a metric of 7
  • 10.5.5.7/32 via 11.11.11.3 has a distance of 20 and a metric of 14

In this case, the router would choose the route via 11.11.11.1 because it has the shortest metric and because the prefix length and administrative distance tied with the other two routes.

We will learn more about administrative distances and routing protocols later in this section.