Configuring BGP Load Balancing

BGP load balancing improves network resource usage and reduces network congestion.

Usage Scenario

On large networks, there may be multiple valid routes to the same destination. BGP, however, advertises only the optimal route to its peers, which may result in load imbalance.

Either of the following methods can be used to resolve the traffic imbalance:

  • Use BGP routing policies to allow traffic to be balanced. For example, use a routing policy to modify the Local_Pref, AS_Path, Origin, or MED attribute of BGP routes to control traffic forwarding and implement load balancing.

  • Use multiple paths to implement traffic load balancing. This method requires that multiple equal-cost routes exist and the number of routes allowed to participate in load balancing be set. Load balancing can be implemented globally or for a specified peer or peer group.

  • You can change load balancing rules through configurations. For example, you can prevent the device from comparing AS_Path attributes or IGP costs. When performing these configurations, ensure that no routing loops will occur.

  • Locally leaked routes and routes imported between public network and VPN instances do not support load balancing.

Pre-configuration Tasks

Before configuring BGP load balancing, configure basic BGP functions.

Procedure

  • Configure BGP peer or peer group-based load balancing.

    1. Run system-view

      The system view is displayed.

    2. Run bgp as-number

      The BGP view is displayed.

    3. Run ipv4-family unicast
      The BGP-IPv4 unicast address family view is displayed.

      The BGP-IPv4 unicast address family view is used as an example, and you can select one of the following views as required: BGP view, BGP-IPv4 unicast address family view, BGP-IPv6 unicast address family view, BGP-VPN instance IPv4 address family view, or BGP-VPN instance IPv6 address family view.

    4. Run peer { ipv4-address | ipv6–address | group-name } load-balancing [ as-path-ignore | as-path-relax ]

      BGP peer or peer group-based load balancing is enabled.

      After the peer load-balancing command is run, BGP peer-based load balancing is implemented only when the following conditions are met:
      • The routes are received from the specified peer or peer group.
      • The optimal route and optimal equal-cost routes exist.
      • The AS_Path attribute is the same as that of the optimal route, or as-path-ignore or as-path-relax is specified in the peer load-balancing command.
        • If as-path-ignore is specified, the device ignores comparing AS_Path attributes when selecting routes for load balancing. In this case, routes can participate in load balancing even if their AS_Path attributes are different.
        • If as-path-relax is specified, the device ignores comparing the AS_Path attributes of the same length when selecting routes for load balancing. In this case, routes cannot participate in load balancing if their AS_Path attributes are of different lengths. For example, the AS_Path attribute of route A is 10, and the AS_Path attribute of route B is 10, 20. Because the two AS_Path attributes are of different lengths, the two routes cannot participate in load balancing.
    5. (Optional) Change load balancing rules.

      • Run the load-balancing as-path-ignore command to prevent the device from comparing AS_Path attributes when selecting routes for load balancing.
      • Run the load-balancing as-path-relax command to configure the device to ignore comparing the AS_Path attributes of the same length when selecting routes for load balancing.
      • Run the load-balancing igp-metric-ignore command to prevent the device from comparing IGP costs when selecting routes for load balancing.

      The address family views supported by the preceding commands are different. When running any of the commands, ensure that the command is run in the correct address family view.

      Change load balancing rules based on network requirements and exercise caution when running the commands.

    6. Run commit

      The configuration is committed.

  • Configure global BGP load balancing.

    • Set the maximum number of BGP routes for load balancing.
      1. Run system-view

        The system view is displayed.

      2. Run bgp as-number

        The BGP view is displayed.

      3. Run ipv4-family unicast

        The IPv4-unicast address family view is displayed.

      4. Run maximum load-balancing [ ebgp | ibgp ] number [ ecmp-nexthop-changed ]

        The maximum number of equal-cost BGP routes for load balancing is set.

        • ebgp indicates that load balancing is implemented only among EBGP routes.

        • ibgp indicates that load balancing is implemented only among IBGP routes.

        • If neither ebgp nor ibgp is specified, both EBGP and IBGP routes can balance traffic, and the number of EBGP routes for load balancing is the same as the number of IBGP routes for load balancing.

        Before routes to the same destination implement load balancing on a public network, a device determines the type of optimal route. If IBGP routes are optimal, only IBGP routes carry out load balancing. If EBGP routes are optimal, only EBGP routes carry out load balancing. This means that load balancing cannot be implemented using both IBGP and EBGP routes with the same destination address.

        The BGP-IPv4 unicast address family view is used as an example, and you can also configure load balancing in the BGP view, BGP-IPv6 unicast address family view, BGP-VPN instance IPv4 address family view, BGP-VPN instance IPv6 address family view or BGP-IPv4 unicast address family view.

      5. (Optional) Change load balancing rules.

        • Run the load-balancing as-path-ignore command to prevent the device from comparing AS_Path attributes when selecting routes for load balancing.
        • Run the load-balancing as-path-relax command to configure the device to ignore comparing the AS_Path attributes of the same length when selecting routes for load balancing.
        • Run the load-balancing igp-metric-ignore command to prevent the device from comparing IGP costs when selecting routes for load balancing.

        The address family views supported by the preceding commands are different. When running any of the commands, ensure that the command is run in the correct address family view.

        Change load balancing rules based on network requirements and exercise caution when running the commands.

      6. Run commit

        The configuration is committed.

    • Set the maximum number of EBGP and IBGP routes for load balancing.

      This configuration is used in a VPN where a CE is dual-homed to two PEs. When the CE resides in the same AS as only one of the PEs, you can set the maximum number of EBGP and IBGP routes for load balancing so that VPN traffic can be balanced among EBGP and IBGP routes.

      1. Run system-view

        The system view is displayed.

      2. Run bgp as-number

        The BGP view is displayed.

      3. Run ipv4-family vpn-instance vpn-instance-name

        The BGP-VPN instance IPv4 address family view is displayed.

      4. Run maximum load-balancing eibgp number [ ecmp-nexthop-changed ]

        The maximum number of EBGP and IBGP routes for load balancing is set.

        After the maximum load-balancing eibgp number command is run on a device, the device, by default, changes the next hop of each route to itself before advertising the route to a peer, regardless of whether the route is to be used for load balancing. However, in RR or BGP confederation scenarios, the device does not change the next hop addresses of non-local routes to be advertised to a local address. As a result, besides the routes for load-balancing, those routes that are not supposed to participate in load balancing deliver traffic to the device, which overburdens the device. To address this problem, you can set ecmp-nexthop-changed so that the device changes the next hop of only routes that are to be used for load balancing to itself before advertising them to peers.

      5. (Optional) Change load balancing rules.

        • Run the load-balancing as-path-ignore command to prevent the device from comparing AS_Path attributes when selecting routes for load balancing.
        • Run the load-balancing as-path-relax command to configure the device to ignore comparing the AS_Path attributes of the same length when selecting routes for load balancing.
        • Run the load-balancing igp-metric-ignore command to prevent the device from comparing IGP costs when selecting routes for load balancing.

        The address family views supported by the preceding commands are different. When running any of the commands, ensure that the command is run in the correct address family view.

        Change load balancing rules based on network requirements and exercise caution when running the commands.

      6. Run commit

        The configuration is committed.

Follow-up Procedure

When BGP routes carrying the link bandwidth extended community attribute are available for load balancing and they all recurse to IP routes or tunnels, you can run the load-balancing ucmp command in the BGP-IPv4 unicast address family view or BGP view to implement unequal-cost load balancing among BGP routes based on the link bandwidth extended community attribute. With this function, when there are multiple egress devices to the destination, unequal-cost load balancing can be implemented based on the actual bandwidth capability of each egress device. The methods of configuring the link bandwidth extended community attribute are as follows:

Verifying the Configuration

After the configuration is complete, verify the configuration.

  • Run the display bgp routing-table [ network ] [ mask | mask-length ] [ longer-prefixes ] command to check information about the BGP routing table.

  • Run the display ip routing-table [ verbose ] command to check information about the IP routing table.

Copyright © Huawei Technologies Co., Ltd.
Copyright © Huawei Technologies Co., Ltd.
< Previous topic Next topic >