BGP Attributes and Path Selection (2024)

Lesson Contents

BGP (Border Gateway Protocol) routers usually receive multiple paths to the same destination. Like how our IGPs (RIP, EIGRP, OSPF) work, we need to select the best path to each destination.




IGPs select the path with the lowest metric. For example:

    • RIP selects the path with the lowest hop count.
    • OSPF selects the path with the lowest cost.
    • EIGRP selects the path with the highest bandwidth and lowest delay (unless you change the K values).

BGP, however, selects the best path based on a list of attributes. On the Internet, it’s more important that you have granular control over how you forward your traffic and to which autonomous systems instead of just going for the shortest path based on a metric.

We are talking about the BGP best path here. That means that BGP has to decide which path to use when it learns about the same prefix through BGP. The prefix also has to be exactly the same. Whether the router will install the BGP best path in the routing table depends on theadministrative distance.

In the picture below, R1 learns about 5.5.5.0/24 from multiple BGP neighbors:

BGP Attributes and Path Selection (1)

Let’s look at a quick example of an actual BGP router. If you haven’t seen a BGP table before, check out the how to read a BGP table lesson first. Below, I have the output of the BGP table of a looking glass server:

route-views.optus.net.au>show ip bgpBGP table version is 781755060, local router ID is 203.202.125.6Status codes: s suppressed, d damped, h history, * valid, > best, i - internal, r RIB-failure, S Stale, m multipath, b backup-path, x best-externalOrigin codes: i - IGP, e - EGP,? - incomplete Network Next Hop Metric LocPrf Weight Path* 1.0.0.0/24 203.202.143.34 0 7474 4826 13335 i* 192.65.89.161 1 0 7474 4826 13335 i* 202.139.124.130 1 0 7474 4826 13335 i* 203.13.132.7 10 0 7474 4826 13335 i*> 203.202.143.33 0 7474 4826 13335 i

This BGP router has five paths for network 1.0.0.0/24. Look at the > symbol at the bottom left. The > symbol means that BGP has selected this path as the best path. This path will be installed in the routing table.

Out of all those five paths, why did BGP select this path as the best path?

Attributes

This path was selected based on the following attributes:

PriorityAttribute
1Weight
2Local Preference
3Originate
4AS path length
5Origin code
6MED
7eBGP path over iBGP path
8Shortest IGP path to BGP next hop
9Oldest path
10Router ID
11Neighbor IP address

Let me give you a quick overview of each attribute. We will cover these in other lessonsin detail.

Weight

Prefer the path with the highest weight. This is a value that islocal to the router, and it’s Cisco proprietary. The default value is 0 for all routes not originated by the local router. You can learn how it works in the BGP weight attribute lesson.

Local Preference

The local preference is used within an autonomous system and exchanged between iBGP routers. We prefer the path with the highest local preference. The default value is 100. To learn more, look at the BGP local preference attribute lesson.

Originate

Prefer the path that the local router originated. In the BGP table, you will see next hop 0.0.0.0. You can get a path in the BGP table through the BGP network command, redistribution, or aggregation. A BGP router will prefer routes that it installed into BGP itself over a route that another router installed in BGP. You can see it in action in the BGP attribute locally originated lesson.

AS path length

Prefer the path with the shortest AS path length. For example, AS path 1 2 3 is preferred over AS path 1 2 3 4 5. You can learn more about AS path length here.

Origin code

Prefer the lowest origin code. There are three origin codes:

  • IGP
  • EGP
  • INCOMPLETE

IGP is lower than EGP, and EGP is lower than INCOMPLETE. You can learn how it works in the origin code lesson.

MED

Prefer the path with the lowest MED. The MED is exchanged between autonomous systems. For a detailed explanation, take alook at the MED lesson.

eBGP path over iBGP path

Prefer eBGP (external BGP) over iBGP (internal BGP) paths.

Shortest IGP path to BGP next hop

Prefer the path within the autonomous system with the lowest IGP metric to the BGP next hop. This means that if there are multiple paths within the AS to a BGP next hop, the router prefers the path with the lowest IGP metric to get there.

