Static Routing · Topic 4 of 4
Recursive Next Hop, Scope and Target Scope
Learn how RouterOS resolves a gateway that is not directly connected, and how the scope and target-scope values decide which routes may be used.
- 5 min
- A recursive route has a gateway that is not on a connected network.
- The router resolves that gateway with a second route lookup.
- A route may resolve the gateway only if its scope is at most the target scope of the asking route.
What it is
A recursive route uses a gateway that is not on a connected network, so the router resolves it through another route.
For example, a route may point to a gateway 10.10.10.1, but the router has no interface in that network. It must first find a route that reaches 10.10.10.1, and then use that route's path.
The scope and target-scope values control this lookup. They decide which routes are allowed to resolve the gateway of which other routes.
How it works
The router resolves the gateway with a second lookup, and scope values limit which routes qualify.
Direct and recursive gateways
When the gateway belongs to a connected network, the router resolves it directly and the interface is known. When it does not, the router looks up the gateway address in the route table, and the route it finds supplies the real next hop.
/ip route add dst-address=10.10.10.0/24 gateway=172.16.1.2
/ip route add dst-address=0.0.0.0/0 gateway=10.10.10.1 target-scope=30
The default route here depends on the first route. The detailed print shows the gateway status as reachable through an interface, or as recursive via another address.
Scope and target scope
Every route has a scope and a target-scope. The scope describes how far from the router the route is. The target scope says how far away a route may be when it is used to resolve this route's gateway.
A gateway lookup accepts a route only if that route's scope is less than or equal to the target scope of the route doing the lookup.
| Route type | Scope | Target scope |
|---|---|---|
| Connected | 10 | - |
| Static | 30 | 10 |
A static route has target scope 10 by default. It can therefore resolve its gateway only through connected routes, whose scope is 10. A recursive gateway that needs another static route, with scope 30, is rejected until you raise the target scope to 30.
That is why the example above sets target-scope=30. Without it, the default route would show as unreachable.
Dynamic routing protocols use their own scope defaults, so read the print output instead of assuming values for them.
Why recursion is useful
A single route can serve as the base for many others. When the underlying path changes, only that one route needs editing.
A typical case is a remote loopback address. Several routes use the loopback as their gateway, and one static route says how to reach the loopback. If the link to that router changes, you update one entry.
It also helps with failover. Routes that depend on a gateway become inactive when the route that resolves it disappears.
/ip route add dst-address=192.168.50.1/32 gateway=10.0.0.2 comment=path-to-R3
/ip route add dst-address=172.20.0.0/16 gateway=192.168.50.1 target-scope=30
/ip route add dst-address=172.21.0.0/16 gateway=192.168.50.1 target-scope=30
Both /16 routes follow the path that the /32 route defines. Changing the /32 route changes the way for both.
Recursion and failover
A recursive route stays active only while its gateway can be resolved. If the resolving route becomes inactive, the dependent route goes inactive too.
The check-gateway setting can test the address that you wrote as the gateway. A dead remote router can then switch the dependent routes to a backup.
Verifying
/ip route print detail where dst-address=0.0.0.0/0
Look for the gateway status line. It names the address and the interface it was resolved through. An unreachable status means no route with a suitable scope could resolve the gateway.
If a route with a far gateway stays inactive, check the target scope before checking anything else.
What to remember for the exam
Seven facts cover most questions on this topic.
- A recursive route has a gateway that is not on a connected network.
- The router resolves that gateway with a second route lookup.
- A route may resolve the gateway only if its scope is at most the target scope of the asking route.
- Connected routes have scope 10.
- Static routes have scope 30 and target scope 10.
- Raise
target-scopeto 30 so a static route can resolve its gateway through another static route. - Several routes can share one recursive gateway, so one change updates all of them.
The usual fix for an unreachable recursive route is to raise the target scope of the route that needs it.
Common mistakes
These four errors appear often.
Leaving the default target scope. The gateway needs a static route to resolve, but target scope 10 only accepts connected routes, so the route stays unreachable.
Mixing up scope and target scope. Scope belongs to the route being found, and target scope belongs to the route doing the looking.
Pointing the gateway at an address with no path at all. No route resolves it, so the route stays inactive regardless of scope.
Assuming recursion is checked at configuration time. The route is accepted when you add it. The problem shows only as an unreachable status later.
Check yourself
Work through these three questions.
What makes a static route recursive?
Its gateway is not on a connected network. The router resolves the gateway through another route.
Why does a static route with a gateway behind another static route show as unreachable by default?
The static route has target scope 10, and the route that must resolve its gateway has scope 30. A lookup accepts only routes whose scope is at most the target scope.
How do you fix that, and what is one benefit of recursion?
Set
target-scope=30on the route that depends on the other one. Several routes can share one resolving route, so a single change updates all of them.
Topic 4 of 4 in Static Routing
Test yourself on Static Routing
The full MikroTik MTCRE question bank has 417 questions, with timed practice exams and an explanation for every answer.
This study guide is independent and is not affiliated with, endorsed by, or sponsored by MikroTik. Vendor names, certification names and exam codes are trademarks of their respective owners and are used for identification only.