⬆️ ⬇️

Features of "national" routing

Anyone who has to deal with at least a few IP networks represents the basics of IP routing.

You may not know the dynamic routing protocols, or know, but not to the subtleties. You can not be the guru of OSPF, BGP and others like them, but the algorithm by which the next-hop is chosen from the formed route-table (formed one way or another, manually or due to dynamics) is represented by many.







Indeed, a simple algorithm for finding the most specific route. It's 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, and therefore the most preferred.

')

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



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



So for the connected (connected) networks it equals 0, for various protocols of dynamic routing see.

ru.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 longer one, i.e., the worst administrative distance? This is where the nuances come out. The devil, as usual in the details.



We take switch cisco L3 and try (replace some octets with xx). Ad 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 specific and, in all logic, it should be chosen.

We are checking.



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



As we see, the administrative distance of 100 did not prevent this route from being a priority.

Just in case we look



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



The best value of the distance 1 did not allow the route to “kill” more specific for the IP destination 192.168.0.1



Logical enough. After all, the 192.168.0.0/255.255.255.0 is just another network compared to the 192.168.0.1/255.255.255.255 network.

But not all manufacturers adhere to the same logic.



Take the Allied Telesyn L3 device.



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 the ad in cisco. The value of pref 60 for a static route given without explicitly indicating this parameter is striking. But our experiment is not a hindrance. As a result, we have what we need. A less specific route with a shorter / better distance and the most specific route with a greater (i.e., worse) route.



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 go along 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. route and selects

the route with the lowest preference value.



2. If there are no routes, then the router inspects

the route with the lowest value

metric.



3. If multiple routes share the lowest preference and metric values, then the

select route for each route

the longest mask.



Such a surprise, we only look at the mask if we have the same preferences / distances and the same metrics.

It is better to know about such a surprise in advance than to “scratch your head” from unexpected device behavior.

Source: https://habr.com/ru/post/157541/



All Articles