PCC Load Balancing Using Mikrotik

Mikrotik router OS has a most favorite feature called load balancing. Load balancing means spread the traffic into multiple upstream based on real time traffic load. Most common technique to implement load balancing is using NTH or PCC (Per Connection Classifier).

Load balancing methods also can be an alternative option to get big downstream bandwidth with relatively cheap price. Because in general, the most demanding traffic is the downstream (download traffic towards to the user) compared the upstream traffic relatively less necessary.

In this post, I'm explaining about the implementation of load balancing using PCC method. For this example, we have 1 LAN which is connected to Internet through 2 WAN from different Internet Service Provider.

ISP 1       = 10.10.10.11/28
Gateway = 10.10.10.1

ISP 2       = 11.11.11.10/28
Gateway = 11.11.11.1

LAN       = 192.168.1.0/24
Gateway = 192.168.1.1

https://blogger.googleusercontent.com/img/b/R29vZ2xl/AVvXsEgTd7WKDSDTLe3wqIOio6LSv0ESfoN4ijplmi6rZlY1d6jJwejsd24W_R5vs78ZMmVUTygqVJZeu_YmpfDTjsO75HFHGYg8Vzrt7IsWlJzZE6MVOio1ervT-jl1KINlZY7VtkTlXoNLWOM/s320/topology.PNG

Then, we start from creating ip addresses for all used interfaces on router :

 /ip address  
 add address=10.10.10.11/28 disabled=no interface=WAN1 network=10.10.10.0  
 add address=11.11.11.10/28 disabled=no interface=WAN2 network=11.11.11.0  
 add address=192.168.1.1/24 disabled=no interface=LAN network=192.168.1.0  

Move to IP -> Firewall -> Mangle for creating PCC Load Balancer settings :

 /ip firewall mangle  
 add action=mark-connection chain=input disabled=no in-interface=WAN1 new-connection-mark=WAN1_connmark passthrough=yes  
 add action=mark-connection chain=input disabled=no in-interface=WAN2 new-connection-mark=WAN2_connmark passthrough=yes  
 add action=mark-routing chain=output connection-mark=WAN1_connmark disabled=no new-routing-mark=to_ISP1 passthrough=yes  
 add action=mark-routing chain=output connection-mark=WAN2_connmark disabled=no new-routing-mark=to_ISP2 passthrough=yes  
 add action=mark-connection chain=prerouting disabled=no dst-address-type=!local in-interface=LAN new-connection-mark=WAN1_connmark passthrough=yes per-connection-classifier=both-addresses-and-ports:2/0  
 add action=mark-connection chain=prerouting disabled=no dst-address-type=!local in-interface=LAN new-connection-mark=WAN2_connmark passthrough=yes per-connection-classifier=both-addresses-and-ports:2/1  
 add action=mark-routing chain=prerouting connection-mark=WAN1_connmark disabled=no in-interface=LAN new-routing-mark=to_ISP1 passthrough=yes  
 add action=mark-routing chain=prerouting connection-mark=WAN2_connmark disabled=no in-interface=LAN new-routing-mark=to_ISP2 passthrough=yes  

Then, don't forget to create masquerade settings to translate local address into public address :

 /ip firewall nat  
 add action=masquerade chain=srcnat disabled=no out-interface=WAN1  
 add action=masquerade chain=srcnat disabled=no out-interface=WAN2  

Last, create IP routes :

 /ip route  
 add distance=1 gateway=10.10.10.1 routing-mark=to_ISP1  
 add distance=1 gateway=11.11.11.1 routing-mark=to_ISP2  
 add distance=1 gateway=10.10.10.1  
 add distance=1 gateway=11.11.11.1  

This is my example from my own setting which indicate that all settings are working well, because my ping test passed through the different gateways :
https://blogger.googleusercontent.com/img/b/R29vZ2xl/AVvXsEi4DbfnKiC7Zcxwr6q2lg_hsMbNjmNXCNkCk5GMA4nwrSe74G6fQxd5sN37H_ADP6X69aQ5MF-FxjFLUU3NmqLvbhJ2PErMkcWfopyznHdCRA_TCk1PRM28zKtQGdfsSR-snTc7cJpwocs/s1600/PCC.PNG

Comments

Post a Comment

Please leave your comment politely and do not write a spam message.

Thank you. :)