Mikrotik router with Weighted PCC Load Balancing

Consider the problem:You have two connection from two different ISPs. One ISP is providing dynamic IP address and the other is providing static IP address. The dynamic IP has 35Mbps and the static IP has only 10Mbps bandwidth. Ideally one wants to configure such that your customers should get highest achievable bandwidth(say 50Mbps package). So the customer should first use the dynamic IP and then use static IP, and the question remains if it is possible to achieve total of 40Mbps(35+10), that is increase bandwidth for many customer?

To maximize your bandwidth usage with PCC load balancing, particularly since your dynamic IP provides 35 Mbps and your static IP offers only 10 Mbps, you'll need to implement load balancing with failover or weighted balancing instead of basic PCC. This setup will prioritize traffic through the dynamic IP (35 Mbps) and only use the static IP (10 Mbps) when the dynamic IP is fully utilized. You can also attempt to combine both bandwidths, but 35+10 Mbps won't work in a perfect aggregation unless specific protocols or bonding methods are applied.

Here’s a solution that involves configuring PCC Load Balancing with Weighted Traffic Distribution, where you prioritize your faster connection (dynamic IP) and use the static one as a backup or additional path.

Steps to Configure Weighted PCC Load Balancing:

1. Remove Bonding Configuration:

  • As mentioned earlier, bonding between two ISPs with different IP setups (static and dynamic) will not work effectively, so ensure the bonding interface is removed.

2. Set Up Mangle Rules with Weighted PCC:

You will need to define mangle rules that distribute traffic based on the bandwidth of each link. Since the dynamic IP has more bandwidth (35 Mbps) than the static IP (10 Mbps), we will distribute traffic using a weight ratio of 7:2 (35:10 Mbps).

  1. Go to: IP → Firewall → Mangle.

  2. Add a mangle rule for marking connections to use ISP 1 (dynamic IP):

    • Chain: prerouting
    • In. Interface: Your LAN bridge (eth2, eth4, eth6).
    • Action: Mark Connection
    • New Connection Mark: ISP1_conn (create it)
    • PCC Classifier: src-address.
    • Per Connection Classifier: Set the ratio to 9/0 (which sends more traffic to ISP 1).
  3. Add a mangle rule for marking connections to use ISP 2 (static IP):

    • Chain: prerouting
    • In. Interface: Your LAN bridge (eth2, eth4, eth6).
    • Action: Mark Connection
    • New Connection Mark: ISP2_conn (create it)
    • PCC Classifier: src-address.
    • Per Connection Classifier: Set the ratio to 9/1 (sends a small amount of traffic to ISP 2).
  4. Adjust the weight ratio according to your needs. For example:

    • Ratio 7/2 will send more traffic through the 35 Mbps (dynamic IP) and less through the 10 Mbps (static IP).

3. Mark Routing for Both Connections:

Next, you’ll set up routing marks so that the packets go through the correct gateway based on the connection marks.

  1. Go to: IP → Firewall → Mangle.

  2. Add a new rule for routing traffic via ISP 1 (dynamic IP):

    • Chain: prerouting
    • Connection Mark: ISP1_conn
    • Action: Mark Routing
    • New Routing Mark: to_ISP1.
  3. Add a new rule for routing traffic via ISP 2 (static IP):

    • Chain: prerouting
    • Connection Mark: ISP2_conn
    • Action: Mark Routing
    • New Routing Mark: to_ISP2.

4. Configure Routes for Both ISPs:

  • Go to: IP → Routes.
  • Add routes for both ISPs based on the routing marks you created.
  1. Add a route for ISP 1 (dynamic IP):

    • Dst. Address: 0.0.0.0/0
    • Gateway: The gateway received via DHCP from eth3 (dynamic IP).
    • Routing Mark: to_ISP1.
  2. Add a route for ISP 2 (static IP):

    • Dst. Address: 0.0.0.0/0
    • Gateway: 22.111.2.93 (static IP gateway for ISP 1).
    • Routing Mark: to_ISP2.

5. Configure NAT for Both ISPs:

  • Go to IP → Firewall → NAT.
  • Add a masquerade rule for each ISP so that outgoing packets are correctly routed.
  1. Masquerade rule for dynamic IP (ISP 1):

    • Chain: srcnat
    • Out. Interface: eth3
    • Action: masquerade.
  2. Masquerade rule for static IP (ISP 2):

    • Chain: srcnat
    • Out. Interface: eth1
    • Action: masquerade.

6. Configure Failover (Optional):

If you want to prioritize the faster ISP (dynamic IP) and only use the static IP when the dynamic IP fails or is overloaded, you can use failover.

  1. Go to: IP → Routes.
  2. Add a default route with the dynamic IP (received from DHCP) as the primary gateway and set the Distance to 1.
  3. Add a secondary default route for the static IP gateway with a Distance of 2.

This will ensure that the dynamic IP is used by default, and the static IP will only be used if the dynamic IP is unavailable.

Summary:

  • Remove bonding because of different networks.
  • Use weighted PCC to distribute traffic based on the capacity of each connection. In your case, use a ratio of 7:2 or 9:1 to prioritize the dynamic IP.
  • Set up mangle rules to mark connections and routes, and configure NAT rules for both ISPs.
  • Optionally, configure failover to automatically switch to the static IP when the dynamic IP fails.

This setup should allow you to utilize the full bandwidth of your connections (35 Mbps from dynamic and 10 Mbps from static) for customer traffic.

Post a Comment

Previous Post Next Post