BGP Local Preference

BGP Local Preference is a BGP attribute that is used for Outbound path manipulation in today's Computer Networks. Path manipulation is known as BGP Traffic Engineering as well and the Local Preference attribute is the most common technique for it in real networks. In this blog post I will be explaining the use case, comparison with other outbound path manipulation techniques, and how the BGP Local Preference attribute works we will understand.

First of all, we should know that it is not a Cisco specific attribute, it is a standard attribute, which is used in other vendor equipment as well. Vendor interoperability works without issue. Because a picture is worth a thousand words, let's have a look at the below topology to understand how it works.


In the above topology, AS65000 has two paths to AS1. Prefixes from AS1 are learned via two paths but AS65000 wants to use the left path as a Primary Path and the right path as a backup path. The reason in real-life people wants to use their links as primary and backup this way is usually a cost.

One of the links might be expensive and another can be cheaper, and they may want to use the cheaper links as a primary if the requirement is a budget. Though it may not be always the case, usually a cost is a big decision factor. Another one can be controlling the quality, using the more robust links for the traffic and less robust ones as a backup, and so on.

Okay, the above ones might be the reason why we want to use the links as primary and backup, but how BGP local preference is used to accomplish this goal. Basically, if from both of the links, the same subnet mask prefix is advertised, then the local preference attribute CAN be used for the best path selection.


BGP local preference higher or lower?

  Although it is not mentioned in the BGP-4 RFC, every vendor implements BGP Local Preference default value as 100. And, Higher BGP Local preference value is chosen over a lower BGP Local Preference. So if we have two paths as in the above topology, one is primary and another one as a backup, for the primary path, we should have a higher BGP Local Preference value.

Of course, the assumption is, from both of the paths we are learning the prefix with the same subnet mask length. So, if over one path, the prefix is learned as 192.168.0.0/23 and another one as 192.168.9.9/24, /24 one will be chosen as the best path/primary path, even BGP local preference is higher on the /23 path.


BGP local preference vs Weight

Another important note is this comparison. BGP Weight attribute is a Cisco-specific attribute that is also used for  Outbound Path Manipulation. But the main difference is, the BGP Weight attribute is local to the router. This means if you have a BGP Policy, the Weight attribute value is not exchanged/agreed between the routers but BGP Local Preference is an AS-wide attribute, thus it is exchanged/agreed by every BGP speaking device in the Internal BGP network.

Still, the BGP Weight attribute can be used on the device if we have two paths from the same device to the destination and it is considered before BGP Local preference. So, in the best path selection, the Weight attribute is more important than BGP Local preference, but in real life, it is not much used in large-scale networks.

Created by
Orhan Ergun

Orhan Ergun, CCIE/CCDE Trainer, Author of Many Networking Books, Network Design Advisor, and Cisco Champion 2019/2020/2021

He created OrhanErgun.Net 10 years ago and has been serving the IT industry with his renowned and awarded training.

Wrote many books, mostly on Network Design, joined many IETF RFCs, gave Public talks at many Forums, and mentored thousands of his students.  

Today, with his carefully selected instructors, OrhanErgun.Net is providing IT courses to tens of thousands of IT engineers. 

View profile