A path with the lowest metric is selected by IGPs. One case in point is:
- RIP chooses the path that requires the fewest hops.
- The one with the lowest cost is the one that OSPF chooses.
- Unless you modify the K values, EIGRP will choose the path with the best combination of bandwidth and delay.
BGP, on the other hand, chooses the optimal route by considering a set of criteria. Going for the quickest path based on a metric isn’t as crucial as having fine-grained control over how and to which autonomous systems your communication is forwarded on the Internet.
For the time being, we are discussing the optimal path for BGP. This indicates that BGP is required to make a decision regarding which path to utilize when it acquires knowledge of the same prefix through BGP. In addition to this, the prefix must be perfectly identical. The administrative distance is a factor that determines whether or not the router will install the BGP optimal path in the routing table.
As seen in the image below, several BGP neighbors provide R1 with information about 10.10.10.0/24.
It needs to choose the best BGP path. The one from R2; its iBGP neighbor? Or one of the eBGP routes from R3, R4, or R5?
Why, out of all those five possible paths, did BGP choose this particular path as the best possible option?
- Attributes
This particular route was chosen on the basis of the following characteristics:
Priority |
Attribute |
1 |
Weight |
2 |
Local Preference |
3 |
Originate |
4 |
AS path length |
5 |
Origin code |
6 |
MED |
7 |
eBGP path over iBGP path |
8 |
Shortest IGP path to BGP next hop |
9 |
Oldest path |
10 |
Router ID |
11 |
Neighbor IP address |
Let’s quickly go over every attribute. We’ll go over these in more depth in other lessons.
- Weight
Choose the route that has the most weight. This value is unique to Cisco and is local to the router. In the absence of a local router origin, the value is set to 0.
- Local Preference
The local preference is used within an autonomous system and is sent back and forth between iBGP routers. The path with the best local preference is the one we want to take. It comes with a value of 100.
- Originate
Choose the way that the local router started. You can see next hop 0.0.0.0 in the BGP table. The BGP network command, reassignment, or aggregation can all be used to get a path in the BGP table. A BGP router will choose routes that it added to BGP over routes that were added by another router.
- AS path length
To minimize AS path length, use the smallest possible path. Take AS path 1 2 3 as an example; it’s better than AS path 1 2 3 4 5.
- Origin code
Choose the lowest Origin code. You can choose from three origin codes: