Configuring BGP Load Balancing
Context
On large networks, there may be multiple valid routes to the same destination. BGP, however, advertises only the optimal route to its peers. This may result in unbalanced traffic on different routes. Configuring BGP load balancing enables traffic to be load balanced and network congestion to be reduced.
Equal-cost BGP routes can be generated for traffic load balancing only when the first eight route attributes described in "BGP Route Selection Policies" are the same. Change load balancing rules by adjusting some configurations, for example, ignoring the comparison of the AS_Path attribute or IGP metric attribute. When adjusting these configurations, ensure that these configurations do not result in routing loops.
Local cross routes and routes imported between public network and VPN instances do not support load balancing.
If BGP load balancing is configured, the local device changes the next-hop address of routes to its address when advertising routes to IBGP peer groups, regardless of whether the peer next-hop-local command is used.
Procedure
- Run system-view
The system view is displayed.
- Run bgp { as-number-plain | as-number-dot }
The BGP view is displayed.
- Run ipv4-family unicast
The IPv4 unicast address family view is displayed.
The BGP-IPv4 unicast address family view is used as an example, and you can also configure load balancing in the BGP view, BGP-IPv4 unicast address family view, BGP-IPv6 unicast address family view, BGP-VPN instance IPv4 address family view, BGP multi-instance VPN instance IPv4 address family view, or BGP-VPN instance IPv6 address family view.
- Run maximum load-balancing [ ebgp | ibgp ] number [ ecmp-nexthop-changed ]
The maximum number of BGP routes to be used for load balancing is set.
By default, the maximum number of BGP routes to be used for load balancing is 1, indicating that load balancing is not implemented.
On a public network, if the routes to the same destination implement load balancing, the system will determine the optimal route type. If the optimal routes are IBGP routes, only IBGP routes carry out load balancing. If the optimal routes are EBGP routes, only EBGP routes carry out load balancing. This means that load balancing cannot be implemented among IBGP and EBGP routes with the same destination address.
Configuring BGP not to compare the AS_Path attributes or IGP metric attributes of the routes to be used for load balancing may cause routing loops.
- (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.
By default, BGP compares the AS_Path attributes of the routes to be used 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.
By default, a device compares the AS_Path attributes when selecting routes for load balancing.
Run the load-balancing igp-metric-ignore command to prevent the device from comparing IGP metric attributes when selecting routes for load balancing.
By default, BGP compares the IGP metric attributes of the routes to be used 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.
- Run commit
The configuration is committed.