Mikrotik Load Balancing (PCC Method)

    1620

    Load balancing is a process of combining or shifting the load of users among different internet sources. You can say the combining of more than one internet connections is called load balancing. Load balancing, Load merging, Line Merging are the different names of a single process. In this tutorial, we will combine two internet connection and will get a combined speed of 2 internet connection in a single line. In this. You can add as many lines as you wish using the same principle. Conceptually, this article will cover the whole process of PCC load balancing and you can merge any number of lines if you read this article thoroughly.

    Open your mikrotik using Winbox.
    Go to interfaces and name the interfaces as LAN , WAN1 and WAN2.
    LAN interface will be our output and will entertain our users, WAN1 is attached to a Maxis Fiber Modem and WAN2 is attached to a YES 4G Modem.

    Assign IP to your interfaces. In this tutorial I am using DHCP for both of my WAN connection.

    ip_address

    Now come to the Mangle rules which is the essence of this article.

    Click on IP > Firewall > Mangle

    Click on Red + sign to add a new mangle rule for WAN1
    Chain=input
    In.interface=WAN1

    Click on advanced tab
    Action=mark connection
    New Connection Mark=WAN1_conn
    Check the pass through.
    mangle_1mangle_2

    Repeat the same process for WAN2.

    Now again we will add mangle rules.

    Click on red + sign.

    Chain=output

    Connection mark=WAN1_conn

    Click on advanced tab

    Action=mark routing

    New Connection Mark=to_WAN1

    Check the pass through.

    mangle_3

    mangle_4Again, we repeat the same process for WAN2.

    Now we will add PCC (Per connection Classifier) Rules.

    Click on red + sign to add a new mangle rule for PCC

    Chain=Prerouting

    In.interface=Local

    Click on Advanced tab.

    Per connection Classifier=both addresses and ports 2/0(we have two lines so we will use 2 over 0).

    Click on extra tab.

    DST.address type

    Address type=Local.

    Click on invert

    Click on action tab.

    Action=mark connection

    New connection mark=WAN1_Conn

    mangle_5mangle_6mangle_7

    Again, we will repeat the same process for WAN2 but this time we change Per Connection Classifier=both addresses and ports 2/1.

    Now we will add final mangle rules.

    Click on red + sign

    Chain=prerouting
    In.interface=Local
    Connection mark=WAN1_conn

    Action=mark routing
    New routing mark=to-WAN1
    Check pass through

    mangle_8mangle_9

    Add the same rule for WAN2.

    Your mangle rules should look like this.

    mangle_10

    Now we will add gateways.

    Click on IP> Routes
    Click on red + sign.

    Gateway= 192.168.0.1
    Check gateway
    =ping (This is a fail over entry which will ping the gateway continuously, if the gateway does not responds, it will disconnect that Line and put the load on the rest of the lines.)
    Routing Mark=to_WAN1

    Now add second route
    Gateway= 192.168.1.1
    Check gateway=ping (This is a fail over entry which will ping the gateway continuously ,if the gateway does not responds, it will disconnect that Line and put the load on the rest of the lines.)
    Routing Mark=to_WAN2

    route_1route_2

    Now add routes with distance.

    Again click on red + sign

    Gateway= 192.168.0.1
    Check
     gateway=ping
    Distance
    =1 (It tells the router which gateway to ping first)

    Again for the second one.

    Gateway= 192.168.1.1
    Check gateway=ping
    Routing Mark=to_WAN2

    route_3route_4

    Your route rules should look like this.

    route_5

    Now we will add two NAT rules which will enable internet sharing.

    Go to IP>Firewall >NAT
    Click on red + sign

    Chain=srcnat
    Out interface=WAN1

    Action=masquerade

    nat_1nat_2

    Add another rule for WAN2.

    Your NAT rules will look like this.

    nat_3

    We have configured 2 WAN load balancing in mikrotik. Now put user load over it. The more load you put, the better results you will get. Here I show you my speed test. WAN1 is 8Mbps and WAN2 is 4Mbps.

    speedtest

    P