Tuesday, March 13, 2012

Mikrotik System Failover dengan Netwatch dan Script

Source :
http://www.mikrotik.com
http://supermenbanget.wordpress.com
http://indonesiacyber.net

Contoh Failover pada Load balancing dgn policy routing berdasarkan ip address client

/ip route
add dst-address=0.0.0.0/0 gateway=192.168.1.1 ( ip modem speedy1 ) routing-mark=speedy1 comment="speedy1"
add dst-address=0.0.0.0/0 gateway=192.168.2.14 ( ip modem speedy2 ) routing-mark=speedy2 comment="speedy2"

Routing Untuk Mikrotik agar dapat melakukan ping ke ip public speedy1 dan speedy2

/ip route
add dst-address=110.220.33.1/32 ( ip public modem dari speedy1 ) gateway=192.168.1.1
add dst-address=112.1.2.3/32 ( ip public modem dari speedy2 ) gateway=192.168.2.14

Set Netwatch terlebih dahulu.

Definisi Argumen di Netwatch :
interval - Waktu antar Ping dieksekusi. Menurunkan nilai interval akan membuatnya lebih responsiv, tapi bisa menimbulkan traffic yang tidak penting dan memakan lebih banyak memori. Defaultnya 1 menit.
timeout - Timeout untuk setiap ping. Jika tidak ada reply yg diterima dari host selama waktu ini, host akan dianggap unreachable ("down").

1 second = 1000 milisecond/ tool netwatch
add host=112.1.2.3 timeout=1000ms interval=40s up-script=speedy2_up \
    down-script=speedy2_down comment="" disabled=no
add host=110.220.33.1 timeout=1000ms interval=40s up-script=speedy1_up \
    down-script=speedy1_down comment="" disabled=no























Setelah itu kita set Scriptnya.

/ system script
add name="speedy1_down" source="/ip route set \[find comment=\"speedy1\"\] gateway=192.168.2.14" \
    policy=ftp,reboot,read,write,policy,test,winbox,password
add name="speedy1_up" source="/ip route set \[find comment=\"speedy1\"\] gateway=192.168.1.1" \
    policy=ftp,reboot,read,write,policy,test,winbox,password
add name="speedy2_up" source="/ip route set \[find comment=\"speedy2\"\] gateway=192.168.2.14" \
    policy=ftp,reboot,read,write,policy,test,winbox,password
add name="speedy2_down" source="/ip route set \[find comment=\"speedy2\"\] gateway=192.168.1.1" \
    policy=ftp,reboot,read,write,policy,test,winbox,password



























Command yang dimasukkan dimasing-masing source :

/ip route set [find comment="speedy2"] gateway=192.168.1.1

/ip route set [find comment="speedy2"] gateway=192.168.2.14

/ip route set [find comment="speedy1"] gateway=192.168.2.14

/ip route set [find comment="speedy1"] gateway=192.168.1.1

Contoh 3 Rule dijalankan dalam satu script :

/ip firewall filter set [find comment="Drop1"] protocol=tcp ;
/ip firewall mangle set [find comment="open"] in-interface=ether2-local-master ;
/queue simple set [find comment="sw22"] max-limit=256k/1M



Satu lagi contoh script failover :

/ip firewall mangle set [find comment="lb1"] in-interface=pppoe-out1 ;
/ip route set [find comment="speedy1mb"] gateway=180.241.246.1 ;
/ip route set [find comment="failover"] gateway=180.241.246.1

/ip firewall mangle set [find comment="lb1"] in-interface=ether3-local-slave ;
/ip route set [find comment="speedy1mb"] gateway=172.16.0.1 ;
/ip route set [find comment="failover"] gateway=172.16.0.1,180.241.246.1,180.241.246.1

/ip firewall mangle set [find comment="lb2"] in-interface=ether3-local-slave ;
/ip route set [find comment="speedy2mb"] gateway=172.16.0.1 ;
/ip route set [find comment="failover"] gateway=172.16.0.1

/ip firewall mangle set [find comment="lb2"] in-interface=pppoe-out1 ;
/ip route set [find comment="speedy2mb"] gateway=180.241.246.1 ;
/ip route set [find comment="failover"] gateway=172.16.0.1,180.241.246.1,180.241.246.1

Selamat mencoba :)

No comments:

Post a Comment