MikroTik PCC Load Balancing with Two ISPs (RouterOS v7)
Use both internet connections at the same time with PCC load balancing on RouterOS v7: connection marks, routing tables, routes with failover, NAT and the FastTrack trap.
Problem
You have two ISP connections and want to use both at once, with traffic shared between them and automatic failover if one goes down.
Symptoms
- Only one ISP is used; the second stays idle.
- Banking sites log you out or some HTTPS sites break after enabling load balancing.
Likely causes
Plain routing always uses the best route, so one link sits idle. PCC (Per Connection Classifier) splits new connections between links and keeps each connection on the same link. Sites break when connections from one user jump between two public IPs, or when FastTrack skips the routing marks.
Prerequisites
- Example: ISP1 on
ether1(gateway203.0.113.1), ISP2 onether2(gateway198.51.100.1), LAN onbridge-lan192.168.88.0/24. - Disable FastTrack (it bypasses mangle).
Solution (WinBox / CLI)
1. Routing tables:
/routing table add name=to-isp1 fib
/routing table add name=to-isp2 fib2. Mangle: mark connections and routes. both-addresses keeps all traffic between a user and a website on the same ISP, which avoids most HTTPS and banking problems:
/ip firewall mangle
add chain=prerouting in-interface=ether1 connection-mark=no-mark action=mark-connection new-connection-mark=isp1-conn
add chain=prerouting in-interface=ether2 connection-mark=no-mark action=mark-connection new-connection-mark=isp2-conn
add chain=prerouting in-interface=bridge-lan dst-address-type=!local connection-mark=no-mark per-connection-classifier=both-addresses:2/0 action=mark-connection new-connection-mark=isp1-conn
add chain=prerouting in-interface=bridge-lan dst-address-type=!local connection-mark=no-mark per-connection-classifier=both-addresses:2/1 action=mark-connection new-connection-mark=isp2-conn
add chain=prerouting in-interface=bridge-lan connection-mark=isp1-conn action=mark-routing new-routing-mark=to-isp1 passthrough=no
add chain=prerouting in-interface=bridge-lan connection-mark=isp2-conn action=mark-routing new-routing-mark=to-isp2 passthrough=no
add chain=output connection-mark=isp1-conn action=mark-routing new-routing-mark=to-isp1 passthrough=no
add chain=output connection-mark=isp2-conn action=mark-routing new-routing-mark=to-isp2 passthrough=no3. Routes with failover:
/ip route
add gateway=203.0.113.1 routing-table=to-isp1 check-gateway=ping
add gateway=198.51.100.1 routing-table=to-isp1 distance=2
add gateway=198.51.100.1 routing-table=to-isp2 check-gateway=ping
add gateway=203.0.113.1 routing-table=to-isp2 distance=2
add gateway=203.0.113.1 check-gateway=ping
add gateway=198.51.100.1 distance=24. NAT on both links:
/ip firewall nat
add chain=srcnat out-interface=ether1 action=masquerade
add chain=srcnat out-interface=ether2 action=masqueradeVerification
/ip firewall connection print where connection-mark=isp2-connshows connections on ISP2.- Watch traffic on both WAN interfaces in WinBox.
- Unplug ISP1: traffic moves to ISP2 within a few seconds.
Common errors
- FastTrack still enabled: traffic ignores the marks. Disable the FastTrack rule.
- Traffic to other local subnets (VLANs, VPN) gets marked and sent to the ISP. Add an accept rule at the top of mangle for local destinations.
- Using
both-addresses-and-ports: better spreading, but more broken logins on banking and some HTTPS sites.
Rollback
/ip firewall mangle disable [find new-connection-mark~"isp"]
/ip firewall mangle disable [find new-routing-mark~"to-isp"]For simple failover without load balancing, see Dual WAN failover with recursive routing.
This topic is covered hands-on in MTCRE — MikroTik Certified Routing Engineer.
View MTCRE