Ciao a tutti sono qua che combatto per far funzionare uno script in modo che se la connessione principale cade subentri quella di backup.
rb750
ether1=wan1
ip 192.168.1.5
gw 192.168.1.252
ether2=wan1
ip 192.168.0.5
gw 192.168.0.1
ether3= LAN
ip 10.1.0.1 (GATEWAY LOCALE)
Dal momento che a monte ho 2 router (1 per adsl) non posso usare distance 1 & 2 in quanto se la connettività cade ma il router resta acceso non fa lo switch delle adsl.
Cercando sul wiki os ho trovato quello che fa al caso mio, ma non riesco a capire come configurare RB750.
gli script li ho capiti, ma no capisco come impostare alla base il MT;
Allego script
crea lo scheduler
/ system scheduler
add name="ping_google_link_A-up" on-event=schedule_A_up start-date=jan/01/1970 \
start-time=00:00:00 interval=5s comment="" disabled=yes
add name="ping_google_link_A-down" on-event=schedule_A_down \
start-date=jan/01/1970 start-time=00:00:00 interval=5s comment="" \
disabled=no
scripts go up
#set variables
:local pingcount 3
:local ipA 192.168.0.5
:local GatewayA 192.168.0.1
:local ipB 192.168.1.5
:local GatewayB 192.168.1.252
:local GatewayC 10.1.0.1
#ping gateways with src
:local pingresultA [/ping http://www.google.com src-address=$ipA count=$pingcount]
:local pingresultB [/ping http://www.google.com src-address=$ipB count=$pingcount]
#if link_A is DOWN and link_B is UP then:
:if (($pingresultA=0) && ($pingresultB=3)) do={
/ip route set [find comment="Default Gateway"] gateway=$GatewayB
}
#if link_A is UP and link_B is DOWN then:
:if (($pingresultA=3) && ($pingresultB=0)) do={
/ip route set [find comment="Default Gateway"] gateway=$GatewayA
}
#if both link DOWN:
:if (($pingresultA=0) && ($pingresultB=0)) do={
/ip route set [find comment="Default Gateway"] gateway=$GatewayC
}
# Link A or Link B both are UP:
:if (($pingresultA=$pingcount) && ($pingresultB=$pingcount)) do={
#send alert email
/tool e-mail send subject=($ipA . "is up now") \
body=("the gateway is backed up at: " . [/system clock get date]) \ to=("XXXXXX@gmail.com")
#disable all multi-session balancing mangles
/ip firewall mangle set [find chain=prerouting in-interface=LAN \
connection-mark=even action=mark-routing passthrough=no] disabled=no
/ip firewall mangle set [find chain=prerouting in-interface=LAN \
connection-state=new new-connection-mark=even passthrough=yes \
action=mark-connection nth=1,1,1] disabled=no
/ip firewall mangle set [find chain=prerouting in-interface=LAN \
connection-mark=odd action=mark-routing new-routing-mark=odd \
passthrough=no] disabled=no
/ip firewall mangle set [find chain=prerouting in-interface=LAN nth=1,1,0 \
action=mark-connection new-connection-mark=odd \
passthrough=yes] disabled=no
#disable current scheduler
/system scheduler set [find name=ping_google_link_A-down] disabled=no
#enable -up scheduler
/system scheduler set [find name=ping_google_link_A-up] disabled=yes
#set gateway back to GatewayB
/ip route set [find comment="Default Gateway"] gateway=$GatewayB
}
Scripts go Down
#set variables
:local pingcount 3
:local ipA 192.168.0.5
:local GatewayA 192.168.0.1
:local ipB 192.168.1.5
:local GatewayB 192.168.1.252
:global state no
#ping gateways with src
:local pingresultA [/ping http://www.google.com src-address=$ipA count=$pingcount]
:local pingresultB [/ping http://www.google.com src-address=$ipB count=$pingcount]
# Link A or Link B is down then>
:if (($pingresultA=0) || ($pingresultB=0)) do={
#send email
/tool e-mail send subject=($ipA . " is down") \
body=("the gateway is down now at: " . [/system clock get date]) \ to=("XXXXXX@gmail.com")
#disable all multi-session balancing mangles
/ip firewall mangle set [find chain=prerouting in-interface=LAN \
connection-mark=even action=mark-routing passthrough=no] disabled=yes
/ip firewall mangle set [find chain=prerouting in-interface=LAN \
connection-state=new new-connection-mark=even passthrough=yes \
action=mark-connection nth=1,1,1] disabled=yes
/ip firewall mangle set [find chain=prerouting in-interface=LAN \
connection-mark=odd action=mark-routing new-routing-mark=odd \
passthrough=no] disabled=yes
/ip firewall mangle set [find chain=prerouting in-interface=LAN nth=1,1,0 \
action=mark-connection new-connection-mark=odd \
passthrough=yes] disabled=yes
#disable current scheduler
/system scheduler set [find name=ping_google_link_A-down] disabled=yes
#enable -up scheduler
/system scheduler set [find name=ping_google_link_A-up] disabled=no
#set gateway to secondary or tertiary
#if link_A is DOWN and link_B is UP then:
:if (($pingresultA=0) && ($pingresultB>0)) do={
/ip route set [find comment="Default Gateway"] gateway=192.168.1.252
}
#if link_A is UP and link_B is DOWN then:
:if (($pingresultA>0) && ($pingresultB=0)) do={
/ip route set [find comment="Default Gateway"] gateway=192.168.0.1
}
#if link_A and link_B both were DOWN then:
:if (($pingresultA=0) && ($pingresultB=0)) do={
/ip route set [find comment="Default Gateway"] gateway=10.1.0.1
}
}
Ho configurato le schede con gli ip come sopra descritti nello script, poi ero in dubbio se creare la tavola di route e ho provato ma senza risultati se non una route statica.
Portate pazienza se ho scritto castronerie.
Il link del wiki da cui ho preso il tutto è il seguente
http://wiki.mikrotik.com/wiki/Improved_Load_Balancing_over_Multiple_Gateways_Failover_Script
Spero possiate essermi di aiuto e di essere stato chiaro.
Ciao e grazie a tutti