Routing

Expand all | Collapse all

BGP local preference configuration questions

Jump to Best Answer
  • 1.  BGP local preference configuration questions

    Posted 6 days ago
    I have one router which is connected to two remote routers in different AS,  I  configured local-preference for one of the peers to try to select that path as follows, but it does not result as I expected.
    root@RP3# run show route 192.68.145.1

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

    192.68.145.0/24 *[BGP/170] 00:00:31, MED 2, localpref 100
    AS path: 64513 I, validation-state: unverified
    > to 172.16.23.2 via ge-0/0/3.0
    [BGP/170] 00:50:01, localpref 100
    AS path: 64511 64513 I, validation-state: unverified
    > to 172.16.13.129 via ge-0/0/2.0

    [edit]
    root@RP3# show protocols bgp | display set
    set protocols bgp group eBGP type external
    set protocols bgp group eBGP export exp2BGP
    set protocols bgp group eBGP neighbor 172.16.23.2 peer-as 64513
    set protocols bgp group eBGP neighbor 172.16.13.129 local-preference 150
    set protocols bgp group eBGP neighbor 172.16.13.129 peer-as 64511

    I like to select the path via 172.16.13.129, but it still selects 172.16.23.2, not know why.  From the output the local preference is not changed.

    But in the following output, it seems changed.

    root@RP3# run show bgp neighbor
    Peer: 172.16.13.129+29745 AS 64511 Local: 172.16.13.130+179 AS 64512
    Type: External State: Established Flags: <Sync>
    Last State: OpenConfirm Last Event: RecvKeepAlive
    Last Error: Cease
    Export: [ exp2BGP ]
    Options: <Preference Localpref PeerAS Refresh>
    Holdtime: 90 Preference: 170 Localpref: 150
    Number of flaps: 1
    Last flap event: Stop
    Error: 'Cease' Sent: 1 Recv: 0
    Peer ID: 172.16.13.129 Local ID: 33.33.33.33 Active Holdtime: 90
    Keepalive Interval: 30 Group index: 1 Peer index: 0
    BFD: disabled, down
    Local Interface: ge-0/0/2.0
    NLRI for restart configured on peer: inet-unicast
    NLRI advertised by peer: inet-unicast
    NLRI for this session: inet-unicast
    Peer supports Refresh capability (2)
    Stale routes from peer are kept for: 300
    Peer does not support Restarter functionality
    Peer does not support Receiver functionality
    Peer supports 4 byte AS extension (peer-as 64511)
    Peer does not support Addpath
    Table inet.0 Bit: 10000
    RIB State: BGP restart is complete
    Send state: in sync
    Active prefixes: 0
    Received prefixes: 15
    Accepted prefixes: 15
    Suppressed due to damping: 0
    Advertised prefixes: 25
    Last traffic (seconds): Received 6 Sent 4 Checked 2
    Input messages: Total 134 Updates 11 Refreshes 0 Octets 2970
    Output messages: Total 136 Updates 8 Refreshes 0 Octets 3058
    Output Queue[0]: 0

    Any insights ?


    thanks in advance !!




  • 2.  RE: BGP local preference configuration questions

    Posted 6 days ago
    set protocols bgp group eBGP neighbor 172.16.13.129 local-preference 150

    This configuration will set local-preference to all routes when they will be advertised to 172.16.13.129

    In your case you can apply input policy to peer 172.16.13.129 and set local-preference 150 


    ------------------------------
    Anatoliy
    ------------------------------



  • 3.  RE: BGP local preference configuration questions

    Posted 6 days ago
    thanks a lot !!


  • 4.  RE: BGP local preference configuration questions

    Posted 6 days ago

    Hello, 

    try to use an import policy for that BGP neighbor instead of local-pref statement in the neighbor config. 

    set policy-options policy-statement XXX from protocol bgp
    set policy-options policy-statement XXX then local-preference 222
    set policy-options policy-statement XXX then accept

    set protocols bgp group name neighbor YYYY import XXX
    set protocols bgp group name neighbor YYYY peer-as ZZZZ

    It should solve your problem.



    ------------------------------
    Michal Skorczewski
    ------------------------------



  • 5.  RE: BGP local preference configuration questions

    Posted 6 days ago
    thanks a lot !!



  • 6.  RE: BGP local preference configuration questions
    Best Answer

     
    Posted 4 days ago
    When you use the local-preference command for a neighbor, that configures the router to set the local preference value of the routes advertised to that neighbor, to the value that you specified.   You want to set the local-preference of the received routes, so like some one else suggested you need to use an import policy. 

    Also,  keep in mind that local-preference is only advertised to IBGP peers. Thus, in your scenario, the command is really doing nothing as your neighbor 172.16.13.129 is EBGP.   If it was IBGP, you could configure this command on the neighbor, which will make it send the routes to you with local-preference 150, and your router would select the routes. 

    Regards, 



    ------------------------------
    Yasmin Lara
    Juniper Ambassador
    JNCIE-SP, JNCIE-ENT, JNCIE-DC, JNCIE-SEC
    JNCDS-DC, JNCIA-DevOps, JNCIP-CLOUD, CCNP-ENT
    ------------------------------



  • 7.  RE: BGP local preference configuration questions

    Posted 4 days ago
    thanks so much !   You have so many shining JNCIEs !!


  • 8.  RE: BGP local preference configuration questions

    Posted 4 days ago

    As Yasmin mentioned, Local Pref is purely for influencing *your AS* on how it routes out towards other neighboring AS's.  So as she mentioned, Local Pref config on an I-BGP speaker feeds back into your local I-BGP domain, what it would like other local AS routers to do.

    MED (multi-exit discriminator) would be how you would influence a remote AS on how you would like it to route back towards you, but, only if you are dual homed to the *same* remote AS

    You will need to use other BGP knobs to accomplish your intended inbound influencing towards your dual homed / different remote AS's... like BGP path-prepending, or cutting prefixes into smaller pieces to have basic longest match ipv4 routing rule kick in.



    ------------------------------
    Aaron Gould
    Sr Net Eng
    aaron@gvtc.com
    https://www.linkedin.com/in/agould123/
    ------------------------------



  • 9.  RE: BGP local preference configuration questions

    Posted 4 days ago
    thanks so much !!   Glad to have so many nice people here to offer great assistance.


  • 10.  RE: BGP local preference configuration questions

    Posted 4 days ago
    Hi,

    Just to add to whats already been said - I think it's also well worth taking a look at the steps BGP takes when doing path selection as to what is preferred over what if you haven't already done this - since it will assist you moving forward.

    I'd strongly suggest taking a look at https://www.juniper.net/documentation/en_US/junos/topics/reference/general/routing-protocols-address-representation.html for information on this topic.


    ------------------------------
    Andrew Alston
    Juniper Ambassador
    Linkedin: andrew-alston
    Twitter: @AndrewLiquid
    ------------------------------