Route Selection, Administrative Distance, and the Routing Table

29 Mar 2011 - Lab-Rat

For identical routes advertised from different protocols, the default behavior of the router is to use the lowest administrative distance. The administrative distances (AD) are:

| Connected | 0 | |---|:-:| | Static | 1 | | EIGRP (summary) | 5 | | EBGP | 20 | | EIGRP (internal) | 90 | | OSPF | 110 | | RIP | 120 | | EIGRP (external) | 170 | | IBGP | 200 |

A word of caution however. 192.168.15.0/25, 192.168.15.0/26, 192.168.15.0/27 are all different routes to the router, due to the varying prefix length. That means that AD would not come into play in deciding which would go into the routing table- they all will. If all these addresses are in a single routing protocol, and a packet for 192.168.15.7 comes in, which route would be chosen?

Let’s do some math:

192.168.15.0/25
Net Start: 192.168.15.0 (duh)
1st Address: 192.168.15.1
Last Address: 192.168.15.126
Broadcast: 192.168.15.127

192.168.15.0/26
Net Start: 192.168.15.0
1st Address: 192.168.15.1
Last Address: 192.168.15.62
Broadcast: 192.168.15.63

192.168.15.0/27
Net Start: 192.168.15.0
1st Address: 192.168.15.1
Last Address: 192.168.15.30
Broadcast: 192.168.15.31

Let’s see, our destination is contained in all the routes- so the router will pick the most specific destination- the one with the longest prefix, 192.168.15.0/27.

The IP CLASSFUL Trap

Be careful with default routes and classful routing (no ip classless configured), the router does the following.

1. If the target route exists in the routing table, it routes normally.
2. If the target route is not in the routing table, AND the classful prefix does not exist in the routing table, it will use the default route.
3. If the target route is not in the routing table, AND the classful prefix DOES exist in the routing table- it drops the packet.

For example, let’s say we have the following routes in our routing table:
router# show ip route
….
172.16.0.0/16 is variably subnetted, 2 subnets, 2 masks
D 172.16.48.0/20 [90/30041323] via 1.1.1.1
D 172.16.48.0/24 [90/15783132] via 2.2.2.2
S* 0.0.0.0/0 [1/0] via 9.9.9.9

1. Anything going to 172.16.48.1 - 172.16.63.255 will be routed to the appropriate longest prefix.
2. Anything outside the 172.16.0.0 class B subnet will be routed to the default.
3. Anything for 172.16.x.x that isn’t in the range in step 1, will be dropped.

Additional Reading:
Route selection