How to Configure BGP Local Preference Attribute

(David M) #21

@adil I know your reply is older but I feel like I understand it enough to give it an explanation myself.

Different between Local Path and AS Path prepend is:

Local Preference- is used to influence which pathway is used (internally) when there are multiple connections to the ISP. This option is not sent in the update to the eBGP neighbor.
-if you take another look at the example it shows the LP for Jack which is behind both edge iBGP routers. Router Jack will choose the Highest value Local Preference as the best pathway to reach the ISP. The ISP (eBGP router) does not see this preference.
The reason why you set the route-map for local pref inbound because you can influence the local preference value internally. This value is not included in the update to the eBGP peer.

Yes configuring LP on one of the iBGP routers should be enough as long as the local preference is set higher then the default of 0.

AS_Path Prepend- is also used when there are multiple connections to the ISP. It sets “fake” mutiple AS path hops on one router making it appear as if its much further then the other iBGP peer. From the ISP (eBGP) perspective it thinks the one with the higher hop count is further away so it sends traffic to the other iBGP router. All AS_Path prepend updates are sent to the ISP (eBGP router)

The reason why you set the route-map for as_path outbound because you are letting the eBGP neighbor about the prepended value

(vijitharan v) #22

You don’t have any direct connection with Jim to John then why are you using the neighbor command between them?

Thank you

(Rene Molenaar) #23

iBGP requires a full-mesh of neighbor adjacencies. Take a look here:

Internal BGP Explained


(Salvatore C) #24

Ciao Rene’,

I hope you are doing well

I’m making a simulation to check the BGP Local Preference behavior, attached you can find the topology diagram

As you can see I configured two Autonomous Systems:

AS1: R1 --> Advertised prefix
AS2: R2,R3,R4 --> IBGP fully meshed using loopbacks plus OSPF area O as IGP
–> R4 is advertising

pinging with source address is working fine, but of course AS1 doesn’t know anything about AS2 IGP configuration which means that “standard pinging” won’t work

now, my question is: how does it work in real life? is there like a best practice to make AS1 aware about AS2 internal routing?

Thanks in advance for your answer :wink:


(William R) #25

I don’t see any changes in Local-p on my routes. What am I doing wrong?

Jack#show ip bgp
BGP table version is 2, local router ID is
Status codes: s suppressed, d damped, h history, * valid, > best, i - internal,
              r RIB-failure, S Stale, m multipath, b backup-path, x best-external, f RT-Filter
Origin codes: i - IGP, e - EGP, ? - incomplete

   Network          Next Hop            Metric LocPrf Weight Path
* i1.1.1.0/24             0    100      0 1 i
*>i                         0    100      0 1 i
* i                         0    100      0 1 i
* i                    0    10


no synchronization
 bgp log-neighbor-changes
 neighbor remote-as 2
 neighbor update-source Loopback0
 neighbor remote-as 2
 neighbor update-source Loopback0
 neighbor next-hop-self
 neighbor remote-as 1
 neighbor route-map LOCAL in
 neighbor remote-as 2
 no auto-summary

  Network          Next Hop            Metric LocPrf Weight Path
* i1.1.1.0/24             0    100      0 1 i
*>                     0             0 1 i

(Rene Molenaar) #26

@Salvatore it depends :slight_smile: It’s possible that the ISP has one “block” of public IP space that is used for IP addresses on their routers and to assign to customers. In that case, you probably advertise the entire block in BGP. It’s also possible to only advertise the customer address space. That could be the subnets behind your routers…in your case,, and

@William what prefixes did you learn from and what does the route-map look like?

(Inderpal K) #27

Hi Rene

Will you be doing lessons on 6PE and 6VPE


(Rene Molenaar) #28

Hi Inderpal,

I probably will once I work on the DC/SP material.


(LER-SAK P) #29


Could you please explain.
I try to configure “neighbor next-hop-self” at R3 so R2 know next-hop for prefix Why does R2 still not use with 100 locPrf as next-hop ?

R2#sh ip bgp | b Ne
   Network          Next Hop            Metric LocPrf Weight Path
* i1.1.1.0/24                  0    100      0 1 i
*>                     0             0 1 i
*>i50.50.50.0/24                  0    100      0 i

When I configured “bgp default local-preference 101” at R3.
Now. R2 use as Next-hop

R2#sh ip bgp | b Ne
   Network          Next Hop            Metric LocPrf Weight Path
*>i1.1.1.0/24                  0    101      0 1 i
*                      0             0 1 i
*>i50.50.50.0/24                  0    100      0 i

Thank you in advance.

(LER-SAK P) #30

Hi Rene,
I now know, because the external path. Am I right?

Thank you.

(ax v) #31

If router James were to be advertising two networks, instead of one, will the route-map we applied to John router need to include another permit statement to allow that network to be advertised through John? ex. John(config)# route-map LOCALPREF permit 20

(ax v) #32

I actually did it myself and now I understand this last statement you wrote about route-maps.

<blockquote>Route-maps are a more flexible solution. If you don’t use a match statement in a route-map then everything is matched by default. </blockquote>

Great guides. Love it!

(Rene Molenaar) #33

Hi Ler-Sak,

If all BGP attributes are the same then your router will select the path with the lowest router ID. However, if you have an IBGP and EBGP path then it will prefer the EBGP path.


(Rene Molenaar) #34

Hi Ax,

That’s right. Good to hear you figured it out.


(Jesse L) #35

Hi Rene,

When using the route-map to influence local-preference, I noticed it didn’t take affect until I did ‘clear ip bgp *soft’ on router James. Does BGP always need to be cleared in this case? I did not have to do this when using ‘bgp default …’

My configurations are the same as yours using GNS3.


(Andrew P) #36

For the most part, yes, a route needs to be refreshed for attributes to be applied for it–at least within any reasonable period of time. As you probably know BGP is very slow to converge (in fact the argument can be made that it never actually converges).

Just be very careful about “clear ip bgp *” in a production environment. The long standing joke with that command is that it is a “resume generating event.”

(Shawn O) #37

Hi Rene,

I enjoyed this lesson. I have a quick question about route-maps and how to know when to apply them in or out and attach them to which neighbor. Is there a rule of thumb when route-maps are used in this fashion? I just wanted to wrap my head around this.


(Andrew P) #38

Make sure you are thinking about it from the perspective of the router you are working on. If things get really desperate, hold you arm out as a representation of the link between your body (the router) and the neighbor (at the end of your arm). As traffic is leaving you towards your neighbor, and you are wanting to effect a change on what is leaving you, you need a route-map in the outbound direction. Likewise, if you are receiving traffic down your “arm” from your neighbor, and you want to effect a change on that, you need a route-map set to inbound. In short, be the router! :slight_smile:

(Networklessons Admin) split this topic #39

19 posts were merged into an existing topic: How to Configure BGP Local Preference Attribute

(bhargavi s) #40

Hi Rene,

Is there any lesson on Route-map?