0% found this document useful (0 votes)
248 views

Script Mikrotik Failover

The document evaluates internet services on two WAN connections (WAN1 and WAN2) by performing ping tests to an external IP address. It checks the status of each WAN connection, and if ping tests fail, it disables firewall rules and logs a message for that WAN. Otherwise, if ping tests pass, firewall rules are enabled and status is logged as OK. Gateway addresses are also checked and updated for WAN2.

Uploaded by

lcar197702
Copyright
© © All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as TXT, PDF, TXT or read online on Scribd
0% found this document useful (0 votes)
248 views

Script Mikrotik Failover

The document evaluates internet services on two WAN connections (WAN1 and WAN2) by performing ping tests to an external IP address. It checks the status of each WAN connection, and if ping tests fail, it disables firewall rules and logs a message for that WAN. Otherwise, if ping tests pass, firewall rules are enabled and status is logged as OK. Gateway addresses are also checked and updated for WAN2.

Uploaded by

lcar197702
Copyright
© © All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as TXT, PDF, TXT or read online on Scribd
You are on page 1/ 2

:log info

"-------------------------------------------------------------------------------";
:log info " QUIMICA CMV GROUP ";
:log info " Evaluando Servicios de Internet ";
:log info
"-------------------------------------------------------------------------------";
:local nPruebasPing 3;
:local ipExterna "8.8.8.8";
:local hora [/system clock get time]

:log info "Evaluando WAN1 $hora";


#:local rping [/ping $ipExterna interface="ether1-WAN1" count=$nPruebasPing];

:local rping [/ping $ipExterna routing-table="hacia_WAN1" count=$nPruebasPing];

# Si la respuesta de ping fue 0, entonces el ISP est� caido y se agrega a la lista


de ispsCaidos
:if ($rping=0) do={
:log info "Estado...... sin servicio";
if ([/ip firewall mangle get [find comment="WAN1"] disable]=no) do={
/system script run noip2
/ip firewall mangle disable [find comment="WAN1"];
:log info "New Conection Mark WAN1 Inhabilitado..!!!";
}

}
:if ([/interface get [find name="ether1-WAN1"] disable]=yes) do={
:log info "Motivo...... Interface WAN1 esta INHABILITADO";

}
:if ($rping=3) do={
:log info "Estado...... Ok!";
if ([/ip firewall mangle get [find comment="WAN1"] disable]=yes) do={
/system script run noip1
/ip firewall mangle enable [find comment="WAN1"];
:log info "New Conection Mark WAN1 Habilitado..!!!";
}

}
:log info
"-------------------------------------------------------------------------------";

:local rgwant [/ip route get [find distance=2] gateway];


:local rgwact [/ip route get [find distance=3] gateway];

:local hora [/system clock get time]


:log info "Evaluando WAN2 $hora";
:log info "Gateway... $rgwant";

if ( $rgwact != $rgwant ) do={


/ip route set [find distance=2] gateway=$rgwact;
:log info "Gateway actualizado a $rgwact";
}
:local rping [/ping $ipExterna routing-table="hacia_WAN2" count=$nPruebasPing];

# Si la respuesta de ping fue 0, entonces el ISP est� caido y se agrega a la lista


de ispsCaidos
:if ($rping=0) do={
:log info "Estado...... sin servicio";
if ([/ip firewall mangle get [find comment="WAN2"] disable]=no) do={
/ip firewall mangle disable [find comment="WAN2"];
:log info "New Conection Mark WAN2 Inhabilitado..!!!";
}
}
:if ([/interface get [find name="ether2-WAN2"] disable]=yes) do={
:log info "Motivo...... Interface WAN2 esta INHABILITADO";
}
:if ($rping=3) do={
:log info "Estado...... Ok!";
if ([/ip firewall mangle get [find comment="WAN2"] disable]=yes) do={
/ip firewall mangle enable [find comment="WAN2"];
:log info "New Conection Mark WAN2 Habilitado..!!!";
}
}
:log info
"-------------------------------------------------------------------------------";

You might also like

pFad - Phonifier reborn

Pfad - The Proxy pFad of © 2024 Garber Painting. All rights reserved.

Note: This service is not intended for secure transactions such as banking, social media, email, or purchasing. Use at your own risk. We assume no liability whatsoever for broken pages.


Alternative Proxies:

Alternative Proxy

pFad Proxy

pFad v3 Proxy

pFad v4 Proxy