Navigation
Guide That Contains This Content
[+] Expand All
[-] Collapse All

    Example: Load Balancing BGP Traffic with Unequal Bandwidth Allocated to the Paths

    This example shows how to configure BGP to select multiple unequal-cost paths as active paths.

    BGP communities can help you control routing policy. An example of a good use for BGP communities is unequal load balancing. When an autonomous system border router (ASBR) receives routes from directly connected external BGP (EBGP) neighbors, the ASBR then advertises those routes to internal neighbors, using IBGP advertisements. In the IBGP adverisements, you can attach the link-bandwidth community to communicate the bandwidth of the advertised external link. This is useful when multiple external links are available, and you want to do unequal load balancing over the links. You configure the link-bandwidth extended community on all ingress links of the AS. The bandwidth information in the link-bandwidth extended community is based on the configured bandwidth of the EBGP link. It is not based on the amount of traffic on the link. Junos OS supports BGP link-bandwidth and multipath load balancing, as described in Internet draft draft-ietf-idr-link-bandwidth-06, BGP Link Bandwidth Extended Community.

    Requirements

    Before you begin:

    • Configure the device interfaces.
    • Configure an interior gateway protocol (IGP).
    • Configure BGP.
    • Configure a routing policy that exports routes (such as direct routes or IGP routes) from the routing table into BGP.

    Overview

    In this example, Device R1 is in AS 65000 and is connected to both Device R2 and Device R3, which are in AS 65001.

    The example uses the bandwidth extended community.

    By default, when BGP multipath is used, traffic is distributed equally among the several paths calculated. The bandwidth extended community allows an additional attribute to be added to BGP paths, thus allowing the traffic to be distributed unequally. The primary application is a scenario where multiple external paths exist for a given network with asymmetric bandwidth capabilities. In such a scenario, you can tag routes received with the bandwidth extended community. When BGP multipath (internal or external) operates among routes that contain the bandwidth attribute, the forwarding engine can unequally distribute traffic according to the bandwidth corresponding to each path.

    When BGP has several candidate paths available for multipath purposes, BGP does not perform unequal cost load balancing according to the bandwidth community unless all candidate paths have this attribute.

    The applicability of the bandwidth extended community is limited by the restrictions under which BGP multipath accepts multiple paths for consideration. Explicitly, the IGP distance, as far as BGP is concerned, between the router performing load balancing and the multiple exit points needs to be the same. This can be achieved by using a full mesh of label-switched paths (LSPs) that do not track the corresponding IGP metric. However, in a network in which the propagation delay of circuits is significant (for example, if long-haul circuits are present), it is often valuable to take into account the delay characteristics of different paths.

    Configure the bandwidth community as follows:

    [edit policy-options] user@host# set community members bandwidth:[1-65535]:[0-4294967295]

    The first 16-bit number represents the local autonomous system. The second 32-bit number represents the link bandwidth in bytes per second.

    For example:

    [edit policy-options] user@host# showcommunity bw-t1 members bandwidth:10458:193000; community bw-t3 members bandwidth:10458:5592000; community bw-oc3 members bandwidth:10458:19440000;

    Where 10458 is the local AS number. The values correspond to the bandwidth of the T1, T3, and OC-3 paths in bytes per second. The value specified as the bandwidth value does not need to correspond to the actual bandwidth of a specific interface. The balance factors used are calculated as a function of the total bandwidth specified. To tag a route with this extended community, define a policy statement, as follows:

    [edit policy-options] user@host# show
    policy-statement link-bw-t1 {then {community set bw-t1;}accept;}

    Apply this as an import policy on the BGP peering sessions facing the asymmetrical bandwidth links. Although in theory the community attribute can be added or removed at any point in the network, in the scenario described above, applying the community as an import policy in the EBGP peering session facing the external link allows for that attribute to influence the local multipath decision, and is potentially easier to manage.

    Topology

    Figure 1 shows the topology used in this example.

    Figure 1: BGP Load Balancing

    BGP Load Balancing

    CLI Quick Configuration shows the configuration for all of the devices in Figure 1. The sectionStep-by-Step Procedure describes the steps on Device R1.

    Configuration

    CLI Quick Configuration

    To quickly configure this example, copy the following commands, paste them into a text file, remove any line breaks, change any details necessary to match your network configuration, and then copy and paste the commands into the CLI at the [edit] hierarchy level.

    Device R1

    set interfaces ge-1/2/0 unit 0 description R1->R3set interfaces ge-1/2/0 unit 0 family inet address 10.0.0.1/30set interfaces ge-1/2/1 unit 0 description R1->R2set interfaces ge-1/2/1 unit 0 family inet address 10.0.1.2/30set interfaces lo0 unit 0 family inet address 192.168.0.1/32set protocols bgp group external type externalset protocols bgp group external import bw-disset protocols bgp group external peer-as 65001set protocols bgp group external multipathset protocols bgp group external neighbor 10.0.1.1set protocols bgp group external neighbor 10.0.0.2set policy-options policy-statement bw-dis term a from protocol bgpset policy-options policy-statement bw-dis term a from neighbor 10.0.1.1set policy-options policy-statement bw-dis term a then community add bw-highset policy-options policy-statement bw-dis term a then acceptset policy-options policy-statement bw-dis term b from protocol bgpset policy-options policy-statement bw-dis term b from neighbor 10.0.0.2set policy-options policy-statement bw-dis term b then community add bw-lowset policy-options policy-statement bw-dis term b then acceptset policy-options policy-statement loadbal from route-filter 10.0.0.0/16 orlongerset policy-options policy-statement loadbal then load-balance per-packetset policy-options community bw-high members bandwidth:65000:60000000set policy-options community bw-low members bandwidth:65000:40000000set routing-options autonomous-system 65000set routing-options forwarding-table export loadbal

    Device R2

    set interfaces ge-1/2/0 unit 0 description R2->R1set interfaces ge-1/2/0 unit 0 family inet address 10.0.1.1/30set interfaces ge-1/2/1 unit 0 description R2->R3set interfaces ge-1/2/1 unit 0 family inet address 10.0.2.2/30set interfaces ge-1/2/1 unit 0 family isoset interfaces lo0 unit 0 family inet address 192.168.0.2/32set interfaces lo0 unit 0 family iso address 49.0001.1921.6800.0002.00set protocols bgp group external type externalset protocols bgp group external export bgp-defaultset protocols bgp group external export send-directset protocols bgp group external peer-as 65000set protocols bgp group external multipathset protocols bgp group external neighbor 10.0.1.2set protocols isis interface ge-1/2/1.0set protocols isis interface lo0.0set policy-options policy-statement bgp-default from protocol staticset policy-options policy-statement bgp-default from route-filter 172.16.0.0/16 exactset policy-options policy-statement bgp-default then acceptset policy-options policy-statement send-direct term 1 from protocol directset policy-options policy-statement send-direct term 1 then acceptset routing-options static route 172.16.0.0/16 discardset routing-options static route 172.16.0.0/16 no-installset routing-options autonomous-system 65001

    Device R3

    set interfaces ge-1/2/0 unit 0 description R3->R2set interfaces ge-1/2/0 unit 0 family inet address 10.0.2.1/30set interfaces ge-1/2/0 unit 0 family isoset interfaces ge-1/2/1 unit 0 description R3->R1set interfaces ge-1/2/1 unit 0 family inet address 10.0.0.2/30set interfaces lo0 unit 0 family inet address 192.168.0.3/32set interfaces lo0 unit 0 family iso address 49.0001.1921.6800.0003.00set protocols bgp group external type externalset protocols bgp group external export send-directset protocols bgp group external export bgp-defaultset protocols bgp group external peer-as 65000set protocols bgp group external multipathset protocols bgp group external neighbor 10.0.0.1set protocols isis interface ge-1/2/0.0set protocols isis interface lo0.0set policy-options policy-statement bgp-default from protocol staticset policy-options policy-statement bgp-default from route-filter 172.16.0.0/16 exactset policy-options policy-statement bgp-default then acceptset policy-options policy-statement send-direct term 1 from protocol directset policy-options policy-statement send-direct term 1 then acceptset routing-options static route 172.16.0.0/16 discardset routing-options static route 172.16.0.0/16 no-installset routing-options autonomous-system 65001

    Step-by-Step Procedure

    The following example requires that you navigate various levels in the configuration hierarchy. For information about navigating the CLI, see Using the CLI Editor in Configuration Mode in the CLI User Guide.

    To configure the BGP peer sessions:

    1. Configure the interfaces.
      user@R1# set ge-1/2/0 unit 0 description R1->R3user@R1# set ge-1/2/0 unit 0 family inet address 10.0.0.1/30
      user@R1# set ge-1/2/1 unit 0 description R1->R2user@R1# set ge-1/2/1 unit 0 family inet address 10.0.1.2/30
      user@R1# set lo0 unit 0 family inet address 192.168.0.1/32
    2. Configure the BGP group.
      [edit protocols bgp group external]user@R1# set type externaluser@R1# set import bw-disuser@R1# set peer-as 65001user@R1# set neighbor 10.0.1.1user@R1# set neighbor 10.0.0.2
    3. Enable the BGP group to use multiple paths.

      Note: To disable the default check requiring that paths accepted by BGP multipath must have the same neighboring autonomous system (AS), include the multiple-as option. Use the multiple-as option if the neighbors are in different ASs.

      [edit protocols bgp group external]user@R1# set multipath
    4. Configure the load-balancing policy.
      [edit policy-options policy-statement loadbal]user@R1# set from route-filter 10.0.0.0/16 orlonger user@R1# set then load-balance per-packet
    5. Apply the load-balancing policy.
      [edit routing-options]user@R1# set forwarding-table export loadbal
    6. Configure the BGP community members.

      This example assumes a bandwidth of 1 Gbps and allocates 60 percent to bw-high and 40 percent to bw-low. The reference bandwidth does not need to be the same as the link bandwidth.

      [editpolicy-options]user@R1# set community bw-high members bandwidth:65000:60000000user@R1# set community bw-low members bandwidth:65000:40000000
    7. Configure the bandwidth distribution policy.
      [editpolicy-options bw-dis]user@R1# set term a from protocol bgpuser@R1# set term a from neighbor 10.0.1.1user@R1# set term a then community add bw-highuser@R1# set term a then accept
      user@R1# set term b from protocol bgpuser@R1# set term b from neighbor 10.0.0.2user@R1# set term b then community add bw-lowuser@R1# set term b then accept
    8. Configure the local autonomous system (AS) number.
      [edit routing-options]user@R1# set autonomous-system 65000

    Results

    From configuration mode, confirm your configuration by entering the show interfaces, show protocols, show policy-options, and show routing-options commands. If the output does not display the intended configuration, repeat the instructions in this example to correct the configuration.

    user@R1# show interfaces
    ge-1/2/0 {unit 0 {description R1->R3;family inet {address 10.0.0.1/30;}}}
    ge-1/2/1 {unit 0 {description R1->R2;family inet {address 10.0.1.2/30;}}}
    lo0 {unit 0 {family inet {address 192.168.0.1/32;}}}
    user@R1# show protocols
    bgp {group external {type external;import bw-dis;peer-as 65001;multipath;neighbor 10.0.1.1;neighbor 10.0.0.2;}}
    user@R1# show policy-options
    policy-statement bw-dis {term a {from {protocol bgp;neighbor 10.0.1.1;}then {community add bw-high;accept;}}term b {from {protocol bgp;neighbor 10.0.0.2;}then {community add bw-low;accept;}}}
    policy-statement loadbal {from {route-filter 10.0.0.0/16 orlonger;}then {load-balance per-packet;}}
    community bw-high members bandwidth:65000:60000000;community bw-low members bandwidth:65000:40000000;
    user@R1# show routing-optionsautonomous-system 65000;
    forwarding-table {export loadbal;}

    If you are done configuring the device, enter commit from configuration mode.

    Verification

    Confirm that the configuration is working properly:

    Verifying Routes

    Purpose

    Verify that both routes are selected and that the next hops on the routes show a 60%/40% balance.

    Action

    From operational mode, run the show route protocol bgp detail command.

    user@R1> show route 172.16/16 protocol bgp detail
    inet.0: 9 destinations, 13 routes (9 active, 0 holddown, 0 hidden)
    172.16.0.0/16 (2 entries, 1 announced)
            *BGP    Preference: 170/-101
                    Next hop type: Router, Next hop index: 262143
                    Address: 0x93fc078
                    Next-hop reference count: 3
                    Source: 10.0.0.2
                    Next hop: 10.0.0.2 via ge-1/2/0.0 balance 40%
                    Next hop: 10.0.1.1 via ge-1/2/1.0 balance 60%, selected
                    State: **Active Ext>
                    Local AS: 65000 Peer AS: 65001
                    Age: 3:22:55 
                    Task: BGP_65001.10.0.0.2+55344
                    Announcement bits (1): 0-KRT 
                    AS path: 65001 I
                    Communities: bandwidth:65000:40000000
                    Accepted Multipath
                    Localpref: 100
                    Router ID: 192.168.0.3
             BGP    Preference: 170/-101
                    Next hop type: Router, Next hop index: 658
                    Address: 0x9260520
                    Next-hop reference count: 4
                    Source: 10.0.1.1
                    Next hop: 10.0.1.1 via ge-1/2/1.0, selected
                    State: <NotBest Ext>
                    Inactive reason: Not Best in its group - Active preferred
                    Local AS: 65000 Peer AS: 65001
                    Age: 3:22:55 
                    Task: BGP_65001.10.0.1.1+62586
                    AS path: 65001 I
                    Communities: bandwidth:65000:60000000
                    Accepted MultipathContrib
                    Localpref: 100
                    Router ID: 192.168.0.2

    user@R1> show route 10.0.2.0 protocol bgp detail
    inet.0: 9 destinations, 13 routes (9 active, 0 holddown, 0 hidden)
    10.0.2.0/30 (2 entries, 1 announced)
            *BGP    Preference: 170/-101
                    Next hop type: Router, Next hop index: 262143
                    Address: 0x93fc078
                    Next-hop reference count: 3
                    Source: 10.0.1.1
                    Next hop: 10.0.0.2 via ge-1/2/0.0 balance 40%
                    Next hop: 10.0.1.1 via ge-1/2/1.0 balance 60%, selected
                    State: <Active Ext>
                    Local AS: 65000 Peer AS: 65001
                    Age: 3:36:37 
                    Task: BGP_65001.10.0.1.1+62586
                    Announcement bits (1): 0-KRT 
                    AS path: 65001 I
                    Communities: bandwidth:65000:60000000
                    Accepted Multipath
                    Localpref: 100
                    Router ID: 192.168.0.2
             BGP    Preference: 170/-101
                    Next hop type: Router, Next hop index: 657
                    Address: 0x92604d8
                    Next-hop reference count: 4
                    Source: 10.0.0.2
                    Next hop: 10.0.0.2 via ge-1/2/0.0, selected
                    State: <NotBest Ext>
                    Inactive reason: Not Best in its group - Active preferred
                    Local AS: 65000 Peer AS: 65001
                    Age: 3:36:36 
                    Task: BGP_65001.10.0.0.2+55344
                    AS path: 65001 I
                    Communities: bandwidth:65000:40000000
                    Accepted MultipathContrib
                    Localpref: 100
                    Router ID: 192.168.0.3

    Meaning

    The active path, denoted with an asterisk (*), has two next hops: 10.0.1.1 and 10.0.0.2 to the 172.16/16 destination.

    Likewise, the active path, denoted with an asterisk (*), has two next hops: 10.0.1.1 and 10.0.0.2 to the 10.0.2.0 destination.

    In both cases, the 10.0.1.1 next hop is copied from the inactive path to the active path.

    The balance of 40 percent and 60 percent is shown in the show route output. This indicates that traffic is being distributed between two next hops and that 60 percent of the traffic is following the first path, while 40 percent is following the second path.

    Published: 2013-07-22