cancel
Showing results for 
Search instead for 
Did you mean: 
cancel
3140
Views
15
Helpful
9
Replies

choosing the best route

daniel4579329
Spotlight
Spotlight

hi im learning from the cisco ccna vol1

and i see that the best route is being choosed by the lowest admin d. 

but in an other place int the book i saw that the route is being choosed by the lowset cost, can someone explain to me 

 

thanks for the help (:

1 Accepted Solution

Accepted Solutions

Martin L
VIP
VIP

 

The longest prefix match always wins among the routes actually installed in the routing table, while the routing protocol with the lowest administrative distance always wins when installing routes into the routing table.

 

source:  "Route Selection in Cisco Routers"

https://www.cisco.com/c/en/us/support/docs/ip/enhanced-interior-gateway-routing-protocol-eigrp/8651-21.html

 

Regards, ML
**Please Rate All Helpful Responses **

View solution in original post

9 Replies 9

Seb Rupik
VIP Alumni
VIP Alumni

Hi there,

Administrative Distance comes into play when there are two competing identical routes (same destination IP and netmask) offered by different routing protocols. The route offered by the routing protocol with the lowest AD is the one which will be inserted into the routing table.

Cost is one type of metric that a routing protocol will use in selecting the best route before it is inserted into the routing table (and its AD is evaluated).

 

cheers,

Seb.

sorry my bad i meant to say route the being choose by the lowest metric not cost

Administrative Distance and Metric are both ways of selecting the best route when there are 2 (or more) candidate routes. And the explanation by Seb describes them. 

 

AD is used when there are 2 (or more) candidate routes and each route comes from a different routing protocol (or from a routing protocol and static route).

 

Metric is used where there are 2 (or more) candidate routes and each route come from the same routing protocol.

HTH

Rick

Martin L
VIP
VIP

 

The longest prefix match always wins among the routes actually installed in the routing table, while the routing protocol with the lowest administrative distance always wins when installing routes into the routing table.

 

source:  "Route Selection in Cisco Routers"

https://www.cisco.com/c/en/us/support/docs/ip/enhanced-interior-gateway-routing-protocol-eigrp/8651-21.html

 

Regards, ML
**Please Rate All Helpful Responses **

Yes ML is correct that when forwarding an IP packet we look into the current routing table. If there is more than one route that could get to the destination then the longest match (the most specific route) is chosen. (2 prefixes in the routing table each of which includes the destination address). For example if we want to forward a packet whose destination address is 192.168.1.130 and we look into the routing table and we find these entries

192.168.1.0 255.255.255.0 via x

192.168.1.128 255.255.255.128 via y

then the second entry will be used to forward the packet because it is more specific. It does not matter whether these routes are from any of the dynamic routing protocols (what is their AD) or static route and it does not matter what metric is associated with either entry. The longest match wins when we are evaluating prefixes in the current routing table. 

 

It is different when we are evaluating what candidate route to put into the routing table. If we are evaluating 2 candidate routes

192.168.1.0 255.255.255.0 via x EIGRP learned from neighbor X

192.168.1.0 255.255.255.0 via y EIGRP learned from neighbor Y

then we would look at the metric of each route and choose the one with the best metric. That is the route that would be put into the routing table.

But if we were evaluating these candidate routes

192.168.1.0 255.255.255.0 via x EIGRP learned from neighbor X

192.168.1.0 255.255.255.0 via y OSPF learned from neighbor Y

For this we do not look at metric but look at AD. And since the AD of EIGRP is better than the AD of OSPF then the first candidate route is chosen. That is the route that would be put into the routing table.

 

To further examine the logic let me ask if we had these 2 candidate routes to be put into the routing table, which one would be chosen

192.168.1.0 255.255.255.0 via x RIP learned from neighbor X

192.168.1.128 255.255.255.128 via y OSPF learned from neighbor Y

 

Would we look at AD?

Would we look at metric?

Who would be the winner???

 

In this case we do not care about AD and we do not care about metric. They are different prefixes and both would be put into the routing table.

HTH

Rick

but 192.168.1.0 255.255.255.0 is overlapping with 192.168.1.128 255.255.255.128

Yes there is overlap. But that is not necessarily a problem. This discussion was about the question of how to choose the best route, especially the functions of Administrative Distance and Metric and longest match. Just to clarify the use of each of those: Administrative Distance and Metric are used when we are making decisions about what route should be inserted into the IP routing table. Longest Match is used to decide which of several routes already in the routing table should be used to forward a packet.

- Administrative Distance is used to select the best route when there are 2 (or more) routes for the same prefix and the routes come from different sources (static, or RIP, or OSPF, or EIGRP). The route with the lowest AD will be chosen and inserted into the IP routing table.

- Metric is used to select the best route when there are 2 (or more) routes for the same prefix and the routes come from the same sources (RIP, or OSPF, or EIGRP). The route with the lowest Metric will be chosen and inserted into the IP routing table.

- Longest Match is used to select which route currently in the IP routing table will be used to forward an IP packet.

 

The example that I proposed was a router wanting to forward a packet to 192.168.1.130. The routing table had 2 entries: one for 192.168.1.0/24 and the other for 192.168.128/25. So let us think a bit more about this example.

 

Let us assume that we have routerA which is connected on Fa0/0 to routerB and is connected on Fa0/1 to routerC. Let us assume that routerB has the following subnets as connected interfaces 192.168.1.0/27, 192.168.1.32/27, 192.168.1.64/27, and 192.168.96/27. And let us assume that instead of advertising individual subnets that routerB does summarization and advertises 192.168.1.0/24. Would you agree that this is valid?

And let us assume that routerC has the connected interface subnet 192.168.1.128/25

The result is that routerA has these 2 routes in its routing table

192.168.1.0/24 via Fa0/0  to routerB

192.168.1.128/25 via Fa0/1 to routerC

Yes they do overlap. But this does not create any problem. Forwarding of IP packets works just as it should. If a packet has destination 192.168.1.130 then it is found in both routes and the longest match wins and the packet will be forwarded to routerC. What about a packet with destination 192.168.1.100. It is found in only a single routing entry and will be forwarded to routerB. No problem at all.

 

If routerB and routerC were both assigning IP addresses in the same address range then certainly that would create a problem, and I believe that this is the situation that you were thinking about. But as long as the routers do not both use the same IP range then it is quite possible (and no problem) to have overlapping entries in the IP routing table.

HTH

Rick

amazing explanation thank you for the help (:

You are welcome. I am glad that my examples and my explanations have been helpful. This community is an excellent place to ask questions and to learn about networking. I hope to see you continue to be active in the community.

HTH

Rick