Overview

Packets destined to a network learned by BGP (BGP route) can also be load balanced.This section describes two methods for load balancing BGP routes.

BGP Route Load Balancing

Equal-cost load balancing is available by default in IGPs such as OSPF. If there are equal-cost routes for a specific network, multiple routes can be registered in the routing table for load balancing. Load balancing is also possible with BGP. There are two main methods.

  • Make sure that packets to the NEXT_HOP IP address are load-balanced
  • Allow BGP routes other than the best path to be added to the routing table (maximum-paths)

This section describes two methods of load balancing BGP routes.

Load balancing to IP addresses of NEXT_HOP

The next hop of the route information learned by BGP is the IP address of NEXT_HOP attribute. When routing packets using BGP route information, the routing table is re-searched to forward packets to the IP address of NEXT_HOP attribute.

Therefore, load balancing to IP addresses of NEXT_HOP attribute allows load balancing BGP routes.

Figure  Load balancing to IP addresses of NEXT_HOP Part1
Figure Load balancing to IP addresses of NEXT_HOP Part1

This figure shows an example of load balancing toward the NEXT_HOP IP address; R1 and R2 have established neighbors on the IP addresses of each other’s loopback interfaces.

R1 has learned the route 100.2.2.0/24 via BGP from R2 and registered it in the routing table. Its next hop is 2.2.2.2. The routes for routing packets to 2.2.2.2 are learned by OSPF, allowing for equal-cost load balancing.

Figure Load balancing to IP addresses of NEXT_HOP Part2

When a packet comes in to R1 destined for 100.2.2.0/24, BGP route information is matched. Its next-hop address is 2.2.2.2. The router re-searches the routing table to forward to 2.2.2.2. The route for forwarding to 2.2.2.2 is designed to allow for equal-cost load balancing, so that the resulting routing to 100.2.2.0/24 can be load balanced over the two links.

Such load balancing is the same for routes learned from IBGP neighbors as for routes learned from EBGP neighbors.

maximum-paths

In BGP, basically only the best-path route information is placed in the routing table. The maximum-paths command allows load balancing by placing route information other than the best path in the routing table.

In order for the maximum-paths command to register multiple BGP routes in the routing table, the WEIGHT, LOCAL_PREFERENCE, MED, AS_PATH, ORIGIN, and other attributes of each route must all be the same. Since BGP attributes are equivalent to metrics in IGP, it can also still be thought of as an equal-cost load balance.

The maximum-paths command has the following syntax.

BGP maximum-paths command

(config)#router bgp <AS>
(config-rouer)#maximum-paths {1-6}

<AS> : AS number
{1-6} : Number of routes to be placed on the routing table

maximum-paths Configuration Example

Figure maximum-paths configuration example part1
Figure maximum-paths configuration example part1

In the network diagram shown in the figure, on R3, configure the maximum-paths command.

The BGP configuration for each router before configuring the maximum-paths command is as follows

R1 BGP Configuration

router bgp 1
 no synchronization
 bgp log-neighbor-changes
 network 172.16.1.0 mask 255.255.255.0
 neighbor 3.3.3.3 remote-as 100
 neighbor 3.3.3.3 ebgp-multihop 255
 neighbor 3.3.3.3 update-source Loopback0
 no auto-summary

R2 BGP Configuration

router bgp 1
 no synchronization
 bgp log-neighbor-changes
 network 172.16.1.0 mask 255.255.255.0
 neighbor 3.3.3.3 remote-as 100
 neighbor 3.3.3.3 ebgp-multihop 255
 neighbor 3.3.3.3 update-source Loopback0
 no auto-summary

R3 BGP Configuration

router bgp 100
 no synchronization
 bgp log-neighbor-changes
 neighbor 1.1.1.1 remote-as 1
 neighbor 1.1.1.1 ebgp-multihop 255
 neighbor 1.1.1.1 update-source Loopback0
 neighbor 2.2.2.2 remote-as 1
 neighbor 2.2.2.2 ebgp-multihop 255
 neighbor 2.2.2.2 update-source Loopback0
 no auto-summary

In addition, the BGP and routing tables on R3 are as follows

R3 BGP Table/Routing Table

R3#show ip bgp
-- omitted --

   Network          Next Hop            Metric LocPrf Weight Path
