BGP Attributes and Path Selection

Hello Rene and Team
Currently i have been reading BGP attributes notes but am little bit confused to these attributes ** local preference** and AS prepend the way are applied to inbound and outbound direction using route map
When you create a route map you actually apply your match weather to inbound direction or out-bond direction!! i don’t get a clear picture as to why for LOCA_PREF route map is applied in-bond and AS_PREPAND is applied outbound,

Hello Emanuel

Just a clarification. Local preference is a BGP attribute, but AS prepend is not an attribute itself, but it is a method used to manipulate the AS path length, which is an attribute.

Local preference is applied within an autonomous system and is used to choose the outbound eBGP path to a particular prefix. Local preference changes can be applied using route maps in an inbound or outbound direction, between BGP neighbours. Remember, the direction has to do with the BGP updates and not the traffic itself! For example, if you apply the following route map:

R3(config)#router bgp 2
R3(config-router)#neighbor 192.168.13.1 route-map LOCALPREF in

the changes made to the local preference attribute by the LOCALPREF route-map will be applied to all prefixes in BGP updates sent from this neighbour inbound to the local router.

You can find out more detailed information about the local preference attribute and how to manipulate it in the BGP Local Preference lesson.

The AS Path Length attribute on the other hand has to do with the length of the AS to a particular prefix. You can manipulate this attribute to adjust BGP path selection by using AS prepending. Like local preference, the AS Path Length can be adjusted by applying a route map to a neighbour. The same concept applies: the direction of application has to do with the direction of the BGP update and not the direction of the actual user traffic.

So, for example, if we have the following configuration:

R1(config)#router bgp 1
R1(config-router)#neighbor 192.168.12.2 route-map PREPEND out

then the changes made to the AS path that are configured in the PREPEND route map will be applied to all of the prefixes found within the BGP update that is being sent outbound to the specific BGP neighbour. In other words, this particular neighbour will receive a BGP update with prefixes that have an adjusted AS path, as per the PREPEND route map.

For more information about AS prepending, take a look at the BGP AS Path Prepending lesson.

I hope this has been helpful!

Laz

Within your BGP statement you have different neighbor routers; however, you want a particular network to go to a certain neighbor. Can prefix list help? Or does anyone know another simpler way?

Hello Shannon

It seems that you are describing two different things, the forming of BGP peerings with neighbours, and the choice of the next-hop BGP router.

Concerning choosing neighbours, in order for BGP to function correctly, you don’t really have a choice of what neighbour peerings to make. iBGP needs to have a “full mesh” of iBGP neighbours within the AS, which means that each and every iBGP router in an AS must be neighbours with every other iBGP router. As for eBGP neighbours, you have more freedom to choose which routers will be neighbours with witch. But the choice of routers as neighbours affects the network topology and does not directly affect the route a particular prefix will take. That is defined by the next-hop IP.

You can indeed affect the choice of the next-hop IP, which will affect the path a packet will take using BGP, and this is achieved using the BGP attributes. There are various ways to do this, and these are described in the BGP attributes and path selection lesson:

Take a look at this lesson and if you have any more questions, please let us know!

I hope this has been helpful!

Laz

Unless I missed it, the question as to why the route with 203.202.143.33 was chosen was not discussed - and the result shown is based upon the following…

  1. I’m assuming that the Cisco routers in this example use the (Cisco, non-IETF) default behavior where the non-presence of any MED value is deemed “better” than the presence of a specific Med value.

  2. If true, in this instance the route selection would come down to a choice between 203.202.143.33 and 203.202.143.34 - since these are the only candidate routes than have no MED values. I then assume that the subsequent path selection rules are a tie until we get to either the neighbor router ID or (if that’s a tie as well) the neighbor IP address for 203.202.143.33 would be preferred over the alternative address of 203.202.143.34.

Is that correct?

BTW- great site! Great course! Great article! Many thanks.

Hello John

According to Cisco, paths that have no MED are actually assigned a MED of 0 and are evaluated using that value, making a MED of 0 preferrable to any other MED value since it is less than any other value a path can have. You can always change this behaviour by using the bgp bestpath med missing-as-worst command to employ the opposite behaviour. You can find more on this at this Cisco documentation. So any non-existent MED in the output you see is equivalent to a MED of 0.

With the information that is given, yes, your description is correct.

I hope this has been helpful!

Laz

Hi Rene,
Has Accumulated Interior Gateway Protocol been added?

Hello Kenneth

It has not yet been added, but Rene will get back to you on this. In the meantime, take a look at this Cisco documentation that describes the Accumulated IGP feature for BGP:

I hope this has been helpful!

Laz

AIGP is live:

@kent2612,

AIGP is now live:

How BGP selects path if I advertised routes from same AS numbers where BGP detects two similar paths with nearly the same local preference, and weight as well?

Regards,
Vijay

Hello Vijay

BGP will always follow the path selection process based on a series of attributes that it compares. These attributes are compared in a specific order and are used as tie-breakers. If the attribute is the same for two or more paths, then the next attribute is compared. If all else fails, the very last tiebreaker is the neighbor IP address, where the path with the lowest neighbor IP address is preferred. This will always be a tie-breaker because the IP addresses of neighbors cannot be the same.

The first attribute that is examined is weight. If it is the same, then the local preference will be examined. If the local preference is “nearly the same” then it is not the same, so the highest local preference will be chosen.

Take a look at this lesson to see all of the attributes and the order in which they are examined.

I hope this has been helpful!

Laz

How do you manipulate the inbound and outbound flow of traffic in BGP?
If we use weight to manipulate the outbound flow of traffic then why are we setting this as ‘in’ direction for the neighbor statement and similarly for the inbound flow of traffic we set it in ‘out’ direction.
Can AS-Path be used to manipulate both inbound and outbound?

Hello Kishore

Take a look at this post, I believe it will clarify the issues with “in” and “out” that you mention here:

But how else do we manipulate incoming and outgoing traffic? You have ultimate control over your outbound traffic flow using BGP. However, you do not have ultimate control over your incoming traffic. You can influence it in various ways, but you can’t ultimately control it. More info about this can be found at the following post:

If you have any further questions, feel free to ask!

I hope this has been helpful!

Laz

Once the Administrative distance would be same and also the prefix length would be same then we will compare the path attributes between them …Right ?

Hello,

I want to understand the best path selection criteria in case of iBGP if we are receiving the the same route from multiple paths.

Hello Kirshan

In all cases, if you receive a particular prefix from multiple sources, then you still go through the BGP attributes in order, so that you can determine which path is best, and thus, which path to put in the BGP table.

I hope this has been helpful!

Laz

Hello.
I have a question.
Does BGP not do load balance between different links ? Does BGP always choose only one path? Thanks.

Hello Raphael

By default, BGP will select only a single path for a prefix. You can see this from the very last attribute that is examined. If all other attributes are the same, at the very end, a BGP router will prefer the path with the lowest neighbor IP address. This is the last tiebreaker, and the neighbor IP addresses will never be the same, so one will always win out over the other.

If you want BGP to perform load balancing, you will have to configure it to do so. This can be done using a feature called Multipath load sharing, and you can learn about it here:

I hope this has been helpful!

Laz

Hello Narad

If you have routing information to a particular destination that is coming from several routing sources such as different routing protocols, then yes, the first thing that would be examined is the administrative distance.

Secondly, for all routing information you are receiving about a particular destination, the prefix length must be the same, otherwise, you are looking at two different destinations. In such a case, each destination would be examined independantly.

I hope this has been helpful!

Laz