# Recursive routing with marking

**URL:** <https://forum.mikrotik.com/t/recursive-routing-with-marking/169122>\
**Category:** Beginner Basics\
**Created:** [August 28, 2023, 1:14am UTC](https://forum.mikrotik.com/t/recursive-routing-with-marking/169122 "2023-08-28T01:14:19Z")\
**Posts on this page:** 4\
**Page:** 1

<div class="post-metadata">

**Author:** ![chuq](https://forum.mikrotik.com/letter_avatar/chuq/32/6_449c533f586939b6e5f246632a46421f.png) [@chuq](https://forum.mikrotik.com/u/chuq)\
**Post date:** [August 28, 2023, 1:14am UTC](https://forum.mikrotik.com/t/recursive-routing-with-marking/169122/1 "2023-08-28T01:14:19Z")

</div>

Found on this page: [https://help.mikrotik.com/docs/pages/viewpage.action?pageId=26476608](https://help.mikrotik.com/docs/pages/viewpage.action?pageId=26476608)  
 ![reroute.png](https://data-discourse.cdn.mikrotik.com/original/3X/8/d/8d1a8bcc4d1b2adef63f11884e88b026862d622e.png)  
Why do we specify **routing-table** in the second part, but not in the first ?

---

<div class="post-metadata">

**Author:** ![Filo](https://forum.mikrotik.com/user_avatar/forum.mikrotik.com/filo/32/2918_2.png) [@Filo](https://forum.mikrotik.com/u/Filo)\
**Post date:** [August 28, 2023, 9:28am UTC](https://forum.mikrotik.com/t/recursive-routing-with-marking/169122/2 "2023-08-28T09:28:46Z")

</div>

Hi,

it’s a bit out of context but…  
Basically recursive routing is done because:

- MikroTik is able to check if a GATEWAY is alive and can handle routing based on the result (let’s say: PING OK / PING NOT OK)

This does not necessarlily mean that the INTERNET is alive on that gateway.

So what these entries are doing is set up a route to 8.8.8.8 and 8.8.8.4 in the ISP-Outbreak-Interfaces.  
The second part - as you might have seen - is missing “dst-address”, which means it will be the DEFAULT route.  
As a gateway they setup 8.8.8.8 and / or 8.8.8.4 recursively, so that only when those hosts are pingeble the route becomes active.  
Primary and Secondary ISP is then managed by the “distance” - the lower the higher the priority.

This is done mainly because it is not possible to check the route depending on hosts AFTER the gateway.

**Falling back to your question:** We need to define the routing table to make sure we can create a corresponding MANGLE-Roule (“mark routing”) in the firewall. This is the only way to make traffic to be sent over a specific route then - all has to correspond.  
  
  
Hope this helped.

If you are as confused about this and rather like to check a host BEHIND a specific gateway - why not try this method instead, I recently discovered:

[http://forum.mikrotik.com/t/simpler-failover-for-two-gateways-i-found-working/169108/1](http://forum.mikrotik.com/t/simpler-failover-for-two-gateways-i-found-working/169108/1)

Best regards,  
Martin!

---

<div class="post-metadata">

**Author:** ![anav](https://forum.mikrotik.com/user_avatar/forum.mikrotik.com/anav/32/2112_2.png) [@anav](https://forum.mikrotik.com/u/anav)\
**Post date:** [August 28, 2023, 11:47am UTC](https://forum.mikrotik.com/t/recursive-routing-with-marking/169122/3 "2023-08-28T11:47:27Z")

</div>

The quick answer is that there is a routing-table specified in the first one, its just not shown, routing-table=main.  
Every IP route needs a routing table, the default one is MAIN.  
The router normally looks at the main table to find where to route traffic.  
If you want the router to pick something different one must use routing rules or mangle traffic to different tables.

---

<div class="post-metadata">

**Author:** ![chuq](https://forum.mikrotik.com/letter_avatar/chuq/32/6_449c533f586939b6e5f246632a46421f.png) [@chuq](https://forum.mikrotik.com/u/chuq)\
**Post date:** [August 28, 2023, 2:28pm UTC](https://forum.mikrotik.com/t/recursive-routing-with-marking/169122/4 "2023-08-28T14:28:00Z")

</div>

> Nexthop lookup is done only in the main routing table, \> **even for routes with different value of routing-mark** \> . It is necessary to restrict set of routes that can be used to look up immediate nexthops.

Quite surprising 🙂 and absolutely unclear why would they do that  
If I understand correctly, routing-mark used only for the first entry selection, and does not matter for the following recursive search
