BGP unequal cost load balancing

You can do it by using "bandwidth" extended-community.

Let's say your n/w is as below:


                 /------->>> ISP1 (AS 200)
                /
               /
        +----+/
(AS 100)| R1 |
        +----+\
               \
                \
                 \-------->>> ISP2 (AS 300)


Step 1:
=======
You need to define two community with bandwidth string as below:

community bw-high members bandwidth:100:60000000;
community bw-low members bandwidth:100:40000000;

bandwidth:100:60000000 translates to bandwidth:<YOUR_AS_NUMBER>:<BANDWIDTH_RATIO>

In this case I have assumed bandwidth of 1G and have allocated 60% to bw-high and 40% to bw-low.
PLEASE NOTE THE REF BANDWIDTH NEED NOT BE SAME AS LINK BANDWIDTH.


Step 2:
=======
Define the policy as below to tag BGP routes:

policy-statement bw-dis {
    term a {
        from {
            protocol bgp;
            neighbor 172.168.1.2;     <<< ISP1
        }
        then {
            community add bw-high;        <<< 60%                 
            accept;
        }
    }
    term b {
        from {
            protocol bgp;
            neighbor 200.210.1.2;    <<< ISP2
        }
        then {
            community add bw-low;        <<< 40%
            accept;
        }
    }
}


Step 3:
=======
Enable multipath and forwarding-plane load-balancing action.
group ext {
    import bw-dis;
    multipath multiple-as;   << Ensure to have multi-as option in case the ISP are in two different AS
    neighbor 172.168.1.2 {
        peer-as 200;
    }
    neighbor 200.210.1.2 {
        peer-as 300;
    }
}

policy-options {
    policy-statement lb {
        then {
            load-balance per-packet;
        }
    }
}

routing-options {
    autonomous-system 100;
    forwarding-table {
        export lb;
    }
}

Verification:
=============
You can verify the load-balancing action as below:

suryak@R1# run show route protocol bgp detail

inet.0: 138 destinations, 238 routes (137 active, 0 holddown, 1 hidden)
10.8.1.0/24 (2 entries, 1 announced)
        *BGP    Preference: 170/-101
                Next hop type: Router, Next hop index: 1048574
                Next-hop reference count: 200
                Source: 172.168.1.2
                Next hop: 172.168.1.2 via ge-1/0/3.0 balance 60%, selected   << 60% to ISP1
                Next hop: 200.210.1.2 via ge-5/0/1.0 balance 40%             << 40% to ISP2
                State: <Active Ext>
                Local AS:   100 Peer AS:   200
                Age: 20:06
                Task: BGP_200.172.168.1.2+179
                Announcement bits (2): 0-KRT 3-BGP RT Background
                AS path: 200 ?
                Communities: bandwidth:100:60000000
                Accepted Multipath
                Localpref: 100
                Router ID: 172.168.1.2
         BGP    Preference: 170/-101
                Next hop type: Router
                Next-hop reference count: 100
                Source: 200.210.1.2
                Next hop: 200.210.1.2 via ge-5/0/1.0, selected
                State: <Ext>
                Inactive reason: Active preferred
                Local AS:   100 Peer AS:   300
                Age: 20:04
                Task: BGP_300.200.210.1.2+179
                AS path: 300 ?
                Communities: bandwidth:100:40000000
                Accepted
                Localpref: 100
                Router ID: 200.210.1.2

10.8.2.0/24 (2 entries, 1 announced)
        *BGP    Preference: 170/-101
                Next hop type: Router, Next hop index: 1048574
                Next-hop reference count: 200
                Source: 172.168.1.2
                Next hop: 172.168.1.2 via ge-1/0/3.0 balance 60%
                Next hop: 200.210.1.2 via ge-5/0/1.0 balance 40%, selected
                State: <Active Ext>
                Local AS:   100 Peer AS:   200
                Age: 20:06
                Task: BGP_200.172.168.1.2+179
                Announcement bits (2): 0-KRT 3-BGP RT Background
                AS path: 200 ?
                Communities: bandwidth:100:60000000
                Accepted Multipath
                Localpref: 100
                Router ID: 172.168.1.2
         BGP    Preference: 170/-101
                Next hop type: Router
                Next-hop reference count: 100
                Source: 200.210.1.2
                Next hop: 200.210.1.2 via ge-5/0/1.0, selected
                State: <Ext>
                Inactive reason: Active preferred
                Local AS:   100 Peer AS:   300
                Age: 20:04
                Task: BGP_300.200.210.1.2+179
                AS path: 300 ?
                Communities: bandwidth:100:40000000
                Accepted
                Localpref: 100
                Router ID: 200.210.1.2

 

 

With multipath, the distribution of  routes would be almost even (50-50) to both ISP1 and ISP2. However when you want to override this default behavior, you tag the incoming prefixes with BANDWIDTH community to distribute unequal prefixes to ISP1 and ISP2.

Based on these bandwidth attribute, router internally calculates on how the distribution of these prefixes to ISP1 and ISP2.

multipath = Equal distribution to ISP1 and ISP2

multipath+bandwidth  = Unequal distribution based on the bandwidth tag