Best route for overlapping routes

solnsusiesolnsusie Member Posts: 128
hi
it says in the ICND1 book of Wendell Odom page 483 that, "when a particular destination IP address matches more than one route in a router's routing table, the router uses the most specific route, in other words, the route with the longest prefix length." which means if an ip address 172.16.1.2 finds 2 routes, 1) 172.16.1.0/24 with hop count 2, and 2)172.16.0.0/22 with hop count 1, it will take the route with the 24 mask, so my question is 1st, what is the logic that it will use with the bigger prefix? and 2nd, why is it choosing the route with the longer prefix mask over the route with the less hop count??
«1

Comments

  • networker050184networker050184 Mod Posts: 11,962 Mod
    Thats they way the routing logic is built. The longest match is the first criteria checked followed by AD then metric. Those two overlapping prefixes could also go to different destinations.
    An expert is a man who has made all the mistakes which can be made.
  • solnsusiesolnsusie Member Posts: 128
    Thats they way the routing logic is built. The longest match is the first criteria checked followed by AD then metric. Those two overlapping prefixes could also go to different destinations.
    thanks for your reply.
    so what you saying is, that if I have 2 routes one with EIGRP and a 2nd with RIP, and the rip has a bigger prefix it will choose the RIP route? even its not using some good features like VLSM? Just because it has a bigger prefix???
    that’s interesting!!!! And sad!!!!
  • MonkerzMonkerz Member Posts: 842
    solnsusie wrote: »
    hi
    it says in the ICND1 book of Wendell Odom page 483 that, "when a particular destination IP address matches more than one route in a router's routing table, the router uses the most specific route, in other words, the route with the longest prefix length." which means if an ip address 172.16.1.2 finds 2 routes, 1) 172.16.1.0/24 with hop count 2, and 2)172.16.0.0/22 with hop count 1, it will take the route with the 24 mask, so my question is 1st, what is the logic that it will use with the bigger prefix? and 2nd, why is it choosing the route with the longer prefix mask over the route with the less hop count??


    Suppose that router (R1) is summarizing 172.16.0.0/22 out Ser0/0 to R2, and also has a route to 172.16.1.0/24 to R3 out Ser0/1 that is 2 hops away.

    Would you want the packets coming from R2 destined to 172.16.1.4/24 to route to R1's Null0 rather than to R3, because Null0 is local and theoretically closer?
  • solnsusiesolnsusie Member Posts: 128
    Monkerz wrote: »
    Suppose that router (R1) is summarizing 172.16.0.0/22 out Ser0/0 to R2, and also has a route to 172.16.1.0/24 to R3 out Ser0/1 that is 2 hops away.

    Would you want the packets coming from R2 destined to 172.16.1.4/24 to route to R1's Null0 rather than to R3, because Null0 is local and theoretically closer?
    sorry, i just dont understand what you are saying, please explain in more detail.
    thanks and sorry..
  • ehndeehnde Member Posts: 1,103
    solnsusie wrote: »
    thanks for your reply.
    so what you saying is, that if I have 2 routes one with EIGRP and a 2nd with RIP, and the rip has a bigger prefix it will choose the RIP route? even its not using some good features like VLSM? Just because it has a bigger prefix???
    that’s interesting!!!! And sad!!!!

    Someone correct me if I'm wrong, but if you have two routes, one EIGRP and the other RIP, the router will choose the EIGRP route because it has an administrative distance of 90. RIP has an administrative of 120.

    Your book scenario with a more specific prefix would apply when comparing two rip routes. Maybe I'm wrong :)
    Climb a mountain, tell no one.
  • solnsusiesolnsusie Member Posts: 128
    ehnde wrote: »
    Someone correct me if I'm wrong, but if you have two routes, one EIGRP and the other RIP, the router will choose the EIGRP route because it has an administrative distance of 90. RIP has an administrative of 120.

    Your book scenario with a more specific prefix would apply when comparing two rip routes. Maybe I'm wrong :)
    as what networker050184 wrote in the 2nd reply, you are wrong, so who is right???? im getting confusedicon_redface.gif
  • solnsusiesolnsusie Member Posts: 128
    Monkerz wrote: »
    I believe AD is considered if both routes have the same prefix.
    I’m talking specifically with different prefix!!!
  • MonkerzMonkerz Member Posts: 842
    solnsusie wrote: »
    I’m talking specifically with different prefix!!!

    Ok, we are just confusing you.

    If you have to routes using the same routing protocol, the longest prefix is used to determine the best route.

    If two routing protocols are used, AD is used find the best route. The router prefers routes with a lower AD because they are more believable.
  • ehndeehnde Member Posts: 1,103
    As you mentioned originally, you have two routes. 127.16.1.0/24 with a hop count of 2 and 172.16.0.0/22 with a hop count of 1.

    a /24 is more specific than a /22. If you had ANOTHER router using a /25, that would be preferred over the /24 (assuming the /25 was a 3rd route to the destination).

    Can someone else please confirm?
    Climb a mountain, tell no one.
  • solnsusiesolnsusie Member Posts: 128
    Monkerz wrote: »
    Ok, we are just confusing you.

    If you have to routes using the same routing protocol, the longest prefix is used to determine the best route.
    so back to my question, why will it take the route with the longer prefix when it has more hop counts??
    Monkerz wrote: »
    If two routing protocols are used, AD is used find the best route. The router prefers routes with a lower AD because they are more believable.
    even with longer prefix?
    is this final for the exam???icon_cheers.gif
  • ehndeehnde Member Posts: 1,103
    If you're wondering WHY the more specific route is chosen, consider this:

    /22 means 10 host bits. 2^10 - 2 = 1024 addresses.

    /24 means 8 host bits. 2^8 - 2 = 254 addresses.

    with 1024 possible hosts to contend with, the /22 would be busier, so it would be more efficient to send to the /24.
    Climb a mountain, tell no one.
  • networker050184networker050184 Mod Posts: 11,962 Mod
    solnsusie wrote: »
    so back to my question, why will it take the route with the longer prefix when it has more hop counts??

    Because you want the traffic to go to the most specific destination. Say you have 10.0.0.0/8 pointed from router A to router B and 10.1.1.0/24 pointed from router A to router C. You would want all destinations within 10.1.1.0/24 to be sent to router C not B which is why the longest match is used.
    solnsusie wrote: »
    even with longer prefix?
    is this final for the exam???icon_cheers.gif
    No, the FIRST thing checked is the longest match. Once that is decided, and only then, is the AD consulted. Once that is decided the metric (hop count for RIP) is used.
    An expert is a man who has made all the mistakes which can be made.
  • networker050184networker050184 Mod Posts: 11,962 Mod
    ehnde wrote: »
    Someone correct me if I'm wrong, but if you have two routes, one EIGRP and the other RIP, the router will choose the EIGRP route because it has an administrative distance of 90. RIP has an administrative of 120.

    Your book scenario with a more specific prefix would apply when comparing two rip routes. Maybe I'm wrong :)

    Yes, you are wrong.
    An expert is a man who has made all the mistakes which can be made.
  • solnsusiesolnsusie Member Posts: 128
    ehnde wrote: »
    If you're wondering WHY the more specific route is chosen, consider this:

    /22 means 10 host bits. 2^10 - 2 = 1024 addresses.

    /24 means 8 host bits. 2^8 - 2 = 254 addresses.

    with 1024 possible hosts to contend with, the /22 would be busier, so it would be more efficient to send to the /24.
    got it, thanks a lot
  • networker050184networker050184 Mod Posts: 11,962 Mod
    ehnde wrote: »
    If you're wondering WHY the more specific route is chosen, consider this:

    /22 means 10 host bits. 2^10 - 2 = 1024 addresses.

    /24 means 8 host bits. 2^8 - 2 = 254 addresses.

    with 1024 possible hosts to contend with, the /22 would be busier, so it would be more efficient to send to the /24.

    What? It has nothing to do with who would be busier.
    An expert is a man who has made all the mistakes which can be made.
  • MonkerzMonkerz Member Posts: 842
    Well, looks like I need to freshen up a bit. Networker is right, 1) Prefix length, 2) AD, 3) Metric
    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.

    Route Selection in Cisco Routers - Cisco Systems
  • solnsusiesolnsusie Member Posts: 128
    No, the FIRST thing checked is the longest match. Once that is decided, and only then, is the AD consulted. Once that is decided the metric (hop count for RIP) is used.
    if so, this means that when the longer match is RIP, we are loosing all the good things from EIGRP!!!!! am i right????
  • solnsusiesolnsusie Member Posts: 128
    Yes, you are wrong.
    so who is correct!!!! who gives up!!!! now im really mixed up!!!!icon_rolleyes.gif
  • ehndeehnde Member Posts: 1,103
    This is an old topic I probably need to review. I'd always thought of the more specific route being chosen as an analogy to zeroing in on a dart board (the more specific route being closer to the bullseye).
    Climb a mountain, tell no one.
  • solnsusiesolnsusie Member Posts: 128
    What? It has nothing to do with who would be busier.
    I understand this, because with the /24 its more specific where the destination is, if I’m wrong please explain,
  • solnsusiesolnsusie Member Posts: 128
    What? It has nothing to do with who would be busier.
    please explain what the logic is that it chooses the longer mask
  • ehndeehnde Member Posts: 1,103
    I will admit I had to do some reviewing to get to the bottom of this.

    Route specificity takes preference over administrative distance. As you may recall, static routes have an AD of 1. If you have a static default route of 0.0.0.0/0 and another route with a higher cost (EIGRP, RIP, whatever) to 192.168.1.0/24, you wouldn't want traffic intended for the 192.168.1.0 network going to 0.0.0.0 just because 0.0.0.0 has a lower AD.

    Thank you for the refresher :)
    Climb a mountain, tell no one.
  • solnsusiesolnsusie Member Posts: 128
    ehnde wrote: »
    I will admit I had to do some reviewing to get to the bottom of this.

    Route specificity takes preference over administrative distance. As you may recall, static routes have an AD of 1. If you have a static default route of 0.0.0.0/0 and another route with a higher cost (EIGRP, RIP, whatever) to 192.168.1.0/24, you wouldn't want traffic intended for the 192.168.1.0 network going to 0.0.0.0 just because 0.0.0.0 has a lower AD.

    Thank you for the refresher :)
    so what are you saying is? it will use the 0.0.0.0/0 route, or hte 192.168.1.0/24 route? isn't the /0 a lower AD? i dont get it!
    in the Odom ICND1 book it says that it won't use the 0.0.0.0/0 route over the 192.168.1.0/24. and i dont know why, this is another question,
  • ehndeehnde Member Posts: 1,103
    solnsusie wrote: »
    so what are you saying is? it will use the 0.0.0.0/0 route, or hte 192.168.1.0/24 route? isn't the /0 a lower AD? i dont get it!
    in the Odom ICND1 book it says that it won't use the 0.0.0.0/0 route over the 192.168.1.0/24. and i dont know why, this is another question,

    I'm sorry if this is confusing. 0.0.0.0 is used as a gateway of last resort. Like this:
    [B]ip route 0.0.0.0 0.0.0.0 170.170.3.8[/B]
    

    If you don't have a route for a packet, send it to 170.170.3.8. If you have a route to 192.168.1.0 you wouldn't want packets destined for the 192.168.1.0 going to 170.170.3.8. 192.168.1.0 is more specific than 0.0.0.0.

    That's the reason that more specific routes always take priority over a route with a lower AD.
    Climb a mountain, tell no one.
  • okplayaokplaya Member Posts: 199
    It simply uses the most specific route. Here is a post from Scott Morris over on CLN with a good analogy....

    "Think of it as "most-specific matching" if that makes more sense!

    If you have a green Toyota Prius....

    It is:

    1. A vehicle with more than two wheels
    2. A car
    3. A car made by Toyota
    4. A green car made by Toyota
    5. A green Prius

    Which is the most-specific (e.g. best description) match for the car you drive? All of those things describe it, but which is best?

    Routing is the same way. You want the BEST match."


    HTH
  • networker050184networker050184 Mod Posts: 11,962 Mod
    Ok, try and take a look at this crappy diagram.
    RC--------------------------RA--------------------------RB-Host 10.1.1.1
              <------10.0.0.0/8       10.1.1.0/24-------->
    
    RouterA (RA) receives a packet destined for host 10.1.1.1. When it look in its routing table it sees a route for 10.0.0.0/8 with AD of 5 and a route for 10.1.1.0/24 with AD of 110. If the router didn't look for the longest match and used AD only it would send the packet to RC which would be the incorrect destination.
    An expert is a man who has made all the mistakes which can be made.
  • solnsusiesolnsusie Member Posts: 128
    Ok, try and take a look at this crappy diagram.
    RC--------------------------RA--------------------------RB-Host 10.1.1.1
              <------10.0.0.0/8       10.1.1.0/24-------->
    
    RouterA (RA) receives a packet destined for host 10.1.1.1. When it look in its routing table it sees a route for 10.0.0.0/8 with AD of 5 and a route for 10.1.1.0/24 with AD of 110. If the router didn't look for the longest match and used AD only it would send the packet to RC which would be the incorrect destination.

    you are right when the host 10.1.1.1 doesn’t have a route trough both routers, then you are right, it must take the RB, because through the RC 10.0.0.0/8 the packet won’t get to his destination, but when you can reach host 10.1.1.1from both routers but one way with longer prefix and one way with more hops why will it take the route with the longer prefix ??? it could get to his destination through both routers. So which is chosen over which?
    And also, if the packet can be reached through both routers why will it choose the route with the higher mask which use RIP routing protocol and losing the benefits of let’s say EIGRP???
  • ehndeehnde Member Posts: 1,103
    solnsusie wrote: »
    if the packet can be reached through both routers why will it choose the route with the higher mask which use RIP routing protocol and losing the benefits of let’s say EIGRP???

    Your keyword here is if. Yes sometimes two or more different routes can lead to the same destination. But not always. networker050184 just gave a specific example of how this could be incorrect. Taking the correct path is more important than getting there the fastest.
    Climb a mountain, tell no one.
  • solnsusiesolnsusie Member Posts: 128
    ehnde wrote: »
    Your keyword here is if. Yes sometimes two or more different routes can lead to the same destination. But not always. networker050184 just gave a specific example of how this could be incorrect. Taking the correct path is more important than getting there the fastest.
    you are 100% right, but what’s bothering me is,

    1) when you have 2 routes to the same destination and both routes running only and only RIP, but one route has a bigger mask and more hops and the other route has a smaller mask and less hops, which route will be the winner? again both routes are RIP which usually chooses the metric count,

    2) when you have 2 routes to the same destination and two AD's let’s say RIP, and EIGRP, the RIP has BIGGER mask MORE hops and is a HIGHER AD, and the second route is EIGRP SMALLER mask and LESS hops and LOWER AD, which route will be the winner?
  • MrRyteMrRyte Member Posts: 347 ■■■■□□□□□□
    Remember the functions of a router? To a)determine paths to networks and then to b)forward packets to either a directly connected network or remote network by comparing the destination address of the packet to the routing table. The router will first assemble its table based on administrative distance. As for how to forward the packet, the router will scan through its entries and then select a route based on the following criteria:

    1. Prefix Length
    2. Administrative Distance (if there is more than one path to the destination network)

    Let's look at this example: The router receives a packet destined for 192.168.32.1 and has these routes in its table (taken from this link Route Selection in Cisco Routers - Cisco Systems -
    router# show ip route
    D 192.168.32.0/26 [90/25789217] via 10.1.1.1
    R 192.168.32.0/24 [120/4] via 10.1.1.2
    O 192.168.32.0/19 [110/229840] via 10.1.1.3
    Although the network address is the same for all three, the longer subnet mask will mean more matching bits for the destination network of the packet.

    (Remember 1=MUST MATCH; 0=do not have to match)
    192.168.32.0/26=11111111.11111111.11111111.11000000
    192.168.32.0/24=11111111.11111111.11111111.00000000
    192.168.32.0/19=11111111.11111111.11100000.00000000

    The more matching 1's or N bits, the more preferred the route.

    Now as for Administrative Distance-the lower the number; the more "trustworthy" the route. So if we have the same 192.168.32.0/26 route learned by OSPF, RIP, EIGRP, IGRP and other routing protocols then it will see which is the lowest AD and select that particular route.

    So in summary; the router will choose the best route in this order:

    1. Prefix Length
    2. Administrative Distance
    3. Default Route (if one is configured rather than just dropping the packet)

    This is the way I understand it. If there's something incorrect please let me know since I'm not the best at explaining things....icon_sad.gif
    NEXT UP: CompTIA Security+ :study:

    Life is a matter of choice not chance. The path to your destiny will be paved by the decisions that you make every day.
Sign In or Register to comment.