

The scripts will automatically enable and disable your routes as they become available. Netwatch must be configured to ping the internet IP's every 10 seconds and perform a script action when it is up or down. Remember to use different reachable dst-address IP's. Start by creating static routes with separate distances for your ISP'sĬreate a route for a reachable IP on the internet for each ISP. This method also allows use for dynamic gateway interfaces. This method is very useful for re-establishing connections to the firewall to mitigate connectivity problems when switching ISP's.

Scripts can be executed to enable/disable routes, clear connections on the firewall and provide log information when this occurs. This tool allows you to check host IP addresses and issue script commands based on their status. Now the router does not rely on the gateway IP to check connectivity but you may still experience connectivity problems with already-established connections when switching back and forth between ISP's. Remember to 'Check Gateway' to enable redundancy.Īdd check-gateway=ping distance=1 gateway=1.1.1.1 target-scope=30 The second route will take you out to the internet but you will need to adjust the 'target scope' field to match the value of the above route for it to be functional. Each ISP should use different internet IP addresses to check connectivity.Īdd distance=1 dst-address=1.1.1.1/32 gateway=10.1.1.251

Adjust your distance accordingly based on which ISP should take preference.
#Mikrotik scripting how to#
The first one to 'tell' your router how to get to your desired IP on the internet. This approach requires two static routes per ISP. Recursive Routing only works with IP addresses and therefore is not suitable for dynamic interface types like PPPoE or DHCP where the IP can change. The static routing principle above remains the same but instead, reachable IP addresses on the internet are used e.g 1.1.1.1 or 8.8.8.8. If you would prefer your failover to not rely on the gateway IP, then you may want to consider using Recursive Routing as a solution. There may also be problems with already-established connections when your primary routes come back online which could be solved using the firewall mangle in RouterOS. If there is a failure after that gateway IP, it would go undetected and routes would never switch over. One disadvantage is that it relies on the gateway IP address to check connectivity. There are disadvantages to the Static Routing with Distance method. The routing flag 'AS' means the route is Active + Static Here is what our default routes look like after the configuration. After 2 timeouts, the route is considered unreachable and the route with the greater distance will kick into action.Īdd check-gateway=ping distance=1 gateway=TSS-InternetĪdd check-gateway=ping distance=2 gateway=Afrihost The 'Check Gateway' option must be set to ping which will periodically (every 10 seconds) check the gateway connection. The idea is to have multiple default routes to the internet at varying distances as the route with the smallest distance will take preference in most cases. When adding routes manually, it gives you control of additional parameters which can be applied to the route. Instead of allowing your router to add the default routes via their interfaces automatically, you can add them manually to the routing table.

This article serves as an introduction on simple ways to achieve failover using RouterOS and assumes all basic configuration has already been completed on the router. Some ways are more complex and offer additional functionality. There are multiple ways to achieve ISP redundancy with MikroTik.
