Tuesday, December 23, 2014

Failover dengan 2 Dynamic Gateway Ip

2 line speedy dengan ip dinamis

 /ip route
add comment=game disabled=no distance=1 dst-address=0.0.0.0/0 gateway=pppoe-out1 routing-mark=game_routing scope=30 target-scope=10
add comment=browsing disabled=no distance=1 dst-address=0.0.0.0/0 gateway=pppoe-out2 scope=30 target-scope=10

Buat scriptnya dulu :
system -> scripts klik tanda +
Nama script = script1
Isi kotak source dengan script berikut :

#set variables
:local pingcount  10
:local wan1 pppoe-out1
:local wan2 pppoe-out2

#ping gateways with interface
:local pingresultA [/ping 8.8.8.8 interface=$wan2 count=$pingcount]
:local pingresultB [/ping 8.8.8.8 interface=$wan1 count=$pingcount]

#if link_A is DOWN and link_B is UP then:
:if (($pingresultA=0) && ($pingresultB=10)) do={
/ip route set [find comment="browsing"] gateway=$wan1
}

#if link_A is UP and link_B is DOWN then:
:if (($pingresultA=10) && ($pingresultB=0)) do={
/ip route set [find comment="browsing"] gateway=$wan2
/ip route set [find comment="game"] gateway=$wan2
}

#if both link DOWN:
:if (($pingresultA=0) && ($pingresultB=0)) do={
/ip route set [find comment="browsing"] gateway=$wan2
/ip route set [find comment="game"] gateway=$wan1
}

# Link A or Link B both are UP:
:if (($pingresultA=$pingcount) && ($pingresultB=$pingcount)) do={

#set gateway back to GatewayB
/ip route set [find comment="browsing"] gateway=$wan2
/ip route set [find comment="game"] gateway=$wan1
}

Kemudian buat schedulernya :
/system scheduler
add name="fail over" on-event=script1 start-date=jan/01/1970 start-time=00:00:00 interval=10s comment="" disabled=no

source : Improved_Load_Balancing_over_Multiple_Gateways_Failover_Script

No comments:

Post a Comment