BGP Weight & Local Preference attributes question

Answered Question
May 2nd, 2007

I am new to BGP.

I would like to better understand how the Cisco implementation of BGP calculates the weight attribute. I would also like to know how Local Preference is calculated/set.

Per the BGP chapter in the Internetworking Technologies Handbook, it says that when Router_A receives a route advertisement from Router_B, it sets the weight to 50. When it receives an advertisement for the same route from Router_C, it sets it to 100. Both Router_B and Router_C are connected to the network advertised in the route update. How does Router_A determine what weight to associate with the route?

I would also like to know how the Local Preference is set. Is it something an admin configures or something that is calculated by the iBGP peers? How do they do this?

Even if I can get some good reading references answering my questions, it would be appreciated.

I have this problem too.
0 votes
Correct Answer by bjornarsb about 9 years 7 months ago

Configuring these attributes you could:

Specify a weight for all routes from a neighbor: neighbor {ip-address | peer-group-name} weight weight

and for LP it's:

!

router bgp 100

network 131.108.0.0

neighbor 131.108.1.1 remote-as 200

neighbor 131.108.1.1 route-map set-local-pref in

!

route-map set-local-pref permit 10

match ip address 2

set local preference 120

!

route-map set-local-pref permit 20

!

Correct Answer by mohammedmahmoud about 9 years 7 months ago

Hi,

Weight

Local to the router  Never sent in any updates (has no code) -> Used to prefer a route out of the local router when multiple routes to the same destination exists (same idea like Local-Pref) -> May be used to select one of the ISPs when manipulated on the multihomed router (The primary ISP routes should have higher weight than the secondary -> to influence the upload/upstream of the customer).

Since it is local to the router and it is never sent in updates  The default value for routes received from neighbors is 0 while the default value for local sourced routes is 32768

In route selection -> Highest weight is preferred (the Max value is 65535 and the default value is 0 (received routes from other neighbors) or 32768 (local originated) which can be set)

Weight is not considered a BGP Path attribute, it is a Cisco propritary vendor specific attribute

Example:

router bgp 123

neighbor 10.1.14.4 weight 4 -> All routes received from this neighbor shall have a weight of 4

neighbor 10.1.15.5 route-map set-weighht-200 in -> All routes received from this neighbor with AS 200 in the AS-Path

ip as-path access-list 5 permit _200_

route-map set-weight-200 permit 10

match as-path 5

set weight 200

route-map set-weight-200 permit 20

Local Pref

The BGP LOCAL_PREF PA allows routers in an AS with multiple exit points to choose which exit point is used to reach a particular NLRI. To do so, the router that is the desired exit point sets the LOCAL_PREF for its eBGP route for that NLRI to a relatively high value, then advertises that route via iBGP. The other routers in the same AS can learn of multiple routes to reach the NLRI, but they will choose the route with the higher LOCAL_PREF as the best route.

It is local to the AS -> only sent between iBGP peers -> Used to select an exit route out of multiple exit routes from the local AS -> When new routes are received from remote AS  By default they are tagged with a local-pref = 100 (Which can be set for PBR)

Example:

route-map setting-local-pref permit 10

match ip address 5

set local-preference 300

HTH, please rate if it does help,

Mohammed Mahmoud.

  • 1
  • 2
  • 3
  • 4
  • 5
Overall Rating: 5 (2 ratings)
Loading.
bjornarsb Wed, 05/02/2007 - 08:49

Hi,

Weight is a Cisco-defined attribute that is local to a router. The weight attribute is not advertised to neighboring routers. If the router learns about more than one route to the same destination, the route with the highest weight will be preferred.

The local preference attribute is used to prefer an exit point from the local autonomous system (AS). Unlike the weight attribute, the local preference attribute is propagated throughout the local AS. If there are multiple exit points from the AS, the local preference attribute is used to select the exit point for a specific route.

BGP uses the following criteria, in the order presented, to select a path for a destination:

?If the path specifies a next hop that is inaccessible, drop the update.

?Prefer the path with the largest weight.

