Latest

BGP Attribute : Local Preference

BGP Attribute : Local Preference 

BGP is used to exchange routing information between multiple autonomous systems (AS) on the Internet. An autonomous system is a group of networks that share a common administrative area. 

BGP is used to route traffic across multiple independent systems and is the protocol used by Internet Service Providers (ISPs) to communicate routing information with one another.

 What is BGP Local Preference ?

The BGP Local Preference attribute is used to influence the outbound routing decision to choose the exit path for traffic destination in a different AS. LOCAL_PREF is not advertised to external BGP neighbors. It only affects routing decisions within your AS. The default value is 100.

The BGP attribute Local Preference is the second on the list in terms of the order priority; and it can be used to inform internal BGP routers how to exit the AS if multiple paths exist. It is applied to inbound external routes, where decisions about the best exit (outbound) path for an autonomous system are made. Here are some key points you need to know about Local Preference:

  • Local preference is sent to all internal BGP routers in your AS when sending updates
  • It’s not passed between external BGP neighbors
  • Local preference is a well-known discretionary BGP attribute, therefore it must be recognized by all BGP routers
  • Its presence in a BGP update is optional
  • The default value is 100
  • The path with the highest local preference is preferred

BGP Local Preference Scenario

Let's go with the scenario below

BGP Local Preference Scenario
Fig 1.1- BGP Local Preference Scenario

One way of doing it as below where we set the BGP with the default local preference values on the router as shown below 

R2> enable
R2# Config t
R2(config)# router bgp 100 
R2(config-router)# bgp default local-preference 200 
R2(config-router)# exit
R2#

R3> enable
R3# Config t
R3(config)# router bgp 100 
R3(config-router)# bgp default local-preference 150
R3(config-router)# exit
R3#
Another way to go with this scenario using the route-map and prefix list to put on the BGP neighbor 
  • R2 connects to AS200 and learns about the 1.1.1.1/32 network.
  • R2 connects to AS300 and learns about the same 1.1.1.1/32 network.
  • You want to prefer traffic destined for 1.1.1.1/32 to exit AS100 through R2 (connected to AS200).
You need to configure the configurations on Router R2 with the Local pref. value of 200 as shown below: 

R2> enable
R2# Config t
R2(config)# ip prefix-list NDNA 1.1.1.1/32
R2(config)# route-map PREFER_PATH permit 10 
R2(config-route-map)# match ip address prefix-list NDNA
R2(config-route-map)# set local-preference 200
R2(config-route-map)#exit
R2(config) # router bgp 100
R2(config-router) # neighbor 30.30.30.2 remote-as 200
R2(config-router)# neighbor 30.30.30.2 route-map PREFER_PATH in
R2(config-router)# exit
R2#
As we want the preferred path over the router R2, you need to configure the configurations on Router R3 with the Local pref. value of 150 which is less than the router R2  as shown below: 

R3> enable
R3# Config t
R3(config)# ip prefix-list NDNA 1.1.1.1/32
R3(config)# route-map PREFER_PATH permit 10 
R3(config-route-map)# match ip address prefix-list NDNA
R3(config-route-map)# set local-preference 150
R3(config-route-map)#exit
R3(config) # router bgp 100
R3(config-router) # neighbor 20.20.20.2 remote-as 300
R3(config-router)# neighbor 20.20.20.2 route-map PREFER_PATH in
R3(config-router)# exit
R3#
When designing and configurations for the BGP protocol for the path influence, you will see the result while using the Local preference:
  • Local preference only affects path selection within your AS. It's not advertised to external BGP neighbors.
  • Local preference works alongside other BGP attributes like AS path length and Multi-Exit Discriminator (MED) to determine the best path.