BGP doesn’t choose more than one best path for each prefix like most routing systems do. Equal Cost Multi-Path Routing (ECMP) is not turned on by default, but it can be done.
The following need to be true for BGP to use the second path:
- Weight
- Local Preference
- AS Path (both AS number and AS path length)
- Origin code
- MED
- IGP metric
Every path also needs a unique next hop address. This comes into picture when you are multihomed to the same router.
Here we will show how to set up eBGP and iBGP so that they can utilize multiple paths.
Configuration
Allow us to begin with two eBGP situations.
eBGP
You can do one of two things with eBGP:
- More than one way to get to the same AS.
- Multiple paths to different ASes.
1st case of Same AS
Consider a situation where two paths lead to the same AS. The topology is as follows:
R1 is connected to R2/R3 in AS200 and is located in AS 100. Paths will be available for R1 to reach 192.168.230.0/24.
This is R1’s BGP table:
R1#show ip bgp
BGP table version is 2, local router ID is 192.168.130.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.230.0 192.168.130.3 0 200 i
*> 192.168.120.2 0 0 200 i
Despite having two pathways that are equal, R1 chose to install the path to R2. Load balancing can be enabled with the maximum-paths command:
R1(config)#router bgp 100
R1(config-router)#maximum-paths 2
Let’s look at the BGP table one more time:
R1#show ip bgp
BGP table version is 3, local router ID is 192.168.130.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.230.0 192.168.130.3 0 200 i
*> 192.168.120.2 0 0 200 i
Two entries have been added. Take note of the “m” that denotes multipath. The routing table has both paths installed.
R1#show ip route bgp
B 192.168.230.0/24 [20/0] via 192.168.130.3, 00:10:05
[20/0] via 192.168.120.2, 00:10:05
2nd case of Different AS
Let’s take a look at yet another eBGP scenario. Currently, we have several types of AS numbers, including:
To get to 4.4.4.4/32 in AS 400, R1 can go through either AS 300 or AS 200.
This is R1’s BGP table:
R1#show ip bgp
BGP table version is 2, local router ID is 192.168.130.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.130.3 0 300 400 i
*> 192.168.120.2 0 200 400 i
As its next hop address, R2 has been installed by R1. Let’s try to make that happen:
R1(config)#router bgp 1
R1(config-router)#maximum-paths 2
On the other hand, this command by itself is not helpful:
R1#show ip bgp
*May 29 10:10:13.118: %SYS-5-CONFIG_I: Configured from console by console
BGP table version is 2, local router ID is 192.168.130.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.130.3 0 300 400 i
*> 192.168.120.2 0 200 400 i
Two different AS numbers, AS 200 and AS 300, are what’s wrong here. We can tell BGP to “loosen up” its rule that the AS path numbers and length must match. Instead, it should only check the AS path length. The following secret command can be used to do this: