cancel
Showing results for 
Search instead for 
Did you mean: 
cancel
2846
Views
25
Helpful
8
Replies

BGP path manipulation using local preference

Ravi Pande
Level 1
Level 1

Hello,
I was reading Jeff Doyle's book Routing TCP/IP vol2 and was studying BGP path manipulation. In the book also it was mentioned about the below observed behavior.However, I was unable to understand it fully.Hence,I am testing on GNS3 and see if anyone could explain why prefixes from certain neighbor doesn't show up after adding local preference.

topology.png

I am using a route-map on R3 which is in AS 30 and that route-map is adding local preference to all the prefixes received from R4(AS100) & R5(AS200). I am seeeing some strange behavior after adding the route-map.

R1's bgp table before adding local preference:

r3beforeLP.PNG

Prefixes are received from 2.2.2.2,4.4.4.4 and 5.5.5.5

Now,if I add local preference of 500 to all the prefixes received from R4 & R5 the bgp table shows route only from 4.4.4.4 & 5.5.5.5 neighbor. prefixes from 2.2.2.2 gets disappeared. Why is that?

R3's routing table after adding local preference to all prefixes received from R4 & R5.

R3afterLP.PNG

 

Next, router R1 in AS 30 before adding sees the prefixes from both ibgp neighbors R2 & R3 in AS 30. See the bgp table before adding the local preference.

R1bforeLP.PNG

Now, after adding local preference on R3 the bgp table changes on R1 as well and I see routes only from R3.

R1afterLP.PNG

Could anyone explain please why is this behavior happening i.e. prefixes from R2 dont seem to be present in BGP table?

Thanks in advance.

Ravi

2 Accepted Solutions

Accepted Solutions


First, bgp router selects one best route (from multiple equals) and sends it over to others. 2. There is also a rule that routes learned via iBGP are not pass over to other iBGPs (except RRs).

you do have full mesh in as 30 and local preference is local only. Both R1 and R2 get value 500 from R3. R2 must prefer those routes via R3.

to see what is sent over to neighbors, use sh ip bgp neig x x x  advertise-routes

other way around is sh ip bgp neig x routes (to see what routes came in)

View solution in original post

Giuseppe Larosa
Hall of Fame
Hall of Fame

Hello Ravi,

>> Now,if I add local preference of 500 to all the prefixes received from R4 & R5 the bgp table shows route only from 4.4.4.4 & 5.5.5.5 neighbor. prefixes from 2.2.2.2 gets disappeared. Why is that?

 

>> Could anyone explain please why is this behavior happening i.e. prefixes from R2 dont seem to be present in BGP table?

This lab helps you and everyone to understand the difference between:

BGP weight a non BGP attribute that has effects only on local router and it is  not sent to other routers

and

BGP local preference that is a BGP attribute and it is sent to all iBGP neighbors.

 

As noted by cisc0.ameer and by Martin your configurations settings on R3 on AS30 have effects that are not limited to R3 router but they are propagated to all routers in AS 30 BGP domain for the scope of local preference attribute.

As soon as R3 rises the local preference on routes learned by 4.4.4.4 and 5.5.5.5 to 500 from default value of 100 the following happens:

R3 choices the paths with local preference 500 as best path for all prefixes received by neighbors 4.4.4.4 and 5.5.5.5 and allowed (= permitted by acl 2 invoked inside the route-map).

R3 sends iBGP advertisements to R2 2.2.2.2 neighbor with new attributes including Loc Pref 500.

R2 receives the new updates from R3 sees the highest local preference value and:

a) install iBGP advertisements coming from R3 as best paths to destinations because the Local preference higher value is preferred

b) R2 stops to send its own advertisemts to R3, because now best paths are via R3. Technically R2 sends out an update with a withdraw section for all prefixes that are now best path via R3.

c) As a result of this on R3 you don't see anymore prefixes coming from R2 2.2.2.2.

 

To be noted if R3 had rised the weight instead of local-preference all effects would have been local to R3 with R3 installing best paths to 4.4.4.4 and 5.5.5.5 and R2 still sending its iBGP advertisements as no change would be seen on other routers in AS 30 when using weight.

For this reason this lab is useful to understand that when we change local-preference we are actually influencing the best path choice not only on the local router R3 but on all routers that belong to local AS 30.

This is exactly the purpose of BGP local-preference attribute and what you see is normal and expected as BGP local-preference has effects on all routers in the local BGP AS 30.

 

Hope to help

Giuseppe

 

View solution in original post

8 Replies 8

Martin L
VIP
VIP

can we see route-map and prefix list configs on r3 as well as part of R3's bgp section with neighbor x.x.x rotue -map out

R3#sh run | s bgp
router bgp 30
no synchronization
bgp log-neighbor-changes
neighbor 1.1.1.1 remote-as 30
neighbor 1.1.1.1 update-source Loopback0
neighbor 1.1.1.1 next-hop-self
neighbor 2.2.2.2 remote-as 30
neighbor 2.2.2.2 update-source Loopback0
neighbor 2.2.2.2 next-hop-self
neighbor 4.4.4.4 remote-as 100
neighbor 4.4.4.4 ebgp-multihop 255
neighbor 4.4.4.4 update-source Loopback0
neighbor 5.5.5.5 remote-as 200
neighbor 5.5.5.5 ebgp-multihop 255
neighbor 5.5.5.5 update-source Loopback0
no auto-summary

