Hi everyone, in this blog post we will walk through how to enable eBGP Equal Cost Multipathing (ECMP) and Unequal Cost multipathing. This comes into play when you are multihomed to different ISPs (AS’s). By default, BGP is not designed to perform load balancing, but it can be configured to do so. BGP will always select a best path as per the path selection process and installs only one route in the routing table.
Be aware that BGP Multipath is only useful for traffic locally on the router, ie when the router has multiple eBGP paths to the same destination (via same or different AS’es). Multipath is in no way “passed” to other routers/neighbors.
To achieve Load balancing, the following attributes in the path selection process among the routes should match.
- Local Preference
- AS Path (Two considerations here : AS number and AS path length)
- Origin code
- IGP metric to the next-hop
Also, the next hop address for each path must be different. This comes into play when you are multihomed to the same router
Lets lab this. Here is my topology that I have been using for my CCIE labs.
We have 4 AS’es – AS 65000, AS 65100, AS 100 & AS 200. Lets assume we are on AS 65100 (R5) and want to reach the loopback interface 220.127.116.11 in AS 200 (R7). R5 has 3 paths to reach there:
- via AS 100 -> AS 200 (next-hop 18.104.22.168)
- via AS 65000 -> AS 100 ->AS 200 (next-hop 22.214.171.124)
- via AS 65000 -> AS 100 ->AS 200 (next-hop 10.0.0.1)
Can you tell which path will be used assuming all the metric defaults are used? Yes, the path with the shorter AS_PATH length. So it is via AS 100 -> AS 200 (next-hop 126.96.36.199)
Lets apply some PBR here to change the best path via AS 65000 – We will have two paths there and see which path will be chosen as best path. Now this is how R5 config looks like:
I’ve created a route-map “MULTIPATH” that matches the prefixes from an ACL (188.8.131.52). This route map will set the local preference for that prefix to 200. This route-map is then applied to the eBGP neighbor statements in AS 65000 in the inbound direction. The result is that this prefix 184.108.40.206 gets a higher local preference in AS 65100 when learned from AS 65000. But when this prefix is learned from AS 100, it’s local preference will be 100 only.
Now, Can you tell which path will be used by R5 to reach 220.127.116.11? The path from R5 via AS 65000 -> AS 100 ->AS 200 using next-hop 18.104.22.168 will win because it now used the next-hop with lowest BGP Router-ID to decide the best path. In this case it is R4 (22.214.171.124).
Now lets enable ECMP so that both paths through AS 65000 will be used. There are two things to consider here:
First, in this case the AS_PATH of both routes are the same (same AS numbers and AS length). So one command “maximum-paths X” is sufficient here.
In second case, if both paths are via different AS BUT with same AS length, the you need a condition relaxation. You need to issue an additional command “bgp bestpath as-path multipath-relax”
Now lets see how the routing table on R5 looks like:
You can see that the load distribution rate is 1:1. But what if you need to do an unequal cost load sharing (when the uplink bandwidths are different for example?)
Let’s try that now:
I am setting different bandwidths on the interfaces used for eBGP peering.
Now I am telling BGP process to consider bandwidth on the interfaces as weight when doing multi-pathing.
Lets see the routing table now: The load distribution ratio is now proportionate to the uplink bandwidth 2:1
Hope this post was useful. Thanks