Script load balance mikrotik 2 isp
Sebelum kalian menggunakan script ini ada baiknya load balance tidak dilakukan pada router mikrotik yang sudah terkonfigurasi hotspot karena akan menyebabkan hotspot kalian tidak bisa menampilkan login page, jadi saran saya lakukan load balance pada router yang tidak memiliki konfigurasi apapun.
Topologi
Untuk topologi yang nantinya akan digunakan pada load balance ini silahkan sesuaikan dengan gambar yang ada, port 1 dan 2 hanya contoh umum. Kalian bisa memindahkanya ke port lain yang terpenting adalah pada bagian script jangan lupa untuk disesuaikan dengan port ethernet kalian masing-masing.
Penjelasan
- Ehter 1 : ISP 1
- Ether 2 : ISP 2
- Ether 3 : Ether/port lan yang mengarah ke distribusi baik client maupun private network
Jangan lupa diganti sesuai dengan data ip isp kalian ya
- 192.168.1.1 : ip address isp 1 atau isp pertama
- 192.168.2.1 : ip address isp 2 atau isp kedua
- ether1 : port lan yang mengarah ke isp 1
- ether2 : port lan yang mengarah ke isp 2
Cara mengoperasikan script ini sama seperti script pada postingan sebelumnya yaitu tinggal paste ke terminal mikrotik.
Berikut scriptnya :
Script untuk menambahkan ip lokal.
/ip firewall address-list
add address=192.168.0.0/16 list=LOCAL-IP
add address=172.16.0.0/12 list=LOCAL-IP
add address=10.0.0.0/8 list=LOCAL-IP
Script untuk melakukan nat pada interface.
/ip firewall nat
add chain=srcnat out-interface="ether1" action=masquerade
add chain=srcnat out-interface="ether2" action=masquerade
Script routing.
/ip route
add check-gateway=ping distance=1 gateway="192.168.1.1" routing-mark="to-ether1"
add check-gateway=ping distance=1 gateway="192.168.2.1" routing-mark="to-ether2"
add check-gateway=ping distance=1 gateway="192.168.1.1"
add check-gateway=ping distance=2 gateway="192.168.2.1"
Script mangel.
/ip firewall mangle
add action=mark-connection chain=input in-interface="ether1" new-connection-mark="cm-ether1" passthrough=yes
add action=mark-connection chain=input in-interface="ether2" new-connection-mark="cm-ether2" passthrough=yes
add action=mark-routing chain=output connection-mark="cm-ether1" new-routing-mark="to-ether1" passthrough=yes
add action=mark-routing chain=output connection-mark="cm-ether2" new-routing-mark="to-ether2" passthrough=yes
add action=mark-connection chain=prerouting dst-address-list=!LOCAL-IP dst-address-type=!local new-connection-mark="cm-ether1" passthrough=yes per-connection-classifier=both-addresses-and-ports:2/0 src-address-list=LOCAL-IP
add action=mark-connection chain=prerouting dst-address-list=!LOCAL-IP dst-address-type=!local new-connection-mark="cm-ether2" passthrough=yes per-connection-classifier=both-addresses-and-ports:2/1 src-address-list=LOCAL-IP
add action=mark-routing chain=prerouting connection-mark="cm-ether1" dst-address-list=!LOCAL-IP new-routing-mark="to-ether1" passthrough=yes src-address-list=LOCAL-IP
add action=mark-routing chain=prerouting connection-mark="cm-ether2" dst-address-list=!LOCAL-IP new-routing-mark="to-ether2" passthrough=yes src-address-list=LOCAL-IP
Demikian tutorial ini, terima kasih sudah berkunjung. Semoga sehat dan sukses selalu.