Page 1 of 1

Routing distance and subnets priority

Posted: Thu Feb 12, 2015 3:08 pm
by iranet
If I understand correctly, when you create a new route, "distance" makes priority.
Eg. if you have two same route to different interface, route with smaller priority will have advantage and will be "active" route.
Example:
add comment="Route 1" distance=5 dst-address=10.10.10.0/24 gateway=Kon1
add comment="Route 2" distance=2 dst-address=10.10.10.0/24 gateway=Kon2

So, all packet to any address 10.10.10.0/24 will go on gateway Kon2 (distance 2)

BUT
But, if you have to different subnet mask / bits, but same ip range - proprity in distance is ignored!
Example:
add comment="Route 1" distance=5 dst-address=10.10.10.0/24 gateway=Kon1
add comment="Route 2" distance=2 dst-address=10.10.10.0/24 gateway=Kon2
add comment="Route 3" distance=1 dst-address=10.10.0.0/16 gateway=Kon3

All route to 10.10.10.0/24 will go on Kon2 anyway, but distance on Kon3 is "1" but subnet is 16bit and distance is igonred!
Is that standard behaviour in Mikrotik routers?

Re: Routing distance and subnets priority

Posted: Thu Feb 12, 2015 3:19 pm
by nickshore
The most specific route is used first, so a /24 will always be used in preference to a /16

Re: Routing distance and subnets priority

Posted: Thu Feb 12, 2015 3:27 pm
by iranet
I understand that, but distance is different
Shouldn't distance change priority of route?

Re: Routing distance and subnets priority

Posted: Thu Feb 12, 2015 3:35 pm
by nickshore
Distance is only considered after subnet size.

Re: Routing distance and subnets priority

Posted: Thu Feb 12, 2015 3:43 pm
by nest
Nick is correct. Also, if multiple routes have the same identical distance then the choice of order becomes: 1st - Connected Route, 2nd - Static Route, 3rd - Dynamic route (usually from a dynamic routing protocol)

Re: Routing distance and subnets priority

Posted: Thu Feb 12, 2015 4:12 pm
by iranet
So, only if I have same subnet size distance makes priority... OK, I understand...

Here is my problem...
I have 25 sites (locations) with Mikrotik routers connected to central Mikrotik router.
So, I'm connected to that central router as well.
But only one of this 25 sites (locaton 5) is special case and has two connection. One to central Mikrotik router and one to my router directly.

Direct connection between "site 5" and my router should be used only if central router is down.

So, I create route something like this:
add comment="Route ALL" distance=1 dst-address=10.0.0.0/8 gateway=Central
add comment="Site 5" distance=2 dst-address=10.0.5.0/24 gateway=Location5

Idea is that route 10.0.5.0/24 work only if route 10.0.0.0/8 is down.
But this not work from obvious reason as you are mention before.

So, any ideas, how I can make this to work?

Re: Routing distance and subnets priority

Posted: Thu Feb 12, 2015 4:21 pm
by iranet
I figure out...
I need to create another route for site 5 to central router:
add comment="Route ALL" distance=1 dst-address=10.0.0.0/8 gateway=Central
add comment="Site 5" distance=2 dst-address=10.0.5.0/24 gateway=Location5
add comment="Central 5" distance=1 dst-address=10.0.5.0/24 gateway=Central

So this work..