BGP: BGP Attributes and Path Selection and Manipulation

In the previous blog post, we established a strong foundation for understanding the Border Gateway Protocol (BGP), exploring its core functions and significance in internet routing. Now, we'll take it a step further and delve into the world of BGP attributes.
BGP attributes are pieces of information added to BGP routes. They help provide details about the route. BGP uses attributes to make path selection decisions. These attributes not only help routers determine the best paths for routing traffic but also empower network administrators to manipulate path selection and gain valuable insights for network troubleshooting.
There are four major types of attributes. They include:
- Well-Known Mandatory
- Well-Known Discretionary
- Optional Transitive
- Optional Non-Transitive
Well-Known Mandatory BGP Attributes
These attributes must be recognized by all BGP routers, present in all BGP updates, and passed on to other BGP routers. They include the AS path, origin, and next hop.
AS Path: This is the list of ASes through which updates have traversed. When a router receives the same network from multiple paths, by default it makes its decision based on the number of AS hops in the AS path, and it picks the route with the smallest number of hops. In other words, if multiple paths exist to get to a network, the path with the shortest AS path is the preferred route (all other factors being equal). The AS path also helps in preventing loops, as mentioned in the previous blog.
Origin: Origin informs all ASes in the internetwork how the network was introduced into BGP. It uses three value types to identify this:
- i = Advertised from an IGP in the AS
- e = Redistributed from an external routing protocol or via static route
- ? = Advertised from sources that are not fully reliable
Internally learned routes are considered more reliable than externally learned routes (all other factors being equal).
Next Hop: BGP is an AS-by-AS routing protocol. This means that the next hop is not simply the immediately adjacent router, but rather a router that facilitates reaching the next Autonomous System (AS). The next hop is determined by the router from which the BGP route was learned.
- eBGP: For eBGP (External BGP), the next hop is typically the IP address of the ASBR (Autonomous System Boundary Router) in the neighboring AS. This ASBR acts as the gateway to that next AS.
- iBGP: For iBGP (Internal BGP), the next hop determination is more nuanced and depends on IGP reachability within the AS:
- Same IGP Domain: If the iBGP speaker and the originating eBGP speaker (the ASBR that initially learned the route from the external AS) are in the same IGP domain, the iBGP speaker advertises the route with the original next hop – the IP address of the ASBR. Routers within the AS can then use their IGP to reach this ASBR.
- Different IGP Domains: If the iBGP speaker and the originating eBGP speaker are in different IGP domains, the iBGP speaker must perform "next-hop-self." It changes the next hop to its own IP address. This is because routers in the AS won't know how to reach the ASBR (the original next hop) directly since it's in a different IGP domain. By setting the next hop to itself, the iBGP speaker becomes the point of contact for reaching the external AS. Traffic is directed to the iBGP speaker, which then has the necessary routing information (via its IGP) to reach the ASBR in the other IGP domain.
Well-Known Discretionary BGP Attributes
These attributes must be recognized by all BGP routers and can be passed on to other BGP routers but need not be present in an update. They include Local preference, weight, and atomic aggregate.
Local Preference: Local preference influences the selection of exit paths from an AS. The path with the highest preference value is more desirable. It is advertised only to iBGP neighbors within an AS. On Cisco IOS, the default value is typically 100.
Weight: The Weight is a locally significant attribute used to influence path selection on the router where it is configured. It's a way for a router to prioritize paths learned from different neighbors. A higher weight is preferred. It is important to remember that Weight is not propagated to other routers. The name “weight” is a Cisco convention; other vendors may have equivalent mechanisms, but the specific term 'Weight' is Cisco-centric.
Atomic Aggregate: Atomic Aggregate is a BGP path attribute that is set when route summarization (aggregation) is performed. This flag indicates that the aggregated route's AS path might be incomplete, specifically that segments of the AS path representing the more specific, original prefixes that were aggregated might have been discarded during the summarization process. The Atomic Aggregate attribute serves as an indicator to other BGP routers that the AS path for this aggregated route may not provide the complete path information to all possible destinations within the summarized prefix.
Optional Transitive BGP Attributes
Optional Transitive attributes are not required to be recognized by all BGP routers, but they should be recognized and passed on to other BGP routers if the router has the capability to do so. These attributes include Aggregator and Community.
Aggregator: The Aggregator attribute identifies the router and AS that performed route summarization/aggregation for a given route. It includes the router ID and the AS number of the router that aggregated the route. This attribute is useful to network administrators when trying to analyze the network and figure out where the route summarization happened.
Community: Community attributes allow for tagging routes with custom attributes, which can then be used for route filtering, route manipulation, and traffic engineering.
Optional Non-Transitive BGP Attributes
If the BGP process does not recognize the attribute, then it can ignore the update and not advertise the path to its peers. It also has the capability to still process the update but mark the attribute as partial. They Include Multi-Exit Discriminator (MED), Originator ID, and Cluster ID.
Multi-Exit Discriminator (MED): The Multi-Exit Discriminator (MED) influences how traffic enters an Autonomous System (AS) and is advertised to eBGP neighbors to influence how those neighbors access the advertising AS. The MED is not propagated beyond the receiving AS. This is a key difference between the AS path and the MED: the AS path is propagated to every AS, while the MED remains within the receiving AS. Because the MED is not propagated beyond the receiving AS, and the receiving AS may disregard the MED value, its scope is limited, making it a 'weaker' metric compared to the AS path. A lower MED value is preferred. The default value of the MED attribute is 0.
Originator ID: In networks using route reflectors, the Originator ID gives information on what router originated the BGP route. It contains the router ID of the router in question and is only used in iBGP sessions. The primary purpose of the Originator ID is to prevent loops in an AS. When a route is reflected by a route reflector, the Originator ID allows routers to avoid re-advertising the route back to the router that originally originated it.
Cluster ID: This attribute is used in route reflectors with the primary goal of preventing loops. Each route reflector has its own Cluster ID and adds it to BGP routes when advertising them. When a client in the AS receives a route, it checks for the Cluster ID. If its own route reflector's Cluster ID is present in the route, the client understands that the route has already been propagated within its cluster, preventing it from unnecessary re-advertising.
How Does BGP Perform Path Selection?
BGP path selection determines the optimal route for network traffic from multiple available paths. While BGP offers flexibility through manually configured policies, path selection is not based on bandwidth. Instead, BGP employs a deterministic process, evaluating various path attributes to identify the most preferred route. These attributes are configured by network engineers to achieve specific routing objectives. This policy-driven approach makes BGP a powerful tool, but it also places a significant responsibility on network administrators to ensure proper configuration and avoid unintended consequences.
Pre-Checks (Before Attribute Comparison):
Before evaluating attributes, BGP performs the following essential checks:
- Synchronization: A BGP route must be synchronized with the IGP (Interior Gateway Protocol) if the BGP speaker and the next-hop router are in the same AS.
- AS Path Loops: The AS path must not contain the router's own AS number.
- Valid Next Hop: The next-hop router must be reachable.
Attribute-Based Selection (Ordered):
BGP compares attributes in the following order. The path selection process stops as soon as a clear best path is identified.
- Weight: Prefer the path with the highest weight (local to the router).
- Local Preference: Prefer the path with the highest local preference (propagated within the AS).
- Locally Originated Routes: Prefer routes originated by the local router (next hop = 0.0.0.0).
- AS Path Length: Prefer the path with the shortest AS path.
- Origin Code: Prefer the path with the lowest origin code (IGP < EGP < Incomplete).
- MED (Multi-Exit Discriminator): Prefer the path with the lowest MED (exchanged between ASes).
- eBGP vs. iBGP: Prefer eBGP paths over iBGP paths (based on Administrative Distance: eBGP = 20, iBGP = 200). eBGP paths are preferred because they represent connections to external ASes and are generally considered more desirable than iBGP paths, which are internal.
- IGP Metric to Next Hop: Prefer the path with the lowest IGP metric to the next-hop router.
- Oldest eBGP Path: For eBGP paths, prefer the oldest path. This helps to prevent route flapping.
- Router ID: Prefer the path learned from the neighbor with the lowest BGP router ID.
- Neighbor IP Address: Prefer the path learned from the neighbor with the lowest IP address.
Conclusion
This blog post has provided an overview of BGP attributes and their essential role in BGP path selection. The next blog post will focus on BGP configuration. Stay tuned!