Unlike most routing protocols, BGP only selects a single best path for each prefix. It doesn’t do ECMP (Equal Cost Multi-Path Routing) by default, but it is possible to enable this.

For BGP to use the second path, the following attributes have to match:

  • Weight
  • Local Preference
  • AS Path (both AS number and AS path length)
  • Origin code
  • MED
  • IGP metric

Also, the next hop address for each path must be different. This comes into play when you are multihomed to the same router.

In this lesson, I’ll show you how to configure eBGP and iBGP to use more than one path.

Configuration

We’ll start with two eBGP scenarios.

eBGP

When it comes to eBGP, there are two options:

  • Multiple paths to the same AS.
  • Multiple paths to different ASes.

Same AS


Let’s look at a scenario where we have two paths to the same AS. Here’s the topology:

Bgp As1 As23 Three Routers

R1 is in AS 1  and connected to R2/R3 in AS23. R1 will have paths to get to 192.168.23.0/24.

  • Configurations
  • R1
  • R2
  • R3

Want to take a look for yourself? Here you will find the startup configuration of each device.

Here’s the BGP table of R1:

R1#show ip bgp 
BGP table version is 2, local router ID is 192.168.13.1
Status codes: s suppressed, d damped, h history, * valid, > best, i - internal, 
              r RIB-failure, S Stale, m multipath, b backup-path, f RT-Filter, 
              x best-external, a additional-path, c RIB-compressed, 
              t secondary path, 
Origin codes: i - IGP, e - EGP, ? - incomplete
RPKI validation codes: V valid, I invalid, N Not found

     Network          Next Hop            Metric LocPrf Weight Path
 *    192.168.23.0     192.168.13.3                           0 23 i
 *>                    192.168.12.2             0             0 23 i

R1 has two equal paths but decided to install the path to R2. We can enable load balancing with the maximum-paths command:

R1(config)#router bgp 1
R1(config-router)#maximum-paths 2

Let’s take another look at the BGP table:

R1#show ip bgp 
BGP table version is 3, local router ID is 192.168.13.1
Status codes: s suppressed, d damped, h history, * valid, > best, i - internal, 
              r RIB-failure, S Stale, m multipath, b backup-path, f RT-Filter, 
              x best-external, a additional-path, c RIB-compressed, 
              t secondary path, 
Origin codes: i - IGP, e - EGP, ? - incomplete
RPKI validation codes: V valid, I invalid, N Not found

     Network          Next Hop            Metric LocPrf Weight Path
 *m   192.168.23.0     192.168.13.3                           0 23 i
 *>                    192.168.12.2             0             0 23 i

Now we have two entries. Note the “m” that stands for multipath. Both paths are installed in the routing table:

R1#show ip route bgp

B     192.168.23.0/24 [20/0] via 192.168.13.3, 00:13:02
                      [20/0] via 192.168.12.2, 00:13:02

That’s looking good.

Different AS



Let’s look at another eBGP scenario. This time, we have multiple AS numbers:

Bgp As 1 To 4

R1 can go through AS 3 or AS 2 to get to 4.4.4.4/32 in AS 4.

  • Configurations
  • R1
  • R2
  • R3
  • R4

Want to take a look for yourself? Here you will find the startup configuration of each device.

Here’s the BGP table of R1:

R1#show ip bgp
BGP table version is 2, local router ID is 192.168.13.1
Status codes: s suppressed, d damped, h history, * valid, > best, i - internal, 
              r RIB-failure, S Stale, m multipath, b backup-path, f RT-Filter, 
              x best-external, a additional-path, c RIB-compressed, 
              t secondary path, 
Origin codes: i - IGP, e - EGP, ? - incomplete
RPKI validation codes: V valid, I invalid, N Not found

     Network          Next Hop            Metric LocPrf Weight Path
 *    4.4.4.4/32       192.168.13.3                           0 3 4 i
 *>                    192.168.12.2                           0 2 4 i

R1 has installed R2 as its next hop address. Let’s see if we can change that:

R1(config)#router bgp 1
R1(config-router)#maximum-paths 2

This command alone, however, doesn’t help:

R1#show ip bgp
*Mar 21 11:10:13.118: %SYS-5-CONFIG_I: Configured from console by console
BGP table version is 2, local router ID is 192.168.13.1
Status codes: s suppressed, d damped, h history, * valid, > best, i - internal, 
              r RIB-failure, S Stale, m multipath, b backup-path, f RT-Filter, 
              x best-external, a additional-path, c RIB-compressed, 
              t secondary path, 
Origin codes: i - IGP, e - EGP, ? - incomplete
RPKI validation codes: V valid, I invalid, N Not found

     Network          Next Hop            Metric LocPrf Weight Path
 *    4.4.4.4/32       192.168.13.3                           0 3 4 i
 *>                    192.168.12.2                           0 2 4 i

