BGP Local Preference Attribute

BGP local preference is a well-known discretionary attribute and can be used to choose the exit path for an autonomous system (AS). When your AS has multiple possible exit paths, you can use local preference to decide which one to use. Local preference is exchanged between iBGP routers, so you can configure this on one router, and all your iBGP routers will then receive the local preference value. The higher the local preference value, the more preferred that path is.

BGP attribute local preference is the second BGP attribute in the BGP path selection list. In this lesson, we’ll configure local preference using both the global command and route-maps, and we’ll verify how it influences BGP path selection.

Key Takeaways

  • Local preference is the second BGP attribute in the path selection process
  • It controls outbound (exit) path selection within your autonomous system
  • Exchanged between iBGP neighbors only—never sent to eBGP peers
  • Default value is 100—higher values are preferred
  • Can be set globally with bgp default local-preference or per-neighbor with route-maps
  • Classified as a well-known discretionary attribute (all BGP routers must recognize it, but it’s optional in updates)

Prerequisites

Before working with local preference, you should understand:

  • Basic BGP configuration and neighbor relationships
  • BGP path selection process
  • How BGP attributes influence routing decisions

Example

Let me show you an example:

bgp local preference example

You can use local preference to configure your autonomous system to select a certain exit point. Instead of configuring weight on each router, you can use local preference because it is exchanged on all internal BGP routers. By increasing the local preference to 800, we can make AS 1 send all traffic toward AS 2.

A well-known discretionary BGP attribute must be recognized by all BGP routers per RFC, but its presence in a BGP update is optional.

Configuration

Now, let me show you how to configure local preference. Here is the topology that we will use:

bgp local preference lab

In the picture above, we have two autonomous systems. R1 will advertise network 1.1.1.0/24 towards AS 2, and R4 will have to choose when it wants to reach this network. It can go through router R2 or R3. We’ll see how local preference influence this. Here’s the default BGP configuration of R1:

R1(config)#interface loopback 0
R1(config-if)#ip address 1.1.1.1 255.255.255.0

R1(config)#router bgp 1
R1(config-router)#neighbor 192.168.12.2 remote-as 2
R1(config-router)#neighbor 192.168.13.3 remote-as 2
R1(config-router)#network 1.1.1.0 mask 255.255.255.0

Let’s configure AS 2 with OSPF:

R2(config)#interface loopback 0
R2(config-if)#ip address 2.2.2.2 255.255.255.0

R2(config)#router ospf 1
R2(config-router)#network 192.168.24.0 0.0.0.255 area 0
R2(config-router)#network 2.2.2.0 0.0.0.255 area 0
R3(config)#interface loopback 0
R3(config-if)#ip address 3.3.3.3 255.255.255.0

R3(config)#router ospf 1
R3(config-router)#network 192.168.34.0 0.0.0.255 area 0
R3(config-router)#network 3.3.3.0 0.0.0.255 area 0
R4(config)#interface loopback 0
R4(config-if)#ip address 4.4.4.4 255.255.255.0

R4(config)#router ospf 1
R4(config-router)#network 192.168.24.0 0.0.0.255 area 0
R4(config-router)#network 192.168.34.0 0.0.0.255 area 0
R4(config-router)#network 4.4.4.0 0.0.0.255 area 0

Now we can configure IBGP within AS 2:

R2(config)#router bgp 2
R2(config-router)#neighbor 192.168.12.1 remote-as 1
R2(config-router)#neighbor 3.3.3.3 remote-as 2
R2(config-router)#neighbor 3.3.3.3 update-source loopback0
R2(config-router)#neighbor 4.4.4.4 remote-as 2
R2(config-router)#neighbor 4.4.4.4 update-source loopback0
R2(config-router)#neighbor 4.4.4.4 next-hop-self
R3(config)#router bgp 2
R3(config-router)#neighbor 192.168.13.1 remote-as 1
R3(config-router)#neighbor 2.2.2.2 remote-as 2
R3(config-router)#neighbor 2.2.2.2 update-source loopback0
R3(config-router)#neighbor 4.4.4.4 remote-as 2
R3(config-router)#neighbor 4.4.4.4 update-source loopback0
R3(config-router)#neighbor 4.4.4.4 next-hop-self
R4(config)#router bgp 2
R4(config-router)#neighbor 2.2.2.2 remote-as 2
R4(config-router)#neighbor 2.2.2.2 update-source loopback 0
R4(config-router)#neighbor 3.3.3.3 remote-as 2
R4(config-router)#neighbor 3.3.3.3 update-source loopback 0

And above, you can see the BGP configurations.

Now let’s find out what path R4 will use to reach network 1.1.1.0/24:

We're Sorry, Full Content Access is for Members Only...

If you like to keep on reading, become a member now!

  • Learn CCNA, CCNP and CCIE R&S. Explained As Simple As Possible.
  • Try for Just $1. The Best Dollar You've Ever Spent on Your Cisco Career!
  • Full Access to our 799 Lessons. More Lessons Added Every Week!
  • Content created by Rene Molenaar (CCIE #41726)
2926 Sign Ups in the last 30 days
satisfaction-guaranteed
  • 100% Satisfaction Guaranteed!
  • You may cancel your monthly membership at any time.
  • No Questions Asked!

Forum Replies

  1. hy, i’m something problem in my network, can you help me.
    example ;

    • added 2 router James
    • added 1 router CE
    • AS 1 and AS 2
    • Local preference : 700
    • routing router CE to router James A and B with OSPF
      how to configur Local preference in router Jim ?
      My topology ;

    router CE ==> router james A & B (AS :1) ======> (AS:2) router Jim & Jon

    Thanks

  2. You can use a route-map like I did above. For example attach it to router Jim on inbound updates and set the local preference there.

  3. i’ve done like route-map like did above, so ping & Lokal preference OK.
    but I am having problems in the CE router, I use OSPF routing.

    router-ce (config)#router ospf 10
    router-ce (config-router)#
    router-ce (config-router)#redistribute connected
    % Only classful networks will be redistributed
    R22(config-router)#
    

    why Only classful networks will be redistributed ?

    thanks

  4. Hi Parwis,

    By default, only classful networks are redistributed when using the “redistribute connected” command. You’ll need to include the “subnets” option if you want classless networks to be also redistributed. The command will be :

    redistribute connected subnets

  5. Hi,

    What would be scenario if i apply

    neighor 192.168.13.1 route-map LOCALPREF out instead of route-map LOCAL PREF in

    Regards,
    Vishal

136 more replies! Ask a question or join the discussion by visiting our Community Forum