Skrip Sederhana Fail Over 2 Gateway Mikrotik

Kebetulan ane punya 2 gateway… berhubung males pindah2in manual, berpikir deh dikit untuk otomatis pindah gateway. Jika salah satu ada yang pudur disini saya cuma memisahkan iix dan ix dengan nice nya mikrotik.co.id dan ntu saya tambahin port na games online sederhana..


Kenapa dns tidak menggunakan 8.8.8.8 dan 8.8.4.4 ? karena dns google digunakan untuk deteksi masing2 gateway

so cekidot…

/ip address
add address=10.10.10.2/30 interface=ether1
add address=11.11.11.2/30 interface=ether2
add address=192.168.88.1/24 inteface=ether3
/ip route
add dst-address=8.8.8.8 gateway=10.10.10.1 check-gateway=ping routing-mark=GW1
add dst-address=8.8.4.4 gateway=11.11.11.1 check-gateway=ping routing-mark=GW2
add gateway=10.10.10.1 routing-mark=GW1
add gateway=11.11.11.1 routing-mark=GW2
/ip dns set servers=208.67.222.222,208.67.220.220 allow-remote-requests=yes
/ip firewall nat
add comment="FORCED DNS" chain=dstnat action=dst-nat to-addresses=208.67.222.222 to-ports=5353 protocol=udp dst-port=53 log=no log-prefix=""
add chain=dstnat action=dst-nat to-addresses=208.67.222.222 to-ports=5353 protocol=tcp dst-port=53 log=no log-prefix=""
add comment="NAT" chain=srcnat action=masquerade src-address=192.168.88.0/24 log=no log-prefix=""
/ip firewall mangle
add comment="GW1" chain=prerouting action=mark-routing new-routing-mark=GW1 passthrough=yes src-address=192.168.88.0/24 dst-address-list=nice log=no log-prefix=""
add comment="BGW1" chain=prerouting action=mark-routing new-routing-mark=GW2 passthrough=yes src-address=192.168.88.0/24 dst-address-list=nice log=no log-prefix=""
add comment="GW2" chain=prerouting action=mark-routing new-routing-mark=GW2 passthrough=yes src-address=192.168.88.0/24 dst-address-list=!nice log=no log-prefix=""
add comment="BGW2" chain=prerouting action=mark-routing new-routing-mark=GW1 passthrough=yes src-address=192.168.88.0/24 dst-address-list=!nice log=no log-prefix=""
add comment="ICMP" chain=output action=mark-packet new-packet-mark=icmp passthrough=yes protocol=icmp log=no log-prefix=""
add chain=input action=mark-packet new-packet-mark=icmp passthrough=yes protocol=icmp log=no log-prefix=""
add comment="MIKROTIK" chain=output action=mark-packet new-packet-mark=mikrotik passthrough=no protocol=tcp dst-port=8291 log=no log-prefix=""
add chain=prerouting action=mark-packet new-packet-mark=mikrotik passthrough=no protocol=tcp dst-port=8291 log=no log-prefix=""
add comment="GAMES" chain=prerouting action=mark-packet new-packet-mark=games passthrough=no protocol=tcp port=20000,1818,2001,3010,4300,5105,5121,5126,5171,5340-5352,6000-6152,7777 log=no log-prefix=""
add chain=prerouting action=mark-packet new-packet-mark=games passthrough=no protocol=tcp port=7341-7350,7451,8085,9600,9601-9602,9300,9376-9377,9400,9700,10001-10011 log=no log-prefix=""
add chain=prerouting action=mark-packet new-packet-mark=games passthrough=no protocol=tcp port=10402,11011-11041,12011,12110,13008,13413,15000-15002,16402-16502,16666,18900-18909,19000 log=no log-prefix=""
add chain=prerouting action=mark-packet new-packet-mark=games passthrough=no protocol=tcp port=19101,22100,27780,28012,29000,29200,39100,39110,39220,39190,40000,49100 log=no log-prefix=""
add chain=prerouting action=mark-packet new-packet-mark=games passthrough=no protocol=udp port=1293,1479,6100-6152,7777-7977,9401,9600-9602,12020-12080,30000,40000-40010 log=no log-prefix=""
add chain=prerouting action=mark-packet new-packet-mark=games passthrough=no protocol=udp port=42051-42052,11100-11125,11440-11460,14009-14026,15100-15150,30002-30020,11004 log=no log-prefix=""
add chain=prerouting action=mark-packet new-packet-mark=games passthrough=no protocol=tcp port=14009-14017,9601-9602,14300-14440,19000,6215,621,28901-28925,27932-27935,9100-9300 log=no log-prefix=""
/tool netwatch
add comment="Monitoring GW1" down-script="/ip firewall mangle disable [find c
omment="GW2"]r
n/ip firewall mangle enable [find comment="BGW2"]r
n" host=8.8.8.8 interval=10s timeout=10s up-script="/ip firewall mangle e
nable [find comment="GW2"]r
n/ip firewall mangle disable [find comment="BGW2"]r
n"
add comment="Monitoring GW2" down-script="/ip firewall mangle disable [find com
ment="GW1"]r
n/ip firewall mangle enable [find comment="BGW1"]r
n" host=8.8.4.4 interval=10s timeout=10s up-script="/ip firewall mangle e
nable [find comment="GW1"]r
n/ip firewall mangle disable [find comment="BGW1"]r
nr
n"

Add a Comment

Alamat email Anda tidak akan dipublikasikan. Ruas yang wajib ditandai *

This site uses Akismet to reduce spam. Learn how your comment data is processed.

Open chat