Pendahuluan
Kebutuhan Internet yang begitu di butuhkan di banyak bidang. membuat kebutuhan internet semakin pesat, sebagai pengelola jaringan kita di haruskan untuk menciptakan koneksi internet yang baik. Load Balancing Mikrotik merupakan salah satu cara untuk menciptakan internet yang baik dengan cara menggabungkan beberapa koneksi sumber internet menjadi satu.
Ada Beberapa cara untuk melakukannya Berikut ini adalah beberapa tutotial tersebut:
Load Balancing Metode PCC
Metode PCC atau Per Connection Classifier Merupakan salah satu metode Load Balancing mikrotik dengan cara mengelompokan trafik koneksi yang melalui atau keluar masuk router menjadi beberapa kelompok.
Bagaimana cara melakukan konfigurasi Load Balance Metode PCC di Mikrotik ?.
Kamu bisa menggunakan terminal atau bisa ssh melalui terminal di winbox yang kamu miliki
RouterOs v6
jika kamu menggunakan routerOs v6 kamu bisa menggunakan kode berikut :
Tambahkan address-list dengan IP Local kamu.
/ip firewall address-list
add address=192.168.0.0/16 list=LOCAL-IP comment="LB PCC by buananetpbun.github.io"
add address=172.16.0.0/12 list=LOCAL-IP comment="LB PCC by buananetpbun.github.io"
add address=10.0.0.0/8 list=LOCAL-IP comment="LB PCC by buananetpbun.github.io"
Tambahkah nat- srcnat dengan action masquerade ke ether 1 dan ether 2 karna mikrotik yang kita gunakan untuk praktek menggunakan nama ISP-1 dan ISP-2, maka masukkan nama tersebut di Script kita.
/ip firewall nat
add chain=srcnat out-interface="ISP1" action=masquerade comment="LB PCC by buananetpbun.github.io"
add chain=srcnat out-interface="ISP2" action=masquerade comment="LB PCC by buananetpbun.github.io"
tambahkan juga routing ke gateway ISP-1 dan ISP-2
/ip route
add check-gateway=ping distance=1 gateway="192,168.0.1" routing-mark="to-ISP1" comment="LB PCC by buananetpbun.github.io"
add check-gateway=ping distance=1 gateway="192,168.1.1" routing-mark="to-ISP2" comment="LB PCC by buananetpbun.github.io"
add check-gateway=ping distance=1 gateway="192,168.0.1" comment="LB PCC by buananetpbun.github.io"
add check-gateway=ping distance=2 gateway="192,168.1.1" comment="LB PCC by buananetpbun.github.io"
Kemudian tambahkan mangle berikut :
/ip firewall mangle
add action=accept chain=prerouting dst-address-list=LOCAL-IP src-address-list=LOCAL-IP comment="LB PCC by buananetpbun.github.io"
add action=accept chain=postrouting dst-address-list=LOCAL-IP src-address-list=LOCAL-IP comment="LB PCC by buananetpbun.github.io"
add action=accept chain=forward dst-address-list=LOCAL-IP src-address-list=LOCAL-IP comment="LB PCC by buananetpbun.github.io"
add action=accept chain=input dst-address-list=LOCAL-IP src-address-list=LOCAL-IP comment="LB PCC by buananetpbun.github.io"
add action=accept chain=output dst-address-list=LOCAL-IP src-address-list=LOCAL-IP comment="LB PCC by buananetpbun.github.io"
add action=mark-connection chain=input in-interface="ISP1" new-connection-mark="cm-ISP1" passthrough=yes comment="LB PCC by buananetpbun.github.io"
add action=mark-connection chain=input in-interface="ISP2" new-connection-mark="cm-ISP2" passthrough=yes comment="LB PCC by buananetpbun.github.io"
add action=mark-routing chain=output connection-mark="cm-ISP1" new-routing-mark="to-ISP1" passthrough=yes comment="LB PCC by buananetpbun.github.io"
add action=mark-routing chain=output connection-mark="cm-ISP2" new-routing-mark="to-ISP2" passthrough=yes comment="LB PCC by buananetpbun.github.io"
add action=mark-connection chain=prerouting dst-address-type=!local new-connection-mark="cm-ISP1" passthrough=yes per-connection-classifier=both-addresses-and-ports:2/0 dst-address-list=!LOCAL-IP src-address-list=LOCAL-IP comment="LB PCC by buananetpbun.github.io"
add action=mark-connection chain=prerouting dst-address-type=!local new-connection-mark="cm-ISP2" passthrough=yes per-connection-classifier=both-addresses-and-ports:2/1 dst-address-list=!LOCAL-IP src-address-list=LOCAL-IP comment="LB PCC by buananetpbun.github.io"
add action=mark-routing chain=prerouting connection-mark="cm-ISP1" new-routing-mark="to-ISP1" passthrough=yes dst-address-list=!LOCAL-IP src-address-list=LOCAL-IP comment="LB PCC by buananetpbun.github.io"
add action=mark-routing chain=prerouting connection-mark="cm-ISP2" new-routing-mark="to-ISP2" passthrough=yes dst-address-list=!LOCAL-IP src-address-list=LOCAL-IP comment="LB PCC by buananetpbun.github.io"
kamu juga bisa menghapus konfigurasi ini dengan menggunakan telnet/terminal dengan cara berikut :
/ip firewall nat remove [find comment="LB PCC by buananetpbun.github.io"]
/ip route remove [find comment="LB PCC by buananetpbun.github.io"]
/ip firewall mangle remove [find comment="LB PCC by buananetpbun.github.io"]
/ip firewall address-list remove [find comment="LB PCC by buananetpbun.github.io"]
/routing table remove [find comment="LB PCC by buananetpbun.github.io"]
Script By : buananetpbun
RouterOs v7
jika kamu menggunakan routerOs v6 kamu bisa menggunakan kode berikut :
Tambahkan address-list dengan IP Local kamu.
/ip firewall address-list
add address=192.168.0.0/16 list=LOCAL-IP comment="LB PCC by buananetpbun.github.io"
add address=172.16.0.0/12 list=LOCAL-IP comment="LB PCC by buananetpbun.github.io"
add address=10.0.0.0/8 list=LOCAL-IP comment="LB PCC by buananetpbun.github.io"
Tambahkah nat- srcnat dengan action masquerade ke ether1 dan ether2 karena mikrotik yang kita gunakan untuk praktek menggunakan nama ISP-1 dan ISP-2, maka masukkan nama tersebut di Script kita.
/ip firewall nat
add chain=srcnat out-interface="ISP1" action=masquerade comment="LB PCC by buananetpbun.github.io"
add chain=srcnat out-interface="ISP2" action=masquerade comment="LB PCC by buananetpbun.github.io"
Setelah itu tambahkan juga routing table ke ISP1 dan ISP2
/routing table
add name="to-ISP1" fib comment="LB PCC by buananetpbun.github.io"
add name="to-ISP2" fib comment="LB PCC by buananetpbun.github.io"
Kemudian tambahkan route ke ISP1 dan ISP2
/ip route
add check-gateway=ping distance=1 gateway="192,168.0.1" routing-table="to-ISP1" comment="LB PCC by buananetpbun.github.io"
add check-gateway=ping distance=1 gateway="192,168.1.1" routing-table="to-ISP2" comment="LB PCC by buananetpbun.github.io"
add check-gateway=ping distance=1 gateway="192,168.0.1" comment="LB PCC by buananetpbun.github.io"
add check-gateway=ping distance=2 gateway="192,168.1.1" comment="LB PCC by buananetpbun.github.io"
jangan lupa tambahkan mangle agar loadbalancing ke ISP 1 dan ISP 2 kamu bisa berjalan dengan lancar.
/ip firewall mangle
add action=accept chain=prerouting dst-address-list=LOCAL-IP src-address-list=LOCAL-IP comment="LB PCC by buananetpbun.github.io"
add action=accept chain=postrouting dst-address-list=LOCAL-IP src-address-list=LOCAL-IP comment="LB PCC by buananetpbun.github.io"
add action=accept chain=forward dst-address-list=LOCAL-IP src-address-list=LOCAL-IP comment="LB PCC by buananetpbun.github.io"
add action=accept chain=input dst-address-list=LOCAL-IP src-address-list=LOCAL-IP comment="LB PCC by buananetpbun.github.io"
add action=accept chain=output dst-address-list=LOCAL-IP src-address-list=LOCAL-IP comment="LB PCC by buananetpbun.github.io"
add action=mark-connection chain=input in-interface="ISP1" new-connection-mark="cm-ISP1" passthrough=yes comment="LB PCC by buananetpbun.github.io"
add action=mark-connection chain=input in-interface="ISP2" new-connection-mark="cm-ISP2" passthrough=yes comment="LB PCC by buananetpbun.github.io"
add action=mark-routing chain=output connection-mark="cm-ISP1" new-routing-mark="to-ISP1" passthrough=yes comment="LB PCC by buananetpbun.github.io"
add action=mark-routing chain=output connection-mark="cm-ISP2" new-routing-mark="to-ISP2" passthrough=yes comment="LB PCC by buananetpbun.github.io"
add action=mark-connection chain=prerouting dst-address-type=!local new-connection-mark="cm-ISP1" passthrough=yes per-connection-classifier=both-addresses-and-ports:2/0 dst-address-list=!LOCAL-IP src-address-list=LOCAL-IP comment="LB PCC by buananetpbun.github.io"
add action=mark-connection chain=prerouting dst-address-type=!local new-connection-mark="cm-ISP2" passthrough=yes per-connection-classifier=both-addresses-and-ports:2/1 dst-address-list=!LOCAL-IP src-address-list=LOCAL-IP comment="LB PCC by buananetpbun.github.io"
add action=mark-routing chain=prerouting connection-mark="cm-ISP1" new-routing-mark="to-ISP1" passthrough=yes dst-address-list=!LOCAL-IP src-address-list=LOCAL-IP comment="LB PCC by buananetpbun.github.io"
add action=mark-routing chain=prerouting connection-mark="cm-ISP2" new-routing-mark="to-ISP2" passthrough=yes dst-address-list=!LOCAL-IP src-address-list=LOCAL-IP comment="LB PCC by buananetpbun.github.io"
kamu juga bisa menghapus konfigurasi ini melalui telnet/terminal menggunakan cara berikut ini :
/ip firewall nat remove [find comment="LB PCC by buananetpbun.github.io"]
/ip route remove [find comment="LB PCC by buananetpbun.github.io"]
/ip firewall mangle remove [find comment="LB PCC by buananetpbun.github.io"]
/ip firewall address-list remove [find comment="LB PCC by buananetpbun.github.io"]
/routing table remove [find comment="LB PCC by buananetpbun.github.io"]
Script By : buananetpbun
Load Balancing Metode ECMP
Metode ECMP atau Equal-Cost Multipath Merupakan salah satu metode Load Balancing yang bekerja dengan teknik yang di gunakan untuk mendistribusikan lalu lintas jaringan secara merata atau seimbang di antara beberapa jalur atau rute yang sama.
RouterOs v6
/ip firewall address-list
add address=192.168.0.0/16 list=LOCAL-IP comment="LB ECMP by buananetpbun.github.io"
add address=172.16.0.0/12 list=LOCAL-IP comment="LB ECMP by buananetpbun.github.io"
add address=10.0.0.0/8 list=LOCAL-IP comment="LB ECMP by buananetpbun.github.io"
/ip firewall nat
add chain=srcnat out-interface="ISP1" action=masquerade comment="LB ECMP by buananetpbun.github.io"
add chain=srcnat out-interface="ISP2" action=masquerade comment="LB ECMP by buananetpbun.github.io"
/ip route
add check-gateway=ping distance=1 gateway="192.168.0.1,192.168.1.2,,,," comment="LB ECMP by buananetpbun.github.io"
add check-gateway=ping distance=1 gateway="192.168.0.1" routing-mark="to-ISP1" comment="LB ECMP by buananetpbun.github.io"
add check-gateway=ping distance=1 gateway="192.168.1.2" routing-mark="to-ISP2" comment="LB ECMP by buananetpbun.github.io"
/ip firewall mangle
add action=accept chain=prerouting dst-address-list=LOCAL-IP src-address-list=LOCAL-IP comment="LB ECMP by buananetpbun.github.io"
add action=accept chain=postrouting dst-address-list=LOCAL-IP src-address-list=LOCAL-IP comment="LB ECMP by buananetpbun.github.io"
add action=accept chain=forward dst-address-list=LOCAL-IP src-address-list=LOCAL-IP comment="LB ECMP by buananetpbun.github.io"
add action=accept chain=input dst-address-list=LOCAL-IP src-address-list=LOCAL-IP comment="LB ECMP by buananetpbun.github.io"
add action=accept chain=output dst-address-list=LOCAL-IP src-address-list=LOCAL-IP comment="LB ECMP by buananetpbun.github.io"
add action=mark-connection chain=input in-interface="ISP1" new-connection-mark="cm-ISP1" passthrough=yes comment="LB ECMP by buananetpbun.github.io"
add action=mark-connection chain=input in-interface="ISP2" new-connection-mark="cm-ISP2" passthrough=yes comment="LB ECMP by buananetpbun.github.io"
add action=mark-routing chain=output connection-mark="cm-ISP1" new-routing-mark="to-ISP1" passthrough=yes comment="LB ECMP by buananetpbun.github.io"
add action=mark-routing chain=output connection-mark="cm-ISP2" new-routing-mark="to-ISP2" passthrough=yes comment="LB ECMP by buananetpbun.github.io"
RouterOs v7
/ip firewall address-list
add address=192.168.0.0/16 list=LOCAL-IP comment="LB ECMP by buananetpbun.github.io"
add address=172.16.0.0/12 list=LOCAL-IP comment="LB ECMP by buananetpbun.github.io"
add address=10.0.0.0/8 list=LOCAL-IP comment="LB ECMP by buananetpbun.github.io"
/ip firewall nat
add chain=srcnat out-interface="ISP1" action=masquerade comment="LB ECMP by buananetpbun.github.io"
add chain=srcnat out-interface="ISP2" action=masquerade comment="LB ECMP by buananetpbun.github.io"
/routing table
add name="to-ISP1" fib comment="LB ECMP by buananetpbun.github.io"
add name="to-ISP2" fib comment="LB ECMP by buananetpbun.github.io"
/ip route
add check-gateway=ping distance=1 gateway="192.168.0.1" routing-table="main" comment="LB ECMP by buananetpbun.github.io"
add check-gateway=ping distance=1 gateway="192.168.1.2" routing-table="main" comment="LB ECMP by buananetpbun.github.io"
add check-gateway=ping distance=1 gateway="192.168.0.1" routing-table="to-ISP1" comment="LB ECMP by buananetpbun.github.io"
add check-gateway=ping distance=1 gateway="192.168.1.2" routing-table="to-ISP2" comment="LB ECMP by buananetpbun.github.io"
/ip firewall mangle
add action=accept chain=prerouting dst-address-list=LOCAL-IP src-address-list=LOCAL-IP comment="LB ECMP by buananetpbun.github.io"
add action=accept chain=postrouting dst-address-list=LOCAL-IP src-address-list=LOCAL-IP comment="LB ECMP by buananetpbun.github.io"
add action=accept chain=forward dst-address-list=LOCAL-IP src-address-list=LOCAL-IP comment="LB ECMP by buananetpbun.github.io"
add action=accept chain=input dst-address-list=LOCAL-IP src-address-list=LOCAL-IP comment="LB ECMP by buananetpbun.github.io"
add action=accept chain=output dst-address-list=LOCAL-IP src-address-list=LOCAL-IP comment="LB ECMP by buananetpbun.github.io"
add action=mark-connection chain=input in-interface="ISP1" new-connection-mark="cm-ISP1" passthrough=yes comment="LB ECMP by buananetpbun.github.io"
add action=mark-connection chain=input in-interface="ISP2" new-connection-mark="cm-ISP2" passthrough=yes comment="LB ECMP by buananetpbun.github.io"
add action=mark-routing chain=output connection-mark="cm-ISP1" new-routing-mark="to-ISP1" passthrough=yes comment="LB ECMP by buananetpbun.github.io"
add action=mark-routing chain=output connection-mark="cm-ISP2" new-routing-mark="to-ISP2" passthrough=yes comment="LB ECMP by buananetpbun.github.io"
/ip firewall nat remove [find comment="LB ECMP by buananetpbun.github.io"]
/ip route remove [find comment="LB ECMP by buananetpbun.github.io"]
/ip firewall mangle remove [find comment="LB ECMP by buananetpbun.github.io"]
/ip firewall address-list remove [find comment="LB ECMP by buananetpbun.github.io"]
/routing table remove [find comment="LB ECMP by buananetpbun.github.io"]
Baca Juga : Mengenal Konfigurasi Dasar Pada Mikrotik.
Load Balancing Metode NTH
Load Balancing NTH (Next Hop Target) adalah salah satu teknik load balancing yang di gunakan dalam untuk konfigurasi jaringan, terutama pada perangkat MikroTik RouterOS. Selain itu, Teknik ini bertujuan untuk mendistribusikan lalu lintas jaringan secara merata di antara beberapa jalur atau koneksi yang tersedia berdasarkan tujuan atau “next hop” dari setiap koneksi.
RouterOs v6
/ip firewall address-list
add address=192.168.0.0/16 list=LOCAL-IP comment="LB NTH by buananetpbun.github.io"
add address=172.16.0.0/12 list=LOCAL-IP comment="LB NTH by buananetpbun.github.io"
add address=10.0.0.0/8 list=LOCAL-IP comment="LB NTH by buananetpbun.github.io"
/ip firewall nat
add chain=srcnat out-interface="ISP1" action=masquerade comment="LB NTH by buananetpbun.github.io"
add chain=srcnat out-interface="ISP2" action=masquerade comment="LB NTH by buananetpbun.github.io"
/ip route
add check-gateway=ping distance=1 gateway="192.168.0.1" routing-mark="to-ISP1" comment="LB NTH by buananetpbun.github.io"
add check-gateway=ping distance=1 gateway="192.168.1.1" routing-mark="to-ISP2" comment="LB NTH by buananetpbun.github.io"
add check-gateway=ping distance=1 gateway="192.168.0.1" comment="LB NTH by buananetpbun.github.io"
add check-gateway=ping distance=2 gateway="192.168.1.1" comment="LB NTH by buananetpbun.github.io"
/ip firewall mangle
add action=accept chain=prerouting dst-address-list=LOCAL-IP src-address-list=LOCAL-IP comment="LB NTH by buananetpbun.github.io"
add action=accept chain=postrouting dst-address-list=LOCAL-IP src-address-list=LOCAL-IP comment="LB NTH by buananetpbun.github.io"
add action=accept chain=forward dst-address-list=LOCAL-IP src-address-list=LOCAL-IP comment="LB NTH by buananetpbun.github.io"
add action=accept chain=input dst-address-list=LOCAL-IP src-address-list=LOCAL-IP comment="LB NTH by buananetpbun.github.io"
add action=accept chain=output dst-address-list=LOCAL-IP src-address-list=LOCAL-IP comment="LB NTH by buananetpbun.github.io"
add action=mark-connection chain=prerouting in-interface="ISP1" new-connection-mark="cm-ISP1" passthrough=yes comment="LB NTH by buananetpbun.github.io"
add action=mark-connection chain=prerouting in-interface="ISP2" new-connection-mark="cm-ISP2" passthrough=yes comment="LB NTH by buananetpbun.github.io"
add action=mark-routing chain=output connection-mark="cm-ISP1" new-routing-mark="to-ISP1" passthrough=yes comment="LB NTH by buananetpbun.github.io"
add action=mark-routing chain=output connection-mark="cm-ISP2" new-routing-mark="to-ISP2" passthrough=yes comment="LB NTH by buananetpbun.github.io"
add action=mark-connection chain=prerouting new-connection-mark="cm-ISP1" passthrough=yes connection-state=new nth=2,1 dst-address-list=!LOCAL-IP src-address-list=LOCAL-IP comment="LB NTH by buananetpbun.github.io"
add action=mark-connection chain=prerouting new-connection-mark="cm-ISP2" passthrough=yes connection-state=new nth=2,2 dst-address-list=!LOCAL-IP src-address-list=LOCAL-IP comment="LB NTH by buananetpbun.github.io"
add action=mark-routing chain=prerouting connection-mark="cm-ISP1" new-routing-mark="to-ISP1" passthrough=yes dst-address-list=!LOCAL-IP src-address-list=LOCAL-IP comment="LB NTH by buananetpbun.github.io"
add action=mark-routing chain=prerouting connection-mark="cm-ISP2" new-routing-mark="to-ISP2" passthrough=yes dst-address-list=!LOCAL-IP src-address-list=LOCAL-IP comment="LB NTH by buananetpbun.github.io"
RouterOs v7
/ip firewall address-list
add address=192.168.0.0/16 list=LOCAL-IP comment="LB NTH by buananetpbun.github.io"
add address=172.16.0.0/12 list=LOCAL-IP comment="LB NTH by buananetpbun.github.io"
add address=10.0.0.0/8 list=LOCAL-IP comment="LB NTH by buananetpbun.github.io"
/ip firewall nat
add chain=srcnat out-interface="ISP1" action=masquerade comment="LB NTH by buananetpbun.github.io"
add chain=srcnat out-interface="ISP2" action=masquerade comment="LB NTH by buananetpbun.github.io"
/routing table
add name="to-ISP1" fib comment="LB NTH by buananetpbun.github.io"
add name="to-ISP2" fib comment="LB NTH by buananetpbun.github.io"
/ip route
add check-gateway=ping distance=1 gateway="192.168.0.1" routing-table="to-ISP1" comment="LB NTH by buananetpbun.github.io"
add check-gateway=ping distance=1 gateway="192.168.1.1" routing-table="to-ISP2" comment="LB NTH by buananetpbun.github.io"
add check-gateway=ping distance=1 gateway="192.168.0.1" comment="LB NTH by buananetpbun.github.io"
add check-gateway=ping distance=2 gateway="192.168.1.1" comment="LB NTH by buananetpbun.github.io"
/ip firewall mangle
add action=accept chain=prerouting dst-address-list=LOCAL-IP src-address-list=LOCAL-IP comment="LB NTH by buananetpbun.github.io"
add action=accept chain=postrouting dst-address-list=LOCAL-IP src-address-list=LOCAL-IP comment="LB NTH by buananetpbun.github.io"
add action=accept chain=forward dst-address-list=LOCAL-IP src-address-list=LOCAL-IP comment="LB NTH by buananetpbun.github.io"
add action=accept chain=input dst-address-list=LOCAL-IP src-address-list=LOCAL-IP comment="LB NTH by buananetpbun.github.io"
add action=accept chain=output dst-address-list=LOCAL-IP src-address-list=LOCAL-IP comment="LB NTH by buananetpbun.github.io"
add action=mark-connection chain=prerouting in-interface="ISP1" new-connection-mark="cm-ISP1" passthrough=yes comment="LB NTH by buananetpbun.github.io"
add action=mark-connection chain=prerouting in-interface="ISP2" new-connection-mark="cm-ISP2" passthrough=yes comment="LB NTH by buananetpbun.github.io"
add action=mark-routing chain=output connection-mark="cm-ISP1" new-routing-mark="to-ISP1" passthrough=yes comment="LB NTH by buananetpbun.github.io"
add action=mark-routing chain=output connection-mark="cm-ISP2" new-routing-mark="to-ISP2" passthrough=yes comment="LB NTH by buananetpbun.github.io"
add action=mark-connection chain=prerouting new-connection-mark="cm-ISP1" passthrough=yes connection-state=new nth=2,1 dst-address-list=!LOCAL-IP src-address-list=LOCAL-IP comment="LB NTH by buananetpbun.github.io"
add action=mark-connection chain=prerouting new-connection-mark="cm-ISP2" passthrough=yes connection-state=new nth=2,2 dst-address-list=!LOCAL-IP src-address-list=LOCAL-IP comment="LB NTH by buananetpbun.github.io"
add action=mark-routing chain=prerouting connection-mark="cm-ISP1" new-routing-mark="to-ISP1" passthrough=yes dst-address-list=!LOCAL-IP src-address-list=LOCAL-IP comment="LB NTH by buananetpbun.github.io"
add action=mark-routing chain=prerouting connection-mark="cm-ISP2" new-routing-mark="to-ISP2" passthrough=yes dst-address-list=!LOCAL-IP src-address-list=LOCAL-IP comment="LB NTH by buananetpbun.github.io"
/ip firewall nat remove [find comment="LB NTH by buananetpbun.github.io"]
/ip route remove [find comment="LB NTH by buananetpbun.github.io"]
/ip firewall mangle remove [find comment="LB NTH by buananetpbun.github.io"]
/ip firewall address-list remove [find comment="LB NTH by buananetpbun.github.io"]
/routing table remove [find comment="LB NTH by buananetpbun.github.io"]