Concept of Local Preference in BGP : BGP Attribute
Today I am going to talk about the BGP attribute which is widely used in many of the enterprise networks. BGP attribute name "Local Preference" is used for controlling outbound traffic in the network. It actually used when we have two different paths and want to select the preference path then we are going to use the local preference by putting the higher local preference value to the route.
Local Preference is not local to the router, the local preference attribute is part of the routing update and is exchanged among routers in the same AS. So if you applied local preference in your network it will effect the network part which is under same AS.
We have two different method to apply the local preference in the network. The one way is to use the bgp default local-preference command and the other way is by using the route-map to set the local preference. I will cover the configuration part of the both the ways in the network.
Below is the basic topology where we are using the local preference in the enterprise network. The topology and the IP addresses uses here below is for the demo purposes and has no relevance with any of the existing and the live network.
Lets start with the way how we are going to configure the local preference by the first method and that method is as follows:
BGP default local preference command
Configurations on Router C
!
So above configuration shows the default way to set the local preference. Now we are going to have another way of setting local preference as follows:
Using Route-maps for setting Local preference
Configurations on Router D
We have two different method to apply the local preference in the network. The one way is to use the bgp default local-preference command and the other way is by using the route-map to set the local preference. I will cover the configuration part of the both the ways in the network.
Below is the basic topology where we are using the local preference in the enterprise network. The topology and the IP addresses uses here below is for the demo purposes and has no relevance with any of the existing and the live network.
![]() |
Fig 1.1- Local Preference- BGP Attribute Sample Topology |
BGP default local preference command
Configurations on Router C
!
router bgp 256
neighbor 1.1.1.1 remote-as 100
neighbor 128.213.11.2 remote-as 256
bgp default local-preference 150
!
Configurations on Router D
!
router bgp 256
neighbor 3.3.3.4 remote-as 300
neighbor 128.213.11.1 remote-as 256
bgp default local-preference 200
!
So above configuration shows the default way to set the local preference. Now we are going to have another way of setting local preference as follows:
Using Route-maps for setting Local preference
Configurations on Router D
!
router bgp 256
neighbor 3.3.3.4 remote-as 300
route-map SETLOCALIN in
neighbor 128.213.11.1 remote-as 256
!
ip as-path 7 permit ^300$
route-map SETLOCALIN permit 10
match as-path 7
set local-preference 200
!
route-map SETLOCALIN permit 20
!
So I hope you guys are now more clear about local preference by both ways.