July 8, 2023

BGP Local Preference Attribute: The Higher The Better

2 min read

One of the many BGP attributes is the Local Preference. Seventy percent of those who are just new in BGP will ask were to apply Local Preference.

BGP Local Preference

Local Preference is used to influence outbound traffic. The higher value is preferred over the lower one.

Letโ€™s take an example.

Looking at my diagram, to route traffic to Dasypoda, if we have all BGP attribute set as default, what path will Apidae take? Is it going to be Colletidae (10.0.30.3)->Dasypoda (10.0.60.6) or  Andrenidae (10.0.70.4)-> Mellitinae (10.0.40.5) -> Dasypoda (10.0.50.6)? If we didnโ€™t set the Local Preference, it will surely go to Collitidae (10.0.30.3)->Dasypoda (10.0.60.6) path.

BGP Local Preference

Let us check the routing table to know why it prefers the Colletidae (10.0.30.3)->Dasypoda (10.0.60.6) path:

As you can see, the valid best path to 6.6.6.0/24 is through 10.0.30.3.

BGP Local Preference: show ip bgp

The question is why? Since Local Preference is not configured, BGP checks the next path selection attribute which is the AS Path. The shortest is more preferred. However, we do not want the Colletidae (10.0.30.3)->Dasypoda (10.0.60.6) path. We want the packet to take the Andrenidae (10.0.70.4)-> Mellitinae (10.0.40.5) -> Dasypoda (10.0.50.6) path. So how are we going to do it? Let us configure the Local Preference.

Apidae(config)#route-map PRIMARY-PATH permit 10
 Apidae(config-route-map)#set local
 Apidae(config-route-map)#set local-preference ?
 <0-4294967295> Preference value


Apidae(config-route-map)#set local-preference 250
 Apidae(config-route-map)#exit
 Apidae(config)#router bgp 65500
 Apidae(config-router)#neigh 10.0.70.4 route-map PRIMARY-PATH ?
 in Apply map to incoming routes
 out Apply map to outbound routes

Apidae(config-router)#neigh 10.0.70.4 route-map PRIMARY-PATH in
 Apidae(config-router)#end

Now that the LOCAL PREFERENCE is changed to prefer the route to neighbor Andrenidae, the path Andrenidae (10.0.70.4)-> Mellitinae (10.0.40.5) -> Dasypoda (10.0.50.6)  is now considered as the best valid path in the BGP table.

BGP Local Preference: show ip bgp

There is another way of manipulating the Local Preference and it is through bgp default local-preference command. Keep in mind that it is just changing the default value of Local Preference from 100 to the value you entered.

Before we end this discussion, what can you notice about this ping result?

BGP Local Preference

We have configured the Local Preference and it works as it prefers the Andrenidae (10.0.70.4)-> Mellitinae (10.0.40.5) -> Dasypoda (10.0.50.6). But what happened to the return traffic? We will see why on our next topic โ€“ BGP Multi-Exit Discriminator (MED).

Leave a Reply