How to Configure BGP Local Preference Attribute

This topic is to discuss the following lesson:

1 Like

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

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.

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

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

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

Hi,

Waht ll be the effect if route map applied out direction.

neighbor 192.168.13.1 route-map LOCALPREF out insted of in

Regards,
Vishal

Hi Vishal,

It’s possible to send local preference outbound to another IBGP neighbor. You can’t send it to EBGP neighbors since it’s not included in the BGP updates.

Rene

1 Like

Hi Rene,
I was wondering why you configured OSPF. Is it not enough with internal BGP, adding the local networks to each bgp section in each router ? (Assuming the network topology is as simple as the example).

Hi Diego,

Good question. Technically it is possible to configure this without OSPF, you’d have to advertise the 192.168.24.0/24 and 192.168.34.0/24 networks on router Jack in BGP so that Jim and John can reach each other.

It is a best practice so use an IGP to advertise the prefixes within the autonomous system so that’s why I used OSPF. It’s also a best practice to use loopback interfaces for IBGP (for failover) but that doesn’t apply to this topology since there are no backup links within AS2.

Rene

You can use community strings to set local preference on remote EBGP peers

1 Like

Hi Rene

How do I achieve load balancing in BGP if I have multi homed link.

Hi Pankaj,

BGP normally doesn’t do any load balancing but there are are some workarounds, for example you can try this:

router bgp 1
bgp bestpath as-path multipath-relax
address-family ipv4
maximum-paths 2

This will allow the router to use load balancing even though you have two different AS paths.

Rene

Hi Rene,

Very nice explanations. BTW can you please change the names of routers. Instead of giving Jhon, Jim, James can you please re-write as simple as R1, R2 etc… I’m having difficulty to memorize these names

Thank you

Taslim

Hi Taslim,

I’ll do this sometime, in all my newer lessons I always use R1, R2, SW1, SW2, ASA1, ASA2, etc.

Rene

Hi Rene,

what is the difference between LP And AS Path Prepend? Is configuring LP On one router sufficient enough to complete The PA?

And also you stated in a comment "Hi Vishal,

It’s possible to send local preference outbound to another IBGP neighbor. You can’t send it to EBGP neighbors since it’s not included in the BGP updates"

in your diagram Jacob is sending a LP OF 800 to James who is an EBGP Neighbor? Thanks

Or even Weight?

Hi Adil,

Local preference is used to set the exit point for “your” AS. We use this on one of our routers on the edge of our network and advertise it to our iBGP routers. If you set a higher local preference on one edge router then it will be advertised to your iBGP routers and they will all prefer this exit path since the default local preference from the other router will be 0.

AS Path prepending is typically done from one AS to another AS. We can use this to inform the AS on the other side what path they “should” use to enter our network.

Weight only influences decisions on the local router, it’s not something that is advertised.

The arrow in the picture indicates the exit path that we use because of the higher local preference btw, not the advertisement :slight_smile:

Rene

1 Like

Hi

Thank you for this, what about AS PATH PREPEND VS MED? (sorry for the pester)

Kind Regards

Hi Adil,

Both can be used to inform the neighbor AS which path that they should use. There’s one difference why you might want to choose one over the other. Here’s an example:

Let’s say we have AS1-AS2-AS3. When you use AS path prepending on AS1 then AS2 and AS3 will both see the added AS numbers. When you use MED on AS1 then only AS2 will see it…AS2 will not forward the MED to AS3.

Rene