*  172.16.1.0/24    2.2.2.2                  0             0 1 i
*>                  1.1.1.1                  0             0 1 i
R3#show ip bgp 172.16.1.0
BGP routing table entry for 172.16.1.0/24, version 2
Paths: (2 available, best #2, table Default-IP-Routing-Table)
  Advertised to non peer-group peers:
  2.2.2.2
  1
    2.2.2.2 (metric 2) from 2.2.2.2 (2.2.2.2)
      Origin IGP, metric 0, localpref 100, valid, external
  1
    1.1.1.1 (metric 2) from 1.1.1.1 (1.1.1.1)
      Origin IGP, metric 0, localpref 100, valid, external, best
R3#show ip route
-- omitted --


Gateway of last resort is not set

     1.0.0.0/32 is subnetted, 1 subnets
O       1.1.1.1 [110/2] via 192.168.13.1, 00:05:26, FastEthernet0/0
C    192.168.13.0/24 is directly connected, FastEthernet0/0
     2.0.0.0/32 is subnetted, 1 subnets
O       2.2.2.2 [110/2] via 192.168.23.2, 00:05:26, FastEthernet0/1
     3.0.0.0/32 is subnetted, 1 subnets
C       3.3.3.3 is directly connected, Loopback0
     172.16.0.0/24 is subnetted, 1 subnets
B       172.16.1.0 [20/0] via 1.1.1.1, 00:04:28
C    192.168.23.0/24 is directly connected, FastEthernet0/1

On R3, the route received from R1 is the best path. This is because the router ID of R1 is smaller than that of R2. And only the route received from R1, which is the best path, is registered in the routing table.

From this state, configure the maximum-paths command on R3.

R3 maximum-paths

router bgp 100
 maximum-paths 2

After configuring the maximum-paths command, R3’s BGP table and routing table will change as follows.

R3 BGP Table/Routing Table after configuring maximum-paths

R3#show ip bgp
-- omitted --

   Network          Next Hop            Metric LocPrf Weight Path
*  172.16.1.0/24    2.2.2.2                  0             0 1 i
*>                  1.1.1.1                  0             0 1 i
R3#show ip bgp 172.16.1.0
BGP routing table entry for 172.16.1.0/24, version 2
Paths: (2 available, best #2, table Default-IP-Routing-Table)
Multipath: eBGP
  Advertised to non peer-group peers:
  2.2.2.2
  1
    2.2.2.2 (metric 2) from 2.2.2.2 (2.2.2.2)
      Origin IGP, metric 0, localpref 100, valid, external, multipath
  1
    1.1.1.1 (metric 2) from 1.1.1.1 (1.1.1.1)
      Origin IGP, metric 0, localpref 100, valid, external, multipath, best
R3#show ip route
-- omitted --

Gateway of last resort is not set

     1.0.0.0/32 is subnetted, 1 subnets
O       1.1.1.1 [110/2] via 192.168.13.1, 00:13:42, FastEthernet0/0
C    192.168.13.0/24 is directly connected, FastEthernet0/0
     2.0.0.0/32 is subnetted, 1 subnets
O       2.2.2.2 [110/2] via 192.168.23.2, 00:13:42, FastEthernet0/1
     3.0.0.0/32 is subnetted, 1 subnets
C       3.3.3.3 is directly connected, Loopback0
     172.16.0.0/24 is subnetted, 1 subnets
B       172.16.1.0 [20/0] via 2.2.2.2, 00:00:54
                   [20/0] via 1.1.1.1, 00:00:54
C    192.168.23.0/24 is directly connected, FastEthernet0/1

Even if the maximum-paths command is configured, only one best path is still determined. Then, if AS_PATH, MED, LOCAL_PREFERENCE, WEIGHT, and ORIGIN are the same, even if it is not the best path, it can be placed in the routing table.

 Figure maximum-paths configuration example part2
Figure maximum-paths configuration example part2

Next, let’s also see the case where the maximu-paths command does not work: on R3, change the MED attribute of the incoming route from R1.

R3  Change attributes of routes received from R1

route-map TEST permit 10
 set metric 10
!
router bgp 100
 neighbor 1.1.1.1 route-map TEST in

After changing the MED of the BGP route to be received from R1, the BGP table and routing table will look like this.

R3 BGP Table/Routing Table(After changing MED attribute)

R3#show ip bgp
-- omitted --

   Network          Next Hop            Metric LocPrf Weight Path
*> 172.16.1.0/24    2.2.2.2                  0             0 1 i
*                   1.1.1.1                 10             0 1 i
R3#show ip bgp 172.16.1.0
BGP routing table entry for 172.16.1.0/24, version 3
Paths: (2 available, best #1, table Default-IP-Routing-Table)
Multipath: eBGP
Flag: 0x800
  Advertised to non peer-group peers:
  1.1.1.1
  1
    2.2.2.2 (metric 2) from 2.2.2.2 (2.2.2.2)
      Origin IGP, metric 0, localpref 100, valid, external, best
  1
    1.1.1.1 (metric 2) from 1.1.1.1 (1.1.1.1)
      Origin IGP, metric 10, localpref 100, valid, external
R3#show ip route
-- omitted --

Gateway of last resort is not set

     1.0.0.0/32 is subnetted, 1 subnets
O       1.1.1.1 [110/2] via 192.168.13.1, 00:26:50, FastEthernet0/0
C    192.168.13.0/24 is directly connected, FastEthernet0/0
     2.0.0.0/32 is subnetted, 1 subnets
O       2.2.2.2 [110/2] via 192.168.23.2, 00:26:50, FastEthernet0/1
     3.0.0.0/32 is subnetted, 1 subnets
C       3.3.3.3 is directly connected, Loopback0
     172.16.0.0/24 is subnetted, 1 subnets
B       172.16.1.0 [20/0] via 2.2.2.2, 00:00:13
C    192.168.23.0/24 is directly connected, FastEthernet0/1

Changing the attribute in this way will prevent all but the best paths from being registered in the routing table, even if the maximum-paths command is configured.

Summary

Points

  • The main methods for load balancing BGP routes are
    • Make sure that packets to the NEXT_HOP IP address are load-balanced
    • Allow BGP routes other than the best path to be added to the routing table (maximum-paths)