Oldest Path

Prefer the path thatwe received first,in other words, the oldest path.

Router ID

Prefer the path with the lowest BGP neighbor router ID. The router ID is based on the highest IP address. If you have a loopback interface, the IP address on the loopback will be used. The router ID can also be manually configured.

Neighbor IP address

Prefer the path with the lowest neighbor IP address. If you have two eBGP routers and two links in between, then the router ID will be the same. In this case, the neighbor’s IP address is the tiebreaker.

Path Selection

When BGP has multiple paths to a destination, they are stored in the BGP table. All paths are in the BGP table, but only one gets installed in the routing table.

Which path do we select? We start at the top of the list with BGP attributes and work our way to the bottom:

  1. We start with weight because it’s at the top of the BGP attributes list. We now have two options:
    1. If one path has a better weight, we select this path as the best path.
    2. If the weight is equal, we move down to the next attribute.
  2. The next attribute is local preference. Once again, we have two options:
    1. If one path has a better local preference, then we select this path as the best path.
    2. If the local preference is equal, we move down to the next attribute.
  3. We work our way down this attribute list until we have a tiebreaker to select the best path. If all paths have the same BGP attributes, we end up with the neighbor IP address.

There are someexceptions to the BGP path selection process when you use (advanced) BGP features like confederations, route reflectors, or multipath. Cisco has a detailed list of the BGP best path selection algorithm.

Conclusion

You have learned how BGP uses a list of attributes to determine what the best path is. I hope this lesson has been useful in understanding how BGP selects the best path.

Sure, let's break down the concepts used in the article about Border Gateway Protocol (BGP) and its path selection attributes:

Concepts Covered in the Article:

  1. Attributes: These are characteristics used by BGP to determine the best path to a destination. They include:

    • Weight: A Cisco-specific attribute preferring the path with the highest weight.
    • Local Preference: Used within an autonomous system to select the path with the highest local preference.
    • Originate: Prefers paths originated by the local router.
    • AS Path Length: Prefers paths with the shortest Autonomous System path.
    • Origin Code: Prefers paths based on origin codes (IGP, EGP, or INCOMPLETE).
    • MED (Multi-Exit Discriminator): Prefers paths with the lowest MED, exchanged between autonomous systems.
    • eBGP over iBGP Path: Prefers external BGP paths over internal BGP paths.
    • Shortest IGP Path to BGP Next Hop: Prefers the path with the lowest IGP metric to reach the BGP next hop.
    • Oldest Path: Prefers paths received first.
    • Router ID and Neighbor IP Address: Used as tiebreakers in path selection.
  2. Path Selection Process: BGP uses these attributes in a specific order to select the best path:

    • It starts with the highest priority attribute (Weight) and proceeds down the list.
    • If one path excels in a particular attribute, it becomes the best path.
    • If attributes are equal, BGP moves to the next attribute in the list.
    • The process continues until a tiebreaker (like Neighbor IP Address) determines the best path.
  3. Conclusion: Understanding BGP's attribute-based path selection helps in comprehending how BGP determines the best route among multiple options.

If you're interested, we can delve deeper into any specific attribute or the advanced BGP features mentioned in the article. Just let me know where you'd like to focus!

BGP Attributes and Path Selection (2024)
Top Articles
Latest Posts
Article information

Author: Prof. An Powlowski

Last Updated:

Views: 6070

Rating: 4.3 / 5 (44 voted)

Reviews: 91% of readers found this page helpful

Author information

Name: Prof. An Powlowski

Birthday: 1992-09-29

Address: Apt. 994 8891 Orval Hill, Brittnyburgh, AZ 41023-0398

Phone: +26417467956738

Job: District Marketing Strategist

Hobby: Embroidery, Bodybuilding, Motor sports, Amateur radio, Wood carving, Whittling, Air sports

Introduction: My name is Prof. An Powlowski, I am a charming, helpful, attractive, good, graceful, thoughtful, vast person who loves writing and wants to share my knowledge and understanding with you.