Questo forum fa uso dei cookie
Questo forum utilizza i cookie per memorizzare i dettagli del tuo login o della tua ultima visita. I cookie sono piccoli files di testo salvati nel computer; i cookie da noi utilizzati sono relativi unicamente ai servizi da noi forniti direttamente o dai banner pubblicitari. I cookie su questo forum salvano inoltre i dettagli relativi alle discussioni lette e alle tue preferenze personali. Sei pregato di selezionare il tasto OKAY se sei consapevole della presenza di questi files e ci autorizzi ad utilizarli per le informazioni specificate.

Indipendentemente dalla tua scelta un cookie verrà salvato per memorizzare nel tuo pc la risposta a questo form. Puoi modificare le impostazioni relative ai cookie nelle preferenze del tuo browser.

  • 0 voto(i) - 0 media
  • 1
  • 2
  • 3
  • 4
  • 5
[Mikrotik] Failover via Netwatch III (English)

#1
Information 
The purpose of this script is to provide a solution for loss of service from ISP providers. The idea is for a topology where there are two different ISP providers, one of them provides a static IP and the other provides a dynamic IP address.

It is important to clarify that DNS should be usable from either ISP connection. This is because each ISP has its own DNS service. If a connection is lost it is likely that ISP 2 will not be able to connect to the DNS at ISP 1 and DNS requests will not be allowed to be resolved. The solution to this is to use a public DNS service such as Open DNS.

OK. For Copy & Paste fans, here is the code, more explanation follows the code below.

Codice:
/tool netwatch

Codice:
add comment=Test1 disabled=no down-script="/tool netwatch set [find comment=\"Test2\"] disabl\

Codice:
ed=no\r\

Codice:
\n/tool netwatch set [find comment=\"Test1\"] disabled=yes" host=74.125.47.104 interval=\

Codice:
30s timeout=2s up-script=""

Codice:
add comment=Test2 disabled=yes down-script=":global GA\r\

Codice:
\n:global GA [/ip dhcp-client get \"ether2 Fibertel\" gateway ]\r\

Codice:
\n/ip route set [find comment=\"Fibertel\"] gateway=\$GA\r\

Codice:
\n/ip route set [find comment=\"Telefonica\"] disabled=yes\r\

Codice:
\n/ip route set [find comment=\"Fibertel\"] disabled=no\r\

Codice:
\n/tool e-mail send to=\"EMAIL ADDRESS\" body=\"Connection with Telefonica Lost\

Codice:
, Switched to Fibertel\" subject=\"Lost connection with Telefonica\"\r\

Codice:
\n/tool netwatch set [find comment=\"Test3\"] disabled=no\r\

Codice:
\n/tool netwatch set [find comment=\"Test2\"] disabled=yes" host=209.191.93.52 interval=\

Codice:
30s timeout=2s up-script=":delay 10ms\r\

Codice:
\n:log warning \"Started Test2\"\r\

Codice:
\n/tool netwatch set [find comment=\"Test1\"] disabled=no\r\

Codice:
\n/tool netwatch set [find comment=\"Test2\"] disabled=yes"

Codice:
add comment=Test3 disabled=yes down-script="/tool netwatch set [find comment=\"Test4\"] disab\

Codice:
led=no\r\

Codice:
\n/tool netwatch set [find comment=\"Test3\"] disabled=yes" host=64.233.169.104 \

Codice:
interval=30s timeout=2s up-script=""

Codice:
add comment=Test4 disabled=yes down-script="/ip route set [find comment=\"Fibertel\"] disable\

Codice:
d=yes\r\

Codice:
\n/ip route set [find comment=\"Telefonica\"] disabled=no\r\

Codice:
\n/tool e-mail send to=\"EMAIL ADDRESS\" body=\"Telefonica Connection Lost and Fi\

Codice:
bertel took over, Trying to restore Telefonica\" subject=\"Loss of service type 2\"\r\

Codice:
\n/tool netwatch set [find comment=\"Test1\"] disabled=no\r\

Codice:
\n/tool netwatch set [find comment=\"Test4\"] disabled=yes" host=209.191.93.55 interval=\

Codice:
30s timeout=2s up-script=":delay 10ms\r\

Codice:
\n:log warning \"Started Test4\"\r\

Codice:
\n/tool netwatch set [find comment=\"Test3\"] disabled=no\r\

Codice:
\n/tool netwatch set [find comment=\"Test4\"] disabled=yes"


How it works:

The solution is composed of 4 netwatch tests.

The first test 1 checks www.google.com, if for some reason this address stops responding to pings then it enables test2 and test1 disables itself.

Test2 pings www.yahoo.com, if the result is UP it enables test1 and test2 disables itself. If the result is "DOWN", test2 looks for the address of the gateway of the ISP on a dynamic IP and configures that address as a static route, followed by disabling the static route of the ISP on a static IP and enabling the dynamic IP route previously mentioned. It then sends an alert e-mail and enables test3 (for the new dynamic ISP) and test2 disables itself.

Test 3 and test4 do the same thing as test1 and test2 respectively. Only in this case, test4 would release the dynamic ISP and re-enable the static ISP.
Cita messaggio


Discussioni simili
Discussione Autore Risposte Letto Ultimo messaggio
Information [Mikrotik] Netwatch on web berryberry 0 1'556 17-06-2015, 11:40
Ultimo messaggio: berryberry
Information [Mikrotik] Failover Scripting berryberry 0 1'000 16-06-2015, 11:17
Ultimo messaggio: berryberry
Information [Mikrotik] Improved Netwatch II berryberry 0 900 16-06-2015, 09:54
Ultimo messaggio: berryberry
Information [Mikrotik ] Improved Netwatch berryberry 0 900 16-06-2015, 09:52
Ultimo messaggio: berryberry
Information [Mikrotik] Resilience /Monitoring -ECMP Failover Script berryberry 0 1'156 16-06-2015, 09:45
Ultimo messaggio: berryberry
  Netwatch kikko 31 12'266 03-12-2013, 18:38
Ultimo messaggio: kikko

Digg   Delicious   Reddit   Facebook   Twitter   StumbleUpon  


Utenti che stanno guardando questa discussione:
1 Ospite(i)


Powered by MyBB, © 2002-2020 MyBB Group.