Border Gateway Protocol (BGP) is like a map that helps computers on the Internet find their way from one network to another. BGP attributes are like signs along the way that give extra information about how to get there. By understanding these signs, network administrators can make sure data packets take the best route possible!
In this article, we’ll take an in-depth look at BGP path attributes, the best path selection process, and its cheat sheet.
Before we dive in, make sure you have read through my previous BGP posts.
What is BGP Path Attribute, and why is it used?
BGP path attributes are pieces of information that are associated with a route. They provide additional information about the route, such as its origin, the AS-Path, the next hop, and more. BGP uses this information to determine which route is best for a particular destination.
BGP path attributes are used to influence the best path selection process. By manipulating these attributes, network administrators can control which routes are preferred and which are not.
What are the BGP Path Attributes Categories?
BGP Path Attributes are categorized into four categories:-
- Well-Known Mandatory
- Well-known Discretionary
- Optional Transitive
- Optional Non-Transitive
1. BGP Well-Known Mandatory Attributes
The well-known mandatory attributes are the attributes that must be present in every BGP update. They are used to control basic BGP operations and make routing decisions. These attributes include AS_PATH, NEXT_HOP, and ORIGIN.
- AS_PATH is a sequence of AS numbers through which the packet must pass to reach a destination. BGP routers use this for loop detection.
- The NEXT_HOP attribute indicates the next BGP hop that a packet should take.
- The ORIGIN field indicates the source of the routing information in terms of either being internal or external to an autonomous system.
2. BGP Well-Known Discretionary Attributes
Well-known discretionary attributes are BGP attributes that could be present in an update but are not required. Routing decisions can be made based on the values of these attributes, and they can be used to prefer particular routes over others.
- The LOCAL_PREF attribute is used to prefer a certain route over other routes with the same destination.
- The ATOMIC_AGGREGATE attribute is used to indicate that a route is the result of an atomic aggregation of other routes.
3. BGP Optional Transitive Attributes
Optional transitive attributes are BGP path attributes that are not required for the route advertisement but are passed along unfiltered for each update. These attributes are used to aid in the decision-making process for choosing the best path. In addition, they generally contain more specific information about a route, such as its community, its extended community, and its aggregate. In addition, a transitive attribute will be passed even if it is not recognized, but the partial bit will be set to indicate that the attribute was not recognized.
- The Community attribute is used to group routes together for the purpose of route aggregation or policy definition.
- The Extended Community attribute provides additional information about a route and can be used to identify a particular route within a community.
- The AGGREGATOR attribute is used to indicate the address and AS number of the router that performed the route aggregation.
4. BGP Optional Non-Transitive Attribute
Optional non-transitive attributes are BGP path attributes that are not required for the route advertisement and will not be passed or modified by the router. These attributes will be discarded if not recognized by the router.
- The MULTI-EXIT DISCRIMINATOR (MED) attribute is used to indicate the preference of a route when the router is connected to the same destination via multiple paths.
Let’s take a closer look at the four main types of BGP path attributes, which are commonly used to affect how BGP chooses paths. In future posts, I’ll talk about the community attribute, which service providers mostly use to influence the traffic pattern.
BGP Path Attribute – Weight (Cisco Proprietary)
- When it comes to outbound routing decisions, the BGP Path Attribute – Weight is a Cisco proprietary feature that can be used when one router has multiple links to a provider or providers.
- It’s only locally significant within a router and never sent out in updates.
- You can set weight values per neighbor with the “neighbor weight” command or with a “route-map.”
- To enforce newly-set weight values, you’ll need to re-establish BGP sessions with the neighbors by clearing BGP.
- If no weight value is specified, the default value of 0 is applied to received routes, while routes that the router originates locally have a default value of 32768.
- Lastly, you can match routes in any combination of prefix-lists, AS-path filters, or other BGP attributes – any routes not matched by the route-map will be discarded.
BGP Path Attribute – Local Preference
- When it comes to Outbound routing decisions, the BGP Path Attribute – Local Preference Attribute is a useful tool. It can be used when there are one or multiple routers with one or multiple links to a provider or providers.
- A BGP router can set the local preference when processing incoming route updates, doing redistribution, or sending outgoing route updates.
- The default value for this attribute is 100, and higher values are always preferred.
BGP Path Attribute – AS-Path
- When it comes to Inbound routing decisions, the BGP Path Attribute – AS-Path is used to decide which return path should be taken when multiple paths are available.
- AS-Path prepending can be useful for two reasons: Firstly, to manipulate the outgoing AS-Path length so that the primary/backup links are properly selected for the return path. Secondly, distributing the return traffic load for multi-homed scenarios.
- To make sure newly set AS-Path lengths are enforced, you’ll need to re-send BGP updates outbound to your neighbors (this is known as a clearing BGP Session).
- When it comes to reducing traffic load on a certain path, AS-Path prepending should be done on outgoing eBGP updates over that path.
- It’s important to note that you won’t be able to monitor or debug AS-Path prepending on the sending router – only on the receiving router.
BGP Path Attribute – MED
- The BGP Path Attribute – MED is used to make Inbound routing decisions when there are multiple return paths from the same Autonomous System (AS) to one or more routers.
- By default, no MED attribute is attached to a route, except if the router originated the route.
- The Cisco default MED value of received updates is 0.
- A lower MED value is preferred, and this value will not be propagated outside of the receiving AS.
- By default, the MED is only considered when selecting routes from the same AS and does not include intra-confederation autonomous systems. However, when using the “network” or “redistribution” command, the metric in the routing table will be used as the MED instead.
Important Points and Pre-requisites of the BGP path Selection process
Important Points for BGP Path Selection:
- The only paths which are eligible for advertising and added to the RIB are those marked with a ‘>.’
- The prefix must have IGP next-hop reachability.
- The synchronization rule must be met or disabled.
- Outbound routing policy affects inbound traffic. For example, Local_pref and Weight.
- Inbound routing policy affects outbound traffic. For example, AS_Path and MED.
BGP Best Path Selection Algorithm Cheat Sheet
When it comes to selecting the best path for a BGP route, there are several attributes that need to be taken into consideration.
- First and foremost, the highest Cisco weight is preferred (this is local to the router and Cisco Proprietary).
- Next, the highest local preference (also local to the AS) should be chosen.
- Then, routes that originated locally should be given priority.
- After that, paths with the shortest AS paths should be selected (only their length is compared).
- Following this, the lowest origin code should be favored (IGP-i before EGP-e before Incomplete-?).
- Additionally, routes with the lowest MED should be preferred.
- External (eBGP) paths are always chosen over internal (iBGP) paths; for eBGP paths, those that are oldest and most stable will take precedence, while for iBGP paths, those through closest IGP neighbors with lowest IGP metrics will have priority.
- Finally, if route reflectors are configured, then non-reflected routes will take precedence over reflected ones. Among reflected ones, those with shorter cluster-lists will be favored over longer ones.
- Lastly, BGP routes from routers with lower BGP router-IDs will get preference.
Real World Use Case – Role of BGP path attributes for selecting BGP Best Path.
BGP path attributes are a key part of figuring out the best way to get to a destination. As was already said, these attributes tell you more about the route, such as Origin, the AS-Path, the next hop, and more.
This information is used by BGP to determine which route is best for a particular destination. For example, if a route has a higher local preference value than another route, BGP will prefer that route.
Let’s look into the details of how BGP selects the best path.
In the BGP best route selection process, all these criteria are considered when choosing the best route to a destination. The values of these attributes are compared, and the best route is chosen accordingly.
For example, consider a scenario where Router A wants to send traffic to Router D, and it has two possible paths to choose from:
- Router A -> Router B -> Router C -> Router D (AS path length: 3, local preference: 100, MED: 200)
- Router A -> Router E -> Router F -> Router G -> Router D (AS path length: 4, local preference: 50, MED: 100)
In this scenario, Router A would compare the values of the preference attributes for each path to determine the best path. The first path has a shorter AS path length, a higher local preference value, and a higher MED value, so Router A would choose the first path as the best path to router D.
What are some common interview questions about BGP?
When preparing for a BGP interview, it is crucial to familiarize yourself with common bgp interview questions and answers. Employers often ask about the basic understanding of BGP functionality, route selection criteria, and scaling techniques. Additionally, questions about BGP attributes, communities, and best practices for troubleshooting BGP issues are common. Being well-prepared will enhance your chances of success.
BGP Path attributes and the Best Path Selection process can be tricky to understand, but once you get a good grasp of all the factors that go into making this decision, it becomes much more straightforward. Knowing these concepts will help you understand how different paths influence transit traffic and make sure that the best paths are being used. Taking time to analyze the attributes of a chosen path helps ensure that your system runs smoothly and efficiently. So take some time to learn about BGP path attributes – it’ll be worth it!