Cisco Support Community
cancel
Showing results for 
Search instead for 
Did you mean: 
Announcements

Welcome to Cisco Support Community. We would love to have your feedback.

For an introduction to the new site, click here. And see here for current known issues.

New Member

Cost and Local Preference in BGP

What is the difference between Cost and Local Preference attributes in BGP?

Krishna

14 REPLIES

Re: Cost and Local Preference in BGP

Hello,

    BGP has good tools to decision how to select best path. Local Preference is one of them. Actually IGP selects best routes by using cost. Routing device will use Admistrative Distance to select best route first except logest prefix.

BGP Ref: http://www.cisco.com/en/US/tech/tk365/technologies_tech_note09186a0080094431.shtml

HTH,

Toshi

Bronze

Cost and Local Preference in BGP

Hi Krishna,

There is no 'Cost' in BGP...  Cost is an OSPF metric.

BGP uses a number of metrics, including Weight, MED, AS PATH and Local Preference which are used in different scenarios depending upon what you are trying to influence.

I imagine that this question comes from your previous thread in which I mentioned using Community Strings to indicate your routing preferences to another organisation, who would set Local Preference in response.

Local Preference is a metric used within a BGP AS in order to specify the prefered destination for a specific prefix.

If one prefix (e.g. 10.10.0.0/16) is advertised into the AS through only one gateway, then the LP value is ignored - there is only one way the traffic to this destination can go.  However if the prefix is advertsed by multiple gateways the traffic will route via the one which advertises the prefix with the highest LP.

The Default LP is 100, so if Router A advertises a prefix without setting the LP and Router B advertises at 150, then traffic will route via router B.  If the LP for that prefix on Router B is changed to 50, then traffic will route via Router A.

If you are more familiar with OSPF, then a BGP Local Preference is similar to an OSPF External Type-2 advertisement.

Please see

http://www.cisco.com/en/US/tech/tk365/technologies_tech_note09186a00800c95bb.shtml#localpref Which gives a good explanation of Local Preference.

Purple

Cost and Local Preference in BGP

Hi Nick,

If you are more familiar with OSPF, then a BGP Local Preference is similar to an OSPF External Type-2 advertisement.

These are completely unrelated concepts and they can't be compared.

Regards.

Alain

Don't forget to rate helpful posts.
Bronze

Re: Cost and Local Preference in BGP

Hi Alain,

These are completely unrelated concepts and they can't be compared.

In the way that the underlying technology works, yes, you are quite correct, VERY different, but from a high level, they really are similar...

The BGP LP value set on a prefix is fixed, no matter what your 'distance' from the advertising router within the AS.  The Same Applies to OE2s.

Granted, OSPF is an IGP, and BGP is an EGP, but other than that, to a user just dipping his toe in more advanced routing as the OP is, they're nigh on identical, and a good comparison is a great teaching tool.

If I'm glossing over any major differences that in particular you think should be pointed out, please let me know :-)

Many Thanks,

Nick

Re: Cost and Local Preference in BGP

Hi Guys,

      Actually OSPF has tools to select routes. No matter what cost is  

      OSPF perfers O > O*IA > O*E1 > O*E2 > O*N1 > O*N2. 

      You will suprise if you only focus on "cost" on OSPF. IMO, BGP is different 

@Alian, long time no see.  How have you been? You're still around here. 5-Point

HTH,

Toshi

Purple

Cost and Local Preference in BGP

Hi Toshi,

I hadn't seen you here for a long time either.    Hope you're doing well.

Good Post about the OSPF route selection  It deserves a 5 too I think.

Regards.

Alain

Don't forget to rate helpful posts.
Purple

Cost and Local Preference in BGP

Hi,

The BGP LP value set on a prefix is fixed, no matter what your  'distance' from the advertising router within the AS.  The Same Applies  to OE2s.

The LP is part of the path decision process when there are multiple ways to get to a prefix so if you really want to compare to OE2, then it should be compared to the forward metric used to decide which ASBR to use to get to the external destination. But even if the AS_PATH would be unequal as the LP is taken into account sooner in the decision process then you could go out the longer AS_PATH way( unlike OSPF for OE1 which will take the shorter cost route) so I really don't like to compare the 2 because it could confuse more than shed light in my opinion.

Regards.

Alain

Don't forget to rate helpful posts.
New Member

Cost and Local Preference in BGP

Guys,

This is my mistake, my biggest mistake.

Actually I wanted to compare WEIGHT and LOCAL PREFERENCE of BGP. There shouldn't be any OSPF cost in picture.

Sorry all..

Krishna

Bronze

Cost and Local Preference in BGP

Hi Krishna,

That's OK.

Simply put, weight is significant only on the router on which it is set. so if router1 has 2 peers advertising the same destination, you can use Weight to control which direction to send the traffic.  Weight is Cisco proprietary, and it is not sent on to any BGP peers.  Weight is also the very first item in the BGP routing decision, and so if it has been set, it will override any other metrics that have been set for that prefix.

LP is set on prefixes as they are advertised into an AS. If the same prefix is advertised into am AS by two different routers, with different LP values, the one that advertised the highest LP will have the traffic routed to it.

Hope that helps!

Please rate posts that you find useful :-)

Nick

Cost and Local Preference in BGP

Hello,

        Try this one : http://www.cisco.com/en/US/tech/tk365/technologies_tech_note09186a00800c95bb.shtml

        IMO,It's a good document for BGP(first step).

HTH,

Toshi

New Member

Cost and Local Preference in BGP

Hi Nick,

Does that the Weight attribute is significant only for incoming routes and LP is for both incoming and outgoing(since LP is an attribute that will be advertised to the BGP peers)

2 peers sending 2 diff routes to same destination. We can locally assign a high weight to whatever routes a particular peer send, and that route will be chosen as the best BGP rouete. Am I right?

Krishna

Purple

Cost and Local Preference in BGP

Hi Krishna,

Weight and LP are both used for outgoing path selection, the difference is weight is Cisco proprietary and only local on a router( this is not really a path attribute) and LP is a path attribute local to an AS. Weight is considered first in the path decision process.

Yes you're right higher weight wins.

Regards.

Alain

Don't forget to rate helpful posts.

Cost and Local Preference in BGP

Hi Krishna


Weight Attribute is the attribute is a Cisco−defined attribute. This attribute uses weight to select a best path. The weight is assigned locally to the router. The value only makes sense to the specific router. The value is not propagated or carried through any of the route updates. A weight can be a number from 0 to 65,535. Paths that the router originates have a weight of 32,768 by default, and other paths have a weight of 0.

Routes with a higher weight value have preference when multiple routes to the same destination exist.

And the weight attribute will effect in IBGP only not in EBGP.


Local Preference Attribute is an indication to the AS about which path has preference to exit the AS in order to reach a certain network. A path with a higher local preference is preferred more. The default value for local preference is 100.

You set local preference with the issue of the bgp default local−preference value command. You can also set local preference with route maps


Hope the above clear and understood.


Please rate the helpfull posts.
Regards,
Naidu.

Purple

Cost and Local Preference in BGP

Hi,

And the weight attribute will effect in IBGP only not in EBGP

I don't agree with you.

Regards.

Alain.

Don't forget to rate helpful posts.
1389
Views
15
Helpful
14
Replies
CreatePlease login to create content