Features of "national" routing

    Everyone who has to deal with at least a bit of IP networks presents the basics of IP routing.
    You may not know the dynamic routing protocols, or you may know, but not to the subtleties. You may not be the gurus of OSPF, BGP and others like them, but the algorithm according to which the next-hop is already selected from the generated route table (generated one way or another, manually or thanks to the dynamics) is presented by many.



    Indeed, a simple algorithm for finding the most specific route. Everything is pretty obvious. If there is, say, a route to the network 192.168.0.0/24 and to the host 192.168.0.1/32, then for the IP destination 192.168.0.1 the second route is the most specific, which means it is the most preferred.

    But everything becomes not so simple when such an additional parameter as the administrative distance ad (cisco) or prference (Allied Telesyn) appears.

    In short, ad is a measure of the reliability of the route source. The smaller this value, the better, the more confidence, the more preferable the route.

    So for connected networks it equals 0, for various dynamic routing protocols see
    en.wikipedia.org/wiki/%D0%90%D0%B4%D0%BC%D0%B8%D0%BD%D0%B8 % D1% 81% D1% 82% D1% 80% D0% B0% D1% 82% D0% B8% D0% B2% D0% BD% D0% BE% D0% B5_% D1% 80% D0% B0% D1 % 81% D1% 81% D1% 82% D0% BE% D1% 8F% D0% BD% D0% B8% D0% B5

    But here is an interesting question. And how will the router behave if it has a more specific route, but a larger, i.e., worse administrative distance? This is where the nuances come out. The devil, as usual in the little things.

    We take the L3 switch cisco and try (replace some octets with xx). Ad of the second route = 100.

    ip route 192.168.0.0 255.255.255.0 192.168.xx.1 1
    ip route 192.168.0.1 255.255.255.255 192.168.xx.2 100

    For a packet whose destination IP address is 192.168.0.1 the second route is obviously more it is specific and in all logic it should be chosen.
    We check.

    sh ip rou 192.168.0.1
    Routing entry for 192.168.0.1/32
    Known via "static", distance 100 , metric 0
    Routing Descriptor Blocks:
    * 192.168.xx.2
    Route metric is 0, traffic share count is 1

    Как видим, административное расстояние 100 нисколько не помешало быть этому маршруту приоритетным.
    На всякий случай смотрим

    sh ip rou 192.168.0.2
    Routing entry for 192.168.0.0/24
    Known via «static», distance 1, metric 0
    Routing Descriptor Blocks:
    * 192.168.xx.1
    Route metric is 0, traffic share count is 1

    Лучшее значение дистанции 1 не позволило маршруту «перебить» более специфичный для IP-назначения 192.168.0.1

    Достаточно логично. Ведь 192.168.0.0/255.255.255.0 это просто другая по отношению к 192.168.0.1/255.255.255.255 сеть.
    But not all manufacturers adhere to the same logic.

    Take the L3 device Allied Telesyn.

    add ip rou = 192.168.0.0 mask = 255.255.255.0 int = vlan1 next = 172.16.xx.2
    set ip rou = 192.168.0.0 mask = 255.255.255.0 int = vlan1 next = 172.16.xx.2 pref = 1

    add ip rou = 192.168.0.1 mask = 255.255.255.255 int = vlan1 next = 172.16.xx.3

    sh ip rou (pref value is highlighted)

    IP Routes
    ...

    192.168.0.0 255.255.255.0 172.16.xx.2 - vlan1 1507
    direct 0 static 1 1

    192.168 .0.1 255.255.255.255 172.16.xx.3 - vlan1 1490
    direct 0 static 1 60

    For AT, the pref parameter is analogous to ad in cisco. The value of pref 60 is striking for a static route specified without explicitly specifying this parameter. But our experiment is not a hindrance. In the end, we have what we need. A less specific route with a shorter / better distance and a more specific route with a larger (i.e. worse) one.

    trace 192.168.0.1

    Trace from 172.16.xx.1 to 192.168.0.1, 1-30 hops
    0. 0 3 11 (ms) 172.16.xx.2

    Unexpected result. We follow the route for 192.168.0.0/24.

    But from the point of view of the manufacturer, everything is exactly as it should. We read in the manual about the route selection algorithm.

    1. The router inspects the preference value of each candidate route and selects
    the route with the lowest preference value.

    2. If multiple routes share the lowest preference value, then the router inspects
    the metric value of each of these routes and selects the route with the lowest
    metric.

    3. If multiple routes share the lowest preference and metric values, then the
    router inspects the mask of each of these routes and selects the route with
    the longest mask.

    Here is such a surprise, we look at the mask only if we have the same preferences / distances and the same metrics.
    It is better to know about such a surprise in advance than then "scratching your head" from the unexpected behavior of the device.

    Also popular now: