How to Configure BGP Local Preference Attribute

@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

1 Like

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

Thank you

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

Internal BGP Explained

Rene

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 1.0.0.1/24
AS2: R2,R3,R4 --> IBGP fully meshed using loopbacks plus OSPF area O as IGP
–> R4 is advertising 192.168.1.1/24

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:

Regards,
Salvatore.

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 4.4.4.4
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       192.168.12.1             0    100      0 1 i
*>i                 2.2.2.2                  0    100      0 1 i
* i                 3.3.3.3                  0    100      0 1 i
* i                 192.168.13.1             0    10

-

Jim#
Jonn:
no synchronization
 bgp log-neighbor-changes
 neighbor 2.2.2.2 remote-as 2
 neighbor 2.2.2.2 update-source Loopback0
 neighbor 4.4.4.4 remote-as 2
 neighbor 4.4.4.4 update-source Loopback0
 neighbor 4.4.4.4 next-hop-self
 neighbor 192.168.13.1 remote-as 1
 neighbor 192.168.13.1 route-map LOCAL in
 neighbor 192.168.34.4 remote-as 2
 no auto-summary

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

@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, 2.0.0.1/32, 3.0.0.1/32 and 4.0.0.1/32.

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

Hi Rene

Will you be doing lessons on 6PE and 6VPE
Thanks

Inderpal

Hi Inderpal,

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

Rene

Hi,

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

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

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

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

Thank you in advance.

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

Thank you.

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

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!

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

Hi Ax,

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

Rene

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.

Thanks!

Jesse,
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.”

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.

Thanks

Shawn,
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:

1 Like

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

Hi Rene,

Is there any lesson on Route-map?

Thanks