BGP Attributes
BGP Data Structures
Neighbor Table
The address in the bgp summary table shows the IP used in the peering, not the Router ID.
BGP Table
Lists all prefixes learned from all peers
If no routes towards a destination show the “>” code, you should investigate why no route is considered valid. Check with:
Route Attributes
Well Known
Well Known attributes are those attributes that must be supported by every BGP implementation.
Mandatory
Mandatory attributes are those attributes that must be sent in each Update.
Whenever a prefix is advertised to an eBGP peer, the AS is prepended to the AS_PATH. AS_PATH prepending is used to make the AS_PATH longer than normal in order to make some routes more preferred than others.
AS_PATH prepending
Ignoring AS_PATH when searching best path
The AS_PATH is an important tiebreaker when selecting the best BGP route for a destination. However, it can be ignored with the hidden command:
AS_PATH loop prevention
AS_PATH also acts as a Loop prevention mechanism. When a BGP peer receives a route that includes its own AS in the AS_PATH, the update is dropped. An extreme way of filtering is to prepend the next AS to the AS_PATH, forcing a neighbor to drop the route due to loop prevention.
However, there are situations when you would want to ignore this behavior and accept routes with your own AS-NUMBER in the AS_PATH. (For example when you have the same AS number configured in 2 locations that connect over an ISP BGP cloud. Normally you would not accept routes that are originated in your own AS, but this time you should). To enable this feature, use:
Another option si for the ISP to override the AS-NUMBER of the customer and replace it with its own AS in the AS-PATH. The command to do this is:
Private AS
When using Private ASes, you should strip them from the AS_PATH when sending to an eBGP peer:
Local AS
Another way of modifying the AS_PATH is via the local-as command, detailed here.
AS_PATH vs AS_SET vs AS_SEQUENCE vs AS_CONFED_SEQUENCE
There are two types of AS_PATH attributes:
AS_SET: an unordered list of AS numbers along a path. It is used when a BGP speaker creates an aggregate route. The AS_SET will include all AS-es in the AS_PATHs of the children routes in order to prevent loops. It will appear between {} in the AS_PATH and will only count as 1 AS when calculating the shortest AS_PATH. When the AS_SET is included in the AS_PATH, the ATOMIC_AGGREGATE does not have to be included with the aggregate.
AS_SEQUENCE: an ordered list of AS numbers along a path
When using confederations, an AS_CONFED_SEQUENCE appears in the AS_PATH between (). They do not count in the Shortest AS_PATH calculation.
Discretionary
Discretionary attributes are those attributes that are supported by every implementation of BGP (Well Known) but may not be sent in every Updated
Local Preference is used only in updates towards iBGP peers. If a BGP speaker receives multiple routes to the same destination, it compares the LOCAL_PREF and the highest value wins. You can set the local preference in a route-map, using:
The default value of local-preference can be modified using:
Optional
Optional attributes are those attributes that may not be supported by every BGP implementation.
Transitive
Transitive attributes are those attributes that may not be supported by every BGP implementation (Optional) but must be passed to the neighbor in the Update messages.
It contains the AS number and the Router ID of the router that originated the Aggregate route
Non-Transitive
Non-Transitive attributes are those attributes that may not be supported by every BGP implementation (Optional) are are not be passed to the neighbor in the Update messages.
Allows an AS to inform another AS of the preferred ingress point. The lowest MED is preferred. The MED attribute is not passed beyond the receiving AS, so it is used to influence traffic between 2 directly connected AS-es. To influence route preference beyond the neighboring AS, use AS_PATH prepend. If an ISP must forward traffic to a client AS, it will usually try to find the shortest way to send the traffic to the client AS. This behavior is cold “Hot Potato Routing”. However, the client might prefer this traffic to enter it’s network on a router that it’s closer to the actual destination. In this way, known as “Cold Potato Routing” the traffic will travel more inside the ISP and less inside the Client’s network. Routing by MED is one way of implementing “Cold Potato Routing”. By default, MED is compared only for routes that come from the same AS. Use the following command to compare MED regardless of the AS they were received:
By default, routes are compared in order, the newest to the 2nd newest, the best of these to the third newest and so on to the oldest route. When comparing MED, this order can be changed using:
When this command is enabled, the routes are grouped by the last AS and a best route is chosen for each group. if the “bgp always-compare-med” command is also used, the best routes for each group are compared between them and the lowest MED wins. Else, the MED will not be used because the routes came from different ASes and the route decision processes will go to the next step. See this article for an example. By default, a Cisco router considers a route that doesn’t have the MED attribute set as heaving the value 0, which is the most preferred MED. You can change this behavior, using:
This will make the router consider a route with a missing MED as the worst MED (4.294.967.295) You can enable MED comparison only for routes originated in the same confederation, using:
When redistributing into BGP, the router will use the value set for the IGP metric as the value of the MED attribute of the route. If no value is set in the redistribution command, then the value of default-metric is used:
Weight
It is a proprietary Cisco attribute that applies only to the current router and is not advertised to other peers. The higher the weight, the more preferable the route. By default, routes learned from peers have a weight of 0, while locally generated routes have a weight of 65535. To set the Weight of incoming routes, use:
Choosing the best route
Valid routes
In order to enter the route selection process, a route received via BGP must be considered valid. To do so, first it should be verified if the route appears in the BGP table:
Most often then not, the reasons why a route is not considered valid, are:
If BGP Synchronization is enabled, the route is not found in the IGP table. When using OSPF, the Router ID of OSPF and BGP must match
The router ignores the prefix because the current AS-NUMBER is already in the AS-PATH of the received route – eBGP only
The route is dampened
The next-hop is unreachable
For each prefix, the route that is chosen as the best route will be marked with the “>” character.
Route Selection Process
W – Highest Weight – Cisco only
L – Highest LOCAL_PREF
OL – Prefer a route that was Originated Locally. Routes originated with the network command are preferred to routes originated with the redistribute command, which are preferred to routes originated with the aggregate command, which are preferred to routes learned from other peers.
A – Shortest AS_PATH
O – Lowest Origin Code = i < e < ?
M – Lowest MED if the routes go to the same AS
E – Prefer eBGP routes first, then iBGP routes
N – Shortest path to the NEXT_HOP – lowest IGP (AD/metric) to the NEXT_HOP
M – If Multipath is enabled, install multiple routes in the routing table, if they are from the same neighboring AS:
Although multiple paths are added to the routing table, only one route will be considered best path and will be advertised to other neighbors. If Multipath is disabled, or no best route has been selected, then continue to the next step
O – Oldest routes – only for eBGP routes. There are situations when this step is skipped, like when using the command:
See this article.
R – Prefer the route originated by the router with the lowest Router ID (or Originator ID in Route Reflector environments).
C – For routes originated by the same Router ID, choose the one with the shortest CLUSTER_LIST
N – Prefer the route that came from the Neighbor with the lowest address
Remember it as With L.OL.A. O.M.E.N. M.O.R. C.N.. For detailed information, read this article
Last updated