MikroTik RouterOS

Generator Load Balance PCC 2–10 WAN

Isi data WAN dan interface client hotspot / PPPoE, lalu salin atau unduh script .rsc siap import.

Data WAN

Bobot = porsi pembagian koneksi. ISP lebih besar beri bobot lebih tinggi.

Interface Client

Hotspot

PPPoE

Opsi

Tambahkan NAT masquerade per WAN
Tambahkan route failover di tabel main
Aktifkan check-gateway=ping

loadbalance-3wan.rsc

# =====================================================
# Load Balance PCC 3 WAN - Hotspot & PPPoE
# RouterOS v7
# Dibuat: 2026-09-15 06:02 UTC
# Semua rule baru diberi comment "PCC-FIX" agar mudah dihapus.
# Rollback: jalankan BAGIAN 0 di bawah ini.
# =====================================================

# --- BAGIAN 0: ROLLBACK (jalankan hanya bila ingin membatalkan) ---
# /ip firewall mangle remove [find comment~"PCC-FIX"]
# /ip firewall nat remove [find comment~"PCC-FIX"]
# /ip route remove [find comment~"PCC-FIX"]
# /routing table remove [find comment~"PCC-FIX"]

# --- BAGIAN 1: Daftar jaringan lokal (tidak ikut load balance) ---
/ip firewall address-list
remove [find list="LOCAL-NET" comment~"PCC-FIX"]
add list=LOCAL-NET address=192.168.0.0/16 comment="PCC-FIX local"
add list=LOCAL-NET address=172.16.0.0/12 comment="PCC-FIX local"
add list=LOCAL-NET address=10.0.0.0/8 comment="PCC-FIX local"

# --- BAGIAN 2: Interface list ---
/interface list
add name=WAN comment="PCC-FIX"
add name=LAN comment="PCC-FIX"
/interface list member
add list=WAN interface=ether1 comment="PCC-FIX isp1"
add list=WAN interface=ether2 comment="PCC-FIX isp2"
add list=WAN interface=ether3 comment="PCC-FIX isp3"
add list=LAN interface=vlan11 comment="PCC-FIX hotspot"
add list=LAN interface=vlan21 comment="PCC-FIX pppoe"

# --- BAGIAN 3: Routing table per WAN ---
/routing table
add name=to-wan01 fib comment="PCC-FIX isp1"
add name=to-wan02 fib comment="PCC-FIX isp2"
add name=to-wan03 fib comment="PCC-FIX isp3"

# --- BAGIAN 4: Route per WAN + failover di tabel main ---
/ip route
add dst-address=0.0.0.0/0 gateway=192.168.1.1 routing-table=to-wan01 check-gateway=ping comment="PCC-FIX isp1"
add dst-address=0.0.0.0/0 gateway=192.168.2.1 routing-table=to-wan02 check-gateway=ping comment="PCC-FIX isp2"
add dst-address=0.0.0.0/0 gateway=192.168.3.1 routing-table=to-wan03 check-gateway=ping comment="PCC-FIX isp3"
# Failover untuk trafik router sendiri (distance bertingkat)
add dst-address=0.0.0.0/0 gateway=192.168.1.1 distance=10 routing-table=main check-gateway=ping comment="PCC-FIX failover isp1"
add dst-address=0.0.0.0/0 gateway=192.168.2.1 distance=11 routing-table=main check-gateway=ping comment="PCC-FIX failover isp2"
add dst-address=0.0.0.0/0 gateway=192.168.3.1 distance=12 routing-table=main check-gateway=ping comment="PCC-FIX failover isp3"

# PENTING: hapus route default lama yang dobel di tabel main
# /ip route print where dst-address="0.0.0.0/0"

# --- BAGIAN 5: Trafik ke router sendiri balik lewat WAN yang sama ---
/ip firewall mangle
add chain=input action=mark-connection new-connection-mark=isp1_conn passthrough=no in-interface=ether1 comment="PCC-FIX input isp1"
add chain=input action=mark-connection new-connection-mark=isp2_conn passthrough=no in-interface=ether2 comment="PCC-FIX input isp2"
add chain=input action=mark-connection new-connection-mark=isp3_conn passthrough=no in-interface=ether3 comment="PCC-FIX input isp3"
add chain=output action=mark-routing new-routing-mark=to-wan01 passthrough=no connection-mark=isp1_conn comment="PCC-FIX output isp1"
add chain=output action=mark-routing new-routing-mark=to-wan02 passthrough=no connection-mark=isp2_conn comment="PCC-FIX output isp2"
add chain=output action=mark-routing new-routing-mark=to-wan03 passthrough=no connection-mark=isp3_conn comment="PCC-FIX output isp3"

# --- BAGIAN 6: PCC load balance untuk client hotspot & PPPoE ---
# Bypass trafik antar jaringan lokal lebih dulu
add chain=prerouting action=accept dst-address-list=LOCAL-NET in-interface-list=LAN comment="PCC-FIX bypass lokal"
add chain=prerouting action=mark-connection new-connection-mark=pcc-1 passthrough=yes connection-state=new connection-mark=no-mark dst-address-list=!LOCAL-NET in-interface-list=LAN per-connection-classifier=both-addresses:3/0 comment="PCC-FIX kelompok 1"
add chain=prerouting action=mark-connection new-connection-mark=pcc-2 passthrough=yes connection-state=new connection-mark=no-mark dst-address-list=!LOCAL-NET in-interface-list=LAN per-connection-classifier=both-addresses:3/1 comment="PCC-FIX kelompok 2"
add chain=prerouting action=mark-connection new-connection-mark=pcc-3 passthrough=yes connection-state=new connection-mark=no-mark dst-address-list=!LOCAL-NET in-interface-list=LAN per-connection-classifier=both-addresses:3/2 comment="PCC-FIX kelompok 3"
add chain=prerouting action=mark-routing new-routing-mark=to-wan01 passthrough=no connection-mark=pcc-1 dst-address-list=!LOCAL-NET in-interface-list=LAN comment="PCC-FIX rute 1"
add chain=prerouting action=mark-routing new-routing-mark=to-wan02 passthrough=no connection-mark=pcc-2 dst-address-list=!LOCAL-NET in-interface-list=LAN comment="PCC-FIX rute 2"
add chain=prerouting action=mark-routing new-routing-mark=to-wan03 passthrough=no connection-mark=pcc-3 dst-address-list=!LOCAL-NET in-interface-list=LAN comment="PCC-FIX rute 3"

# --- BAGIAN 7: NAT masquerade per WAN ---
/ip firewall nat
add chain=srcnat action=masquerade out-interface=ether1 comment="PCC-FIX nat isp1"
add chain=srcnat action=masquerade out-interface=ether2 comment="PCC-FIX nat isp2"
add chain=srcnat action=masquerade out-interface=ether3 comment="PCC-FIX nat isp3"

# --- BAGIAN 8: Verifikasi setelah 5-10 menit trafik ---
# /ip firewall mangle print stats where comment~"PCC-FIX kelompok"
# /ip firewall connection print where connection-mark~"pcc"
# Bersihkan koneksi lama agar pembagian langsung berlaku:
# /ip firewall connection remove [find]

# Bobot: isp1=1/3  isp2=1/3  isp3=1/3

Import di router: import loadbalance-3wan.rsc. Semua rule diberi comment PCC-FIX sehingga mudah dihapus kembali.