Static routing

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.

Commands in this article follow RouterOS v7 documentation but have not yet been marked as lab-tested on this site. Always test changes in a lab or maintenance window and keep a backup.

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 (gateway 203.0.113.1), ISP2 on ether2 (gateway 198.51.100.1), LAN on bridge-lan 192.168.88.0/24.
  • Disable FastTrack (it bypasses mangle).

Solution (WinBox / CLI)

1. Routing tables:

RouterOS CLI
/routing table add name=to-isp1 fib
/routing table add name=to-isp2 fib

2. 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:

RouterOS CLI
/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=no

3. Routes with failover:

RouterOS CLI
/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=2

4. NAT on both links:

RouterOS CLI
/ip firewall nat
add chain=srcnat out-interface=ether1 action=masquerade
add chain=srcnat out-interface=ether2 action=masquerade

Verification

  • /ip firewall connection print where connection-mark=isp2-conn shows 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

RouterOS CLI
/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.

Go deeper in class

This topic is covered hands-on in MTCRE — MikroTik Certified Routing Engineer.

View MTCRE
WhatsApp