?If the weights are the same, prefer the path with the largest local preference.

?If the local preferences are the same, prefer the path that was originated by BGP running on this router.

?If no route was originated, prefer the route that has the shortest AS_path.

?If all paths have the same AS_path length, prefer the path with the lowest origin type (where IGP is lower than EGP, and EGP is lower than incomplete).

?If the origin codes are the same, prefer the path with the lowest MED attribute.

?If the paths have the same MED, prefer the external path over the internal path.

?If the paths are still the same, prefer the path through the closest IGP neighbor.

?Prefer the path with the lowest IP address, as specified by the BGP router ID.

Regards

Bjornarsb

pkapoor Wed, 05/02/2007 - 08:55

Thanks for your interest in this question.

I do understand the information you have provided me. However, my question is not answered by that information.

I do not want to know how route selection is done by BGP.

I want to know how BGP DETERMINES what weight and local preference to assign a route before it starts the route selection procedure.

Correct Answer
mohammedmahmoud Wed, 05/02/2007 - 08:57

Hi,

Weight

Local to the router  Never sent in any updates (has no code) -> Used to prefer a route out of the local router when multiple routes to the same destination exists (same idea like Local-Pref) -> May be used to select one of the ISPs when manipulated on the multihomed router (The primary ISP routes should have higher weight than the secondary -> to influence the upload/upstream of the customer).

Since it is local to the router and it is never sent in updates  The default value for routes received from neighbors is 0 while the default value for local sourced routes is 32768

In route selection -> Highest weight is preferred (the Max value is 65535 and the default value is 0 (received routes from other neighbors) or 32768 (local originated) which can be set)

Weight is not considered a BGP Path attribute, it is a Cisco propritary vendor specific attribute

Example:

router bgp 123

neighbor 10.1.14.4 weight 4 -> All routes received from this neighbor shall have a weight of 4

neighbor 10.1.15.5 route-map set-weighht-200 in -> All routes received from this neighbor with AS 200 in the AS-Path

ip as-path access-list 5 permit _200_

route-map set-weight-200 permit 10

match as-path 5

set weight 200

route-map set-weight-200 permit 20

Local Pref

The BGP LOCAL_PREF PA allows routers in an AS with multiple exit points to choose which exit point is used to reach a particular NLRI. To do so, the router that is the desired exit point sets the LOCAL_PREF for its eBGP route for that NLRI to a relatively high value, then advertises that route via iBGP. The other routers in the same AS can learn of multiple routes to reach the NLRI, but they will choose the route with the higher LOCAL_PREF as the best route.

It is local to the AS -> only sent between iBGP peers -> Used to select an exit route out of multiple exit routes from the local AS -> When new routes are received from remote AS  By default they are tagged with a local-pref = 100 (Which can be set for PBR)

Example:

route-map setting-local-pref permit 10

match ip address 5

set local-preference 300

HTH, please rate if it does help,

Mohammed Mahmoud.

pkapoor Wed, 05/02/2007 - 09:03

Got it.

So in summary, these attributes are set manually but also have default values, if not set.

Thanks.

pkapoor Wed, 05/02/2007 - 14:01

Another attribute question.

Multi-exit Discriminator (MED):

I know MEDs are propagated between autonomous systems and not propagated into a third autonomous system.

My question is: Are MEDs also propagated within the same autnomous system?

Correct Answer
bjornarsb Wed, 05/02/2007 - 08:59

Configuring these attributes you could:

Specify a weight for all routes from a neighbor: neighbor {ip-address | peer-group-name} weight weight

and for LP it's:

!

router bgp 100

network 131.108.0.0

neighbor 131.108.1.1 remote-as 200

neighbor 131.108.1.1 route-map set-local-pref in

!

route-map set-local-pref permit 10

match ip address 2

set local preference 120

!

route-map set-local-pref permit 20

!

pkapoor Wed, 05/02/2007 - 09:03

Got it.

So in summary, these attributes are set manually but also have default values, if not set.

Thanks.

Actions

This Discussion