The problem here is that we have two different AS numbers, AS 2 and AS 3. We can tell BGP to “relax” its requirement of having the same AS path numbers and AS path length to only checking the AS path length. This can be done with the following hidden command:

R1(config-router)#bgp bestpath as-path multipath-relax

Here’s how this command affects R1:

R1#show ip bgp
BGP table version is 3, local router ID is 192.168.13.1
Status codes: s suppressed, d damped, h history, * valid, > best, i - internal, 
              r RIB-failure, S Stale, m multipath, b backup-path, f RT-Filter, 
              x best-external, a additional-path, c RIB-compressed, 
              t secondary path, 
Origin codes: i - IGP, e - EGP, ? - incomplete
RPKI validation codes: V valid, I invalid, N Not found

     Network          Next Hop            Metric LocPrf Weight Path
 *m   4.4.4.4/32       192.168.13.3                           0 3 4 i
 *>                    192.168.12.2                           0 2 4 i

We now see the “m” so we know R1 uses R3 as well. We can confirm this by looking at the routing table:

R1#show ip route 4.4.4.4 | include from
  Last update from 192.168.12.2 00:00:55 ago
  * 192.168.13.3, from 192.168.13.3, 00:00:55 ago
    192.168.12.2, from 192.168.12.2, 00:00:55 ago

That’s all we have for eBGP.

iBGP



What about iBGP? Let’s take a look at the following topology:

Bgp As123 As4 Four Routers

R1, R2, and R3 are in AS 123 while R4 is in AS 4. R1 can use either R2 or R3 to get to 4.4.4.4/32.

  • Configurations
  • R1
  • R2
  • R3
  • R4

Want to take a look for yourself? Here you will find the startup configuration of each device.

Let’s have a look at the BGP table:

R1#show ip bgp
BGP table version is 12, local router ID is 1.1.1.1
Status codes: s suppressed, d damped, h history, * valid, > best, i - internal, 
              r RIB-failure, S Stale, m multipath, b backup-path, f RT-Filter, 
              x best-external, a additional-path, c RIB-compressed, 
              t secondary path, 
Origin codes: i - IGP, e - EGP, ? - incomplete
RPKI validation codes: V valid, I invalid, N Not found

     Network          Next Hop            Metric LocPrf Weight Path
 *>i  4.4.4.4/32       192.168.24.4             0    100      0 4 i
 * i                   192.168.34.4             0    100      0 4 i
 *>i  192.168.24.0     2.2.2.2                  0    100      0 i
 *>i  192.168.34.0     3.3.3.3                  0    100      0 i
 r i  192.168.123.0    3.3.3.3                  0    100      0 i
 r>i                   2.2.2.2                  0    100      0 i

R1 has two options to get to 4.4.4.4/32 but is using only one entry. We can change this with the maximum-paths command but you need to add the ibgp parameter:

R1(config)#router bgp 123 
R1(config-router)#maximum-paths ibgp 2

Let’s take another look:

R1#show ip bgp 
BGP table version is 10, local router ID is 1.1.1.1
Status codes: s suppressed, d damped, h history, * valid, > best, i - internal, 
              r RIB-failure, S Stale, m multipath, b backup-path, f RT-Filter, 
              x best-external, a additional-path, c RIB-compressed, 
              t secondary path, 
Origin codes: i - IGP, e - EGP, ? - incomplete
RPKI validation codes: V valid, I invalid, N Not found

     Network          Next Hop            Metric LocPrf Weight Path
 *>i  4.4.4.4/32       192.168.24.4             0    100      0 4 i
 *mi                   192.168.34.4             0    100      0 4 i
 *>i  192.168.24.0     2.2.2.2                  0    100      0 i
 *>i  192.168.34.0     3.3.3.3                  0    100      0 i
 rmi  192.168.123.0    3.3.3.3                  0    100      0 i
 r>i                   2.2.2.2                  0    100      0 i

That’s looking better. Let’s check the routing table:

R1#show ip route bgp

      4.0.0.0/32 is subnetted, 1 subnets
B        4.4.4.4 [200/0] via 192.168.34.4, 00:00:37
                 [200/0] via 192.168.24.4, 00:00:37
B     192.168.24.0/24 [200/0] via 2.2.2.2, 00:26:11
B     192.168.34.0/24 [200/0] via 3.3.3.3, 00:26:18

Looking good, we have two entries on R1 in the routing table.

Conclusion

You have now learned how to enable ECMP (Equal-Cost Multi-Path Routing) for BGP.

  • All BGP attributes have to be the same for different paths, except for the next hop address.
  • You can enable load balancing with the maximum-paths command.
  • When you use eBGP with different AS numbers, you need to add the hidden bgp bestpath as-path multipath-relax command
  • When you use iBGP, make sure you add the ibgp parameter to the maximum-paths command

I hope you enjoyed this lesson. If you have any questions feel free to leave a comment!