MikroTik Dual-WAN (2 ISP) PCC Load Balancing & Failover Script for RouterOS v7
Production-ready MikroTik RouterOS v7 2-WAN PCC Load Balancing script with FIB routing tables, mangle rules, and recursive gateway failover.
📊Reference Table & Engineering Specs
| Parameter / Metric | Specification Value |
|---|---|
| WAN Uplinks | 2 ISP (ISP-1 + ISP-2) |
| PCC Classifier Mode | both-addresses-and-ports (Aman untuk Mobile Banking & HTTPS) |
| PCC Hash Buckets | 2/0 (ke ISP-1) dan 2/1 (ke ISP-2) |
| Target RouterOS Version | RouterOS v7.x (/routing table add fib) |
| Failover Mechanism | check-gateway=ping (Distance 1 & 2) |
📖Technical Explanation & Methodology
Dual-WAN PCC distributes LAN connections across two ISPs using `both-addresses-and-ports` so HTTPS, banking, and gaming sessions maintain sticky public IP affinity.
/routing table
add name=to-isp1 fib
add name=to-isp2 fib
/ip firewall mangle
add chain=prerouting in-interface=bridge-lan dst-address-type=!local per-connection-classifier=both-addresses-and-ports:2/0 action=mark-connection new-connection-mark=isp1_conn passthrough=yes
add chain=prerouting in-interface=bridge-lan dst-address-type=!local per-connection-classifier=both-addresses-and-ports:2/1 action=mark-connection new-connection-mark=isp2_conn passthrough=yes❓Frequently Asked Questions (FAQ)
Why use both-addresses-and-ports in MikroTik PCC?
It keeps each client connection bound to a consistent WAN IP, preventing broken SSL/banking sessions.