This article covers a topic that is quite foundational to networking knowledge but, surprisingly, there has not been any previous articles on the subject on this site; so here goes.

In this article, we will consider how a Cisco router chooses which interface or next-hop address to forward a packet through/to. We will also look at classless/classful route forwarding.

CCNA Training – Resources (Intense)

Factors that Affect Route Selection

To begin this article, we need to familiarize ourselves with some concepts that affect how a router will select the best path to forward traffic through.

Administrative Distance

The first on the list is Administrative Distance. Administrative Distance talks about the trustworthiness of the source of a route. Just like you will believe news received from some news outlets more than others, in the same way a router will believe some route sources more than others. The lower the Administrative Distance, the more trustworthy the source of a route is.

The table below shows a list of the Administrative Distance for common route sources:

Source of route Default Administrative Distance
Connected

0

Static

1

External BGP

20

Internal EIGRP

90

OSPF

110

Although the Administrative Distance is a configurable value, most times we just leave the default values the way they are.

Metric

While Administrative Distance relates to several routing sources, metric has a scope within an individual routing source. A routing protocol that receives the same network information from multiple sources will rely on the metric to choose the best path – the lower the metric, the better the route.

Prefix length

Prefix length is just another way of representing the subnet mask. For example, 255.255.255.0 is represented as /24.

How the Routing Table Is Built

Each routing process running on the router performs its own best path selection for every destination network it receives information about. For most routing protocols, the metric is used to determine the best path. For example, if a router running EIGRP receives two advertisements for the 192.168.10.0/24 network, it will choose the path with the lowest metric as the best path.

Note: BGP uses a complex process to select the best path for a route. Also, there may be more than one best path, in which case load balancing may occur depending on the routing protocol.

After each routing process performs its internal best path selection process, it will attempt to install its best path route into the routing table. For the same route (same network, same prefix-length) that is attempted to be installed by multiple routing processes, the router will install the route from the source with the lowest Administrative Distance into the routing table.

With the routing table built, it then becomes easy for the router to forward traffic and it does this based on the longest prefix match.

Let’s use the lab setup below to explore this routing table building and route selection.

  • We will run EIGRP among R1, R2 and R3. Just to tip the balance a bit, we will change the default delay on R3’s e0/1 interface.
  • We will also run OSPF between R1 and R4.
  • We will configure a static route on R1 pointing towards R5 for the 192.168.0.0/26 network.

Let’s begin with the 192.168.0.0/24 network. R1 will receive information about that route from 3 routers: R2 and R3 (via EIGRP) and R4 (via OSPF).

We can check the EIGRP topology table on R1 to see the details about that route from R2 and R3.

Based on the metric (feasible distance), EIGRP has determined that the best path to reach that network is through 10.1.1.2, so it will attempt to install that route into the routing table.

Now, since that route is received from only one OSPF neighbor (10.1.1.4), then that neighbor automatically becomes the best path. So the OSPF process will also try to install this route in the routing table.

To determine which one will be installed into the routing table, the router will use the Administrative Distance. Since EIGRP has a lower (better) Administrative Distance (90) than OSPF (110), the route from EIGRP will be installed into the routing table. We can confirm this by looking at that route in R1’s routing table:

Let’s take a look at the complete routing table of R1:

We see both the 192.168.0.0/24 and 192.168.0.0/26 networks in this routing table. Now the question is: If R1 wants to send traffic to 192.168.0.60, what next hop address will it forward the traffic to?

This is where longest prefix match comes in: even though 192.168.0.60 falls under both 192.168.0.0/26 and 192.168.0.0/24, the longer prefix is 192.168.0.0/26; therefore, R1 will forward the traffic to 10.1.5.5.

We can confirm this by debugging IP packets on R1 and pinging 192.168.0.60.

Hint: You can use an ACL to limit your debug to just ping traffic

R1#ping 192.168.0.60 re 1
Type escape sequence to abort.
Sending 1, 100-byte ICMP Echos to 192.168.0.60, timeout is 2 seconds:
!
Success rate is 100 percent (1/1), round-trip min/avg/max = 1/1/1 ms
R1#
*Jul 2 14:03:23.582: IP: s=10.1.5.1 (local), d=192.168.0.60, len 100, local feature
*Jul 2 14:03:23.582: ICMP type=8, code=0, Logical MN local(14), rtype 0, forus FALSE, sendself FALSE, mtu 0, fwdchk FALSE
*Jul 2 14:03:23.582: FIBipv4-packet-proc: route packet from (local) src 10.1.5.1 dst 192.168.0.60

*Jul 2 14:03:23.582: FIBfwd-proc: packet routed by adj to Ethernet0/1 10.1.5.5

*Jul 2 14:03:23.582: FIBipv4-packet-proc: packet routing succeeded
*Jul 2 14:03:23.582: IP: s=10.1.5.1 (local), d=192.168.0.60 (Ethernet0/1), len 100, sending
*Jul 2 14:03:23.582: ICMP type=8, code=0
*Jul 2 14:03:23.582: IP: s=10.1.5.1 (local), d=192.168.0.60 (Ethernet0/1), len 100, sending full packet
*Jul 2 14:03:23.582: ICMP type=8, code=0

On the other hand, if R1 receives a packet destined to 192.168.0.100, the longest prefix match for that packet is 192.168.0.0/24 and so the next hop will be 10.1.1.2.

IP Classless

While we are on this topic of route selection, it is a good time to discuss how the router behaves when the [no] ip classless command is configured. Although this command does not change the way the routing table is built, it affects the way packets are forwarded.

Starting from version 11.3, the default on Cisco IOS routers is that ip classless is enabled but we can disable it using the no ip classless command. When disabled, if a router has a supernet for a network in its routing table but receives a packet destined to an unknown subnet, that packet will be dropped EVEN IF a default route is present in the routing table.

An example will help drive home the point. Imagine a router with the following configuration:

ip route 0.0.0.0 0.0.0.0 10.1.1.3
ip route 172.16.0.0 255.255.240.0 10.1.1.2
ip route 172.16.0.0 255.255.255.0 10.1.1.1

The routing table of this router will look something like this:

Let’s consider a couple of scenarios with the default ip classless command configured. Remember that 172.16.0.0/24 has a range of host IP addresses of 172.16.0.1 to 172.16.0.254, while 172.16.0.0/24 goes from 172.16.0.1 to 172.16.15.254:

  • If the router receives a packet destined to 172.16.0.100, it will forward it to 10.1.1.1 because 172.16.0.0/24 is the longest prefix match.
  • If the router receives a packet destined to 172.16.1.100, it will forward it to 10.1.1.2 because 172.16.0.0/20 is the longest prefix match.
  • If the router receives a packet destined to 172.16.20.100, it will forward it to 10.1.1.3 because that destination does not match any other longer prefix so the default route will be used.

You can confirm that these results are true by debugging IP packets (detail) and sending one ping packet to those addresses from the router.

Now, if the no ip classless command is configured, the first two results will remain the same. However, the last result will change because the packet will be dropped. If you turn on IP packet debugging, you will get a message similar to the one below:

*Mar 1 00:01:13.059: IP: s=10.1.1.100 (local), d=172.16.20.100, len 100, unroutable

The reason the packet is dropped is because the router knows the supernet 172.16.0.0/16 (because it has some of the subnets of that supernet in its routing table), but since the router does not have the subnet that 172.16.20.100 belongs to in its routing table, the packet is dropped even though there is a default route available.

However, for a packet destined to, say 172.17.20.100, the default route will be used because the router does not know about 172.17.0.0/16 from any other source.

Summary

This brings us to the end of this article, where we have looked at route selection on Cisco routers. We covered several points like Administrative Distance, metric and prefix length. We also looked at how forwarding of packets is affected when the ip classless command is disabled.

I hope you have found this article insightful.

References and Further Reading