Winflare
mikrotikloadbalancing

How to Setup Load Balancing using PCC on Mikrotik

Load Balancing is a technique used to send network traffic over multiple gateways. If you have multiple ISP connections in your network, you can send your network traffic through those ISP connections and make a load balanced network.

In this tutorial I am explaining how to create a Load Balancing setup using the PCC (Per connection classifier) method on Mikrotik routers. We will combine two internet connection into our local network and also get fail over if one line is unreachable.

With PCC you can add as many lines as you wish using the same method. Conceptually, this video tutorial will cover the whole process of PCC load balancing and you can merge any number of lines if you watch the video accordingly.

My complete setup export as seen in the video, you can use it to see each step in detail and as a starting, research point for your setup. Please make sure to re import it on a blank router:


/interface bridge
add name=localnetwork
/interface wireless security-profiles
set [ find default=yes ] supplicant-identity=MikroTik
/ip pool
add name=dhcp_pool0 ranges=10.30.30.6-10.30.30.254
/ip dhcp-server
add address-pool=dhcp_pool0 disabled=no interface=localnetwork name=dhcp1
/interface bridge port
add bridge=localnetwork interface=ether3
/ip address
add address=10.10.10.10/24 interface=ether1 network=10.10.10.0
add address=10.20.20.20/24 interface=ether2 network=10.20.20.0
add address=10.30.30.5/24 interface=localnetwork network=10.30.30.0
/ip dhcp-server network
add address=10.30.30.0/24 gateway=10.30.30.5
/ip dns
set servers=208.67.222.222,208.67.220.220
/ip firewall mangle
add action=mark-connection chain=prerouting connection-state=new \
in-interface=ether1 new-connection-mark=wan1 passthrough=yes
add action=mark-connection chain=prerouting connection-state=new \
in-interface=ether2 new-connection-mark=wan2 passthrough=yes
add action=mark-routing chain=output connection-mark=wan1 new-routing-mark=\
wan1-out passthrough=yes
add action=mark-routing chain=output connection-mark=wan2 new-routing-mark=\
wan2-out passthrough=yes
add action=mark-connection chain=prerouting connection-state=new \
dst-address-type=!local in-interface=localnetwork new-connection-mark=\
wan1 passthrough=yes per-connection-classifier=both-addresses:2/0
add action=mark-connection chain=prerouting connection-state=new \
dst-address-type=!local in-interface=localnetwork new-connection-mark=\
wan2 passthrough=yes per-connection-classifier=both-addresses:2/1
add action=mark-routing chain=prerouting connection-mark=wan1 in-interface=\
localnetwork new-routing-mark=wan1output passthrough=yes
add action=mark-routing chain=prerouting connection-mark=wan2 in-interface=\
localnetwork new-routing-mark=wan2output passthrough=yes
/ip firewall nat
add action=masquerade chain=srcnat out-interface=ether1
add action=masquerade chain=srcnat out-interface=ether2
/ip route
add check-gateway=ping distance=1 gateway=10.10.10.5 routing-mark=wan1output
add check-gateway=ping distance=2 gateway=10.20.20.1 routing-mark=wan2output
add check-gateway=ping distance=1 gateway=10.10.10.5
add check-gateway=ping distance=2 gateway=10.20.20.1
/system clock
set time-zone-name=Europe/Vienna
/system identity
set name="Core Load Balancer"

How PCC Works: https://wiki.mikrotik.com/wiki/How_PCC_works_(beginner)

Follow us

Don't be shy, get in touch. We love meeting interesting people and making new friends.

Most discussed

Get your e-mail updates

Sign up and get your news fix directly to your inbox. Nothing more nothing else and definitely no spam.
Name
Email address
We won't share your e-mail or send spam