Routing
Reply
Regular Visitor
nigelwensley
Posts: 5
Registered: ‎09-27-2011
0
Accepted Solution

BGP local-preference doesn't work?

I have a simple eBGP adjacency with 2 peers configured as shown. 

 

bgp {
group ext {
peer-as 65222;
neighbor 172.16.0.14;
neighbor 172.16.0.18 {
local-preference 200;
}
}

 

I want to increase Local Preference for 1 of the peers quickly and easily using the local-preference command documented here: http://www.juniper.net/techpubs/en_US/junos12.1/topics/reference/configuration-statement/local-prefe...

 

The command does not appear to work as documented as you can see Local Pref remains at the default of 100 for both peers:

 

user@r3# run show route aspath-regex 65222

 

200.1.0.0/24 *[BGP/170] 05:30:27, localpref 100
AS path: 65222 I
> to 172.16.0.14 via em2.1

[BGP/170] 00:01:07, localpref 100
AS path: 65222 I
> to 172.16.0.18 via em2.2

 

The local router has neither increased the Local Pref for the received eBGP routes installed in the routing table, nor for those exported to other iBGP peers:

 

user@r3# run show route advertising-protocol bgp 10.0.6.1 aspath-regex 65222


Prefix Nexthop   MED Lclpref AS path
* 200.1.0.0/24 Self 100 65222 I
* 200.1.1.0/24Self 100 65222 I

 

What gives? This is a great easy option instead of creating policy that I would like to use. Rest assured I have tried resetting the adjacencies since the configuration was applied in case the session or rpd needed updating somehow.

Recognized Expert
Mattia
Posts: 198
Registered: ‎03-17-2010
0

Re: BGP local-preference doesn't work?

[ Edited ]

Hi, the local preference is a non transitive attribute, so can't be advertised to an external peer (which belongs to a different AS), therefore your peer sees the route with the default local preference.

You can use the MED attribute to influence how the external peer reaches your networks; note that the MED can traverse 1 AS as a maximum.

.................................................................................
JNCIP-ENT, JNCIP-SEC, JNCIS-SP
(If this post helped you, please mark it as an "Accepted Solution"; kudos are also appreciated!)


Regular Visitor
nigelwensley
Posts: 5
Registered: ‎09-27-2011
0

Re: BGP local-preference doesn't work?

Hello, no that's not correct. Local Preference is transitive. It is a Well Known attribute meaning it must be supported by all BGP implementations, and all Well Known attributes are transitive. Local Preference is not attached to eBGP updates, only to iBGP updates. I am not trying to send Local Preference to the eBGP peer. I believe the command as configured should assign Local Preference 200 to prefixes accepted from the eBGP peer 172.16.0.18 and advertise that higher Local Preference to iBGP peers allowing them to prefer 172.16.0.18 as the exit point from the AS.

Trusted Contributor
acecanal
Posts: 149
Registered: ‎07-05-2011
0

Re: BGP local-preference doesn't work?

[ Edited ]

  

  The local pref works on outgoing direction. You will set local pref to prefix propagated to that neighbor, not to prefix received from that neighbor.

 

  If you want to set local pref to incoming prefix, have to use a import policy.

 

  Look, some output ommited.

 

  I set local pref to 199 on neighbor 10.2.2.2, group RI2.

set routing-instances RI3 protocols bgp group RI2 type internal

 

set routing-instances RI3 protocols bgp group RI2 local-preference 199


set routing-instances RI3 protocols bgp group RI2 local-address 10.3.3.3

 

set routing-instances RI3 protocols bgp group RI2 neighbor 10.2.2.2


set routing-instances RI3 protocols bgp group RI4 type internal
set routing-instances RI3 protocols bgp group RI4 local-address 10.3.3.3

 

set routing-instances RI3 protocols bgp group RI4 neighbor 10.4.4.4

 

 

I learn this from this neighbor, but dont see the local pref.


admin@MX> show route receive-protocol bgp 10.2.2.2
RI3.inet.0: 46 destinations, 57 routes (46 active, 0 holddown, 1 hidden)
  Prefix                  Nexthop              MED     Lclpref    AS path
* 10.2.1.0/24             10.2.2.2                     100        I
* 10.2.3.0/24             10.2.2.2                     100        I
* 10.2.4.0/24             10.2.2.2                     100        I
* 12.12.12.0/24           10.2.2.2                     100        I
  23.23.23.0/24           10.2.2.2                     100        I

 

 

But i propagate this to this neighbor with local pref 199.


admin@MX> show route advertising-protocol bgp 10.3.3.3
RI3.inet.0: 46 destinations, 57 routes (46 active, 0 holddown, 1 hidden)
  Prefix                  Nexthop              MED     Lclpref    AS path
* 10.3.1.0/24             Self                         199        I
* 10.3.2.0/24             Self                         199        I
* 10.3.3.0/24             Self                         199        I
* 10.3.4.0/24             Self                         199        I
* 10.4.1.0/24             10.4.4.4                     199        I
* 10.4.2.0/24             10.4.4.4                     199        I
* 10.4.3.0/24             10.4.4.4                     199        I
* 10.4.4.0/24             10.4.4.4                     199        I
* 23.23.23.0/24           Self                         199        I
* 34.34.34.0/24           Self                         199        I

 

 

 

And what this neighbor receives have local pref 199.


admin@MX> show route receive-protocol bgp 10.3.3.3

RI2.inet.0: 49 destinations, 66 routes (49 active, 0 holddown, 0 hidden)
  Prefix                  Nexthop              MED     Lclpref    AS path
* 10.3.1.0/24             10.3.3.3                     199        I
* 10.3.2.0/24             10.3.3.3                     199        I
* 10.3.3.0/24             10.3.3.3                     199        I
* 10.3.4.0/24             10.3.3.3                     199        I
* 10.4.1.0/24             10.4.4.4                     199        I
* 10.4.2.0/24             10.4.4.4                     199        I
* 10.4.3.0/24             10.4.4.4                     199        I
* 10.4.4.0/24             10.4.4.4                     199        I
  23.23.23.0/24           10.3.3.3                     199        I
* 34.34.34.0/24           10.3.3.3                     199        I

 

 

 But on the second group RI4 i dont see any local pref.


RI4.inet.0: 52 destinations, 62 routes (52 active, 0 holddown, 0 hidden)
  Prefix                  Nexthop              MED     Lclpref    AS path
* 10.2.1.0/24             10.2.2.2                     100        I
* 10.2.3.0/24             10.2.2.2                     100        I
* 10.2.4.0/24             10.2.2.2                     100        I
* 10.3.1.0/24             10.3.3.3                     100        I
* 10.3.2.0/24             10.3.3.3                     100        I
* 10.3.3.0/24             10.3.3.3                     100        I
* 10.3.4.0/24             10.3.3.3                     100        I
* 12.12.12.0/24           10.2.2.2                     100        I
* 23.23.23.0/24           10.3.3.3                     100        I
  34.34.34.0/24           10.3.3.3                     100        I

 

 

This is the import policy that will set local pref, and metric to incoming prefixes, from R3 to R4, and from R4 to R3. R3 have ip address 34.34.34.3, and R4 34.34.34.4.


set policy-options policy-statement Set-Pref from protocol bgp

set policy-options policy-statement Set-Pref then metric 777
set policy-options policy-statement Set-Pref then local-preference 177
set policy-options policy-statement Set-Pref then accept

 

set routing-instances RI3 protocols bgp group RI4 import Set-Pref

 

set routing-instances RI4 protocols bgp group RI3 import Set-Pref

 

 

RI3.inet.0: 46 destinations, 57 routes (46 active, 0 holddown, 1 hidden)
+ = Active Route, - = Last Active, * = Both

A Destination        P Prf   Metric 1   Metric 2  Next hop        AS path

  10.4.1.0/24        B 200        177        777 >34.34.34.4      I
  10.4.2.0/24        B 200        177        777 >34.34.34.4      I
  10.4.3.0/24        B 200        177        777 >34.34.34.4      I
  10.4.4.0/24        B 200        177        777 >34.34.34.4      I

  34.34.34.0/24      B 200        177        777 >34.34.34.4      I

 

 

 

RI4.inet.0: 52 destinations, 62 routes (52 active, 0 holddown, 0 hidden)
+ = Active Route, - = Last Active, * = Both

A Destination        P Prf   Metric 1   Metric 2  Next hop        AS path
  10.2.1.0/24        B 200        177        777 >34.34.34.3      I
  10.2.3.0/24        B 200        177        777 >34.34.34.3      I
  10.2.4.0/24        B 200        177        777 >34.34.34.3      I
  10.3.1.0/24        B 200        177        777 >34.34.34.3      I
  10.3.2.0/24        B 200        177        777 >34.34.34.3      I
  10.3.3.0/24        B 200        177        777 >34.34.34.3      I
  10.3.4.0/24        B 200        177        777 >34.34.34.3      I
  12.12.12.0/24      B 200        177        777 >34.34.34.3      I
  23.23.23.0/24      B 200        177        777 >34.34.34.3      I
  34.34.34.0/24      B 200        177        777 >34.34.34.3      I

 

Br
Alex

~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~

If you want to say thanks, the word is Kudos!!.

Thx.

~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~

JNCIA-JUNOS, JNCIS-ENT, JNCIS-SP, JNCIP-SP.
CCNA, CCNP, Written CCIE.
Copyright© 1999-2013 Juniper Networks, Inc. All rights reserved.