Caps Services - Forum

K-net => Internet => Discussion démarrée par: halesk2k le 27 Août 2021 à 09:49:30

Titre: Failover fibre/4g Mikrotik
Posté par: halesk2k le 27 Août 2021 à 09:49:30
Si comme moi, vous utilisez un backup 4G pour fiabiliser votre connexion, je vous partages mon script de failover pour routeur Mikrotik.

https://github.com/loiklo/mikrotik/blob/main/failover-dhcp


Features:
   - main/backup failover with 2 dhcp-client interfaces
   - rely on multiple remote test hosts to decide if the main link is working properly
   - automaticaly add/remove required routes to remote test hosts
   - adjust testHosts routes if the gateway change
   - configurable "ping success rate expected"
   - stop pinging testHosts as soon as the expected rate is reached to avoid unnecessary traffic
   - release DHCP lease in mainInterface on link failure to trigger a renew.
     (This is usefull if the provider change the subnet on its side but our DHCP lease is not expired yet)
   - doesn't need :global variable
   - doesn't need specific configuration other than using dhcp-client on both main/backup interfaces
 
Limitations:
   - hosts in testHosts array can't be reach through backupInterface if mainInterface receive a DHCP lease
   - mainInterface and backupInterface must be configured in dhcp-client
   - Only work with IPv4