->R3#sh route-map
route-map localpref, permit, sequence 10
Match clauses:
ip address (access-lists): 2
Set clauses:
local-preference 500
Policy routing matches: 0 packets, 0 bytes
route-map localpref, permit, sequence 20
Match clauses:
Set clauses:
Policy routing matches: 0 packets, 0 bytes

R3(config-router)#neighbor 4.4.4.4 route-map localpref in
R3(config-router)#neighbor 5.5.5.5 route-map localpref in


First, bgp router selects one best route (from multiple equals) and sends it over to others. 2. There is also a rule that routes learned via iBGP are not pass over to other iBGPs (except RRs).

you do have full mesh in as 30 and local preference is local only. Both R1 and R2 get value 500 from R3. R2 must prefer those routes via R3.

to see what is sent over to neighbors, use sh ip bgp neig x x x  advertise-routes

other way around is sh ip bgp neig x routes (to see what routes came in)

Hello

i'm not sure what exactly purpose Ravi Pande considered to asked question

but as he used Local Preference and his question was why after applying Inbound Route-map contain Local preference values other that default :

bgp table of R1 Does not show R2 paths ... i understand upto here

You answered :

First, bgp router selects one best route (from multiple equals) and sends it over to others. 2. There is also a rule that routes learned via iBGP are not pass over to other iBGPs (except RRs).

So you mean without(before) applying any BGP attribute : here LP cause affect to all BGP routers in that AS(30) :

before use any attribute multiple path (multiple equals) will shown but as we applied attribute like LP which applied INBOUND but affect is OUTBOUND (egress point)

because of using attribute JUST Best path will be shown ? did i understand correctly ?

and second :

you do have full mesh in as 30 and local preference is local only. 

did you mean by Local Only meant for OWN AS Locally only because LP is attribute affect to all BGP Router in his AS

 

but i think if we take a output of : show ip bgp 1.1.1.1/32

it shows 2 Paths but best one is via R3

 

thanks


yes, I meant Local AS only, not as local router only. I made correction.
Yes, LP 500 is propagated to all routers in same local AS by R3, R2 will go via R3 even thou it gets external bgp routes from eBGP neighbors.
I don't think R2 sends all those routes with LP 500 to R1 because of ibgp loop-prevention measure (rule).

thanks and regards

Giuseppe Larosa
Hall of Fame
Hall of Fame

Hello Ravi,

>> Now,if I add local preference of 500 to all the prefixes received from R4 & R5 the bgp table shows route only from 4.4.4.4 & 5.5.5.5 neighbor. prefixes from 2.2.2.2 gets disappeared. Why is that?

 

>> Could anyone explain please why is this behavior happening i.e. prefixes from R2 dont seem to be present in BGP table?

This lab helps you and everyone to understand the difference between:

BGP weight a non BGP attribute that has effects only on local router and it is  not sent to other routers

and

BGP local preference that is a BGP attribute and it is sent to all iBGP neighbors.

 

As noted by cisc0.ameer and by Martin your configurations settings on R3 on AS30 have effects that are not limited to R3 router but they are propagated to all routers in AS 30 BGP domain for the scope of local preference attribute.

As soon as R3 rises the local preference on routes learned by 4.4.4.4 and 5.5.5.5 to 500 from default value of 100 the following happens:

R3 choices the paths with local preference 500 as best path for all prefixes received by neighbors 4.4.4.4 and 5.5.5.5 and allowed (= permitted by acl 2 invoked inside the route-map).

R3 sends iBGP advertisements to R2 2.2.2.2 neighbor with new attributes including Loc Pref 500.

R2 receives the new updates from R3 sees the highest local preference value and:

a) install iBGP advertisements coming from R3 as best paths to destinations because the Local preference higher value is preferred

b) R2 stops to send its own advertisemts to R3, because now best paths are via R3. Technically R2 sends out an update with a withdraw section for all prefixes that are now best path via R3.

c) As a result of this on R3 you don't see anymore prefixes coming from R2 2.2.2.2.

 

To be noted if R3 had rised the weight instead of local-preference all effects would have been local to R3 with R3 installing best paths to 4.4.4.4 and 5.5.5.5 and R2 still sending its iBGP advertisements as no change would be seen on other routers in AS 30 when using weight.

For this reason this lab is useful to understand that when we change local-preference we are actually influencing the best path choice not only on the local router R3 but on all routers that belong to local AS 30.

This is exactly the purpose of BGP local-preference attribute and what you see is normal and expected as BGP local-preference has effects on all routers in the local BGP AS 30.

 

Hope to help

Giuseppe

 

Getting Started

Find answers to your questions by entering keywords or phrases in the Search bar above. New here? Use these resources to familiarize yourself with the community: