What is BGP Local Preference?
The BGP Local Preference attribute is used to manipulate the best outbound path and applied on inbound external routes. Unlike the Weight attribute, Local Preference is passed on to iBGP peers.
If multiple paths exist, Local Preference informs iBGP routers how to exit the AS ie which path to prefer for outgoing traffic. Local Preference is a 32-bit number and can range from 0 to 4294967295.
The default preference value is 100. The greater the Local preference e value, the more it becomes the preferred path
Related Article – eBGP vs iBGP
Local preferences can be applied in 2 ways –
1. Directly putting default local preference by iBGP router to its neighbours. Eg –
2. On per route basis by calling a Route-map and access/prefix-list through a neighbour. Eg –
Below scenario will help in clarifying how local preference can be configured –
Related- BGP Origin Attribute
As in the above diagram, we are required to have R1 prefer R3 instead of R2 as the best path for reachability to network 188.8.131.52/24 (Loopback of R4).
Related – BGP States
Under the normal case, R1 will receive route for R4 loopback from both iBGP neighbours R2 and R3 .R2 will be the preferred path based on BGP path preference criteria of R2 having lower Router ID ie 192.168.12.2 and R3 with Router ID 192.168.13.3. Below is the snapshot.
Now, we configure the R3 to advertise itself as a preferred path by manipulating the “Local Preference” value as below –t
Once the above configuration is performed on R3 and the same information is learned by its iBGP neighbour i.e. R1, the best path for R1 changes from R2 to R3 since R3 has Higher (more preferred) Local preference than R2.
Related – BGP Interview Questions
Related- BGP Allowas in