Routing

Expand all | Collapse all

Adding a BGP community to prefixes for export to OSPF and iBGP peers

Jump to Best Answer
  • 1.  Adding a BGP community to prefixes for export to OSPF and iBGP peers

    Posted 03-12-2018 16:23

    Hi,

     

    We plan on eBGP peering with an ISP over two links. One of those links (ispA) will be dedicated to RFC1918 address space and the second link (ispB) will be dedicated to public prefixes. Our ISP does not use communities, so we are hoping to add communities to prefixes learned from our ISP for two reasons:

    1. To add a local preference to any prefixes advertised to iBGp peers

    2. In order to export the prefixes learned orm our eBGP to our OSPf routing table

     

    We are using mx80s as our border router. As a quick example our topology will look someithing like this:

    ___________     eBGP      __________       iBGP      __________

    | R10 AS1234  | <---------> | R1 AS100  |  ---------- | R3 AS100  |

    ------------------                    ------------------                   -----------------

                                                       | OSPF area 0

                                                    ---------- |--------------|

                                                                   | R2 AS100 |

                                                                    ----------------

    And the configuration of that border router (R1) will look something liek this. 

    !!! R1 !!!

    !

    !!! Set the communities we would like to assign a community to private (ispA) and public (ispB) prefixes learned from AS1234 !!!

    set policy-options community ispA members 1234:1

    set policy-options community ispB members 1234:2

    !

    set policy-options policy-statement set-community-isp-a term 1 from as-path 1234

    set policy-options policy-statement set-community-isp-a term 1 then community add ispA

    set policy-options policy-statement set-community-isp-a term 1 then accept

    !

    set policy-options policy-statement set-community-isp-b term 1 from as-path 1234

    set policy-options policy-statement set-community-isp-b term 1 then community add ispB

    set policy-options policy-statement set-community-isp-b term 1 then accept

    !

    !!! RFC1918 prefixes which we will advertise to ispA !!!

    set policy-options prefix-list AS100_private_prefixes 10.1.0.0/16

    set policy-options prefix-list AS100_private_prefixes 10.2.0.0/16

    !

    !!! Public prefixes which we will advertise to ispB !!!

    set policy-options prefix-list AS100_public_prefixes 255.255.1.0/24

    !

    !!! Accept any prefix from our ISP aside from our own (originated from AS100) and add the appropriate community !!!

    set policy-options policy-statement import-from-ispB from protocol bgp

    set policy-options policy-statement import-from-ispA term reject-routes from prefix-list AS100_private_prefixes

    set policy-options policy-statement import-from-ispA term reject-routes then reject

    !!! Add the community for export to OSPF !!!

    set policy-options policy-statement import-from-ispA term all_else from as-path 1234

    set policy-options policy-statement import-from-ispA term all_else then community add ispA 

    set policy-options policy-statement import-from-ispA term all_else then accept

    !

    set policy-options policy-statement import-from-ispB from protocol bgp

    set policy-options policy-statement import-from-ispB term reject-routes from prefix-list AS100_public_prefixes

    set policy-options policy-statement import-from-ispB term reject-routes then reject

    !!! Add the community for export to OSPF !!!

    set policy-options policy-statement import-from-ispB term all_else from as-path 1234

    set policy-options policy-statement import-from-ispB term all_else then community add ispB

    set policy-options policy-statement import-from-ispB term all_else then accept

    !

    !!! Add OSPF local preference when advertising eBGP peer routes to iBGP peers !!!

    !!! set the local preference to 50 when advertised to iBGP peers !!!

    set policy-options policy-statement set-local-pref term 1 from as-path 1234

    set policy-options policy-statement set-local-pref term 1 then  local-preference add 50

    set policy-options policy-statement set-local-pref term 1 then accept

     

     

    !

    set policy-options policy-statement export-to-ispA term get-routes from prefix-list AS100_private_prefixes

    set policy-options policy-statement export-to-ispA term get-routes then accept

    set policy-options policy-statement export-to-ispA term others then reject

    !

    set policy-options policy-statement export-to-ispA term get-routes from prefix-list AS100_public_prefixes

    set policy-options policy-statement export-to-ispA term get-routes then accept

    set policy-options policy-statement export-to-ispA term others then reject

    !

    !

    !!! eBGP peering with our ISP !!!

    set protocols bgp group ispA type external

    set protocols bgp group ispA import import-from-ispA

    set protocols bgp group ispA export export-to-ispA

    set protocols bgp group ispA peer-as 1234

    set protocols bgp group ispA neighbor 10.0.0.1

    !

    set protocols bgp group ispB type external

    set protocols bgp group ispB import import-from-ispB

    set protocols bgp group ispB export export-to-ispB

    set protocols bgp group ispB peer-as 1234

    set protocols bgp group ispB neighbor 10.0.0.3

    !

    !!! iBGP peer !!!

    !

    set protocols bgp group AS100 type internal

    set protocols bgp group AS100 export set-local-pref

    set protocols bgp group AS100 neighbor 192.168.1.2

    !

    !!! Export all prefixes learned from ISP A and ISP B to OSPF !!!

    set policy-options policy-statement bgp-to-ospf term 1 from protocol bgp

    set policy-options policy-statement bgp-to-ospf term 1 from community ispA

    set policy-options policy-statement bgp-to-ospf term 1 from community ispB

    set policy-options policy-statement bgp-to-ospf term 1 then accept

    set protocols ospf export bgp-to-ospf

    !

     

    Do the iports and exports make sense in their current format?



  • 2.  RE: Adding a BGP community to prefixes for export to OSPF and iBGP peers

    Posted 03-12-2018 22:05

    Hi Ottimo,

     

    Please find the observations from your configuration provided for your design

     

    set policy-options policy-statement import-from-ispB from protocol bgp == > import-from-ispA instead of import-from-ispB

    set policy-options policy-statement import-from-ispA term reject-routes from prefix-list AS100_private_prefixes

    set policy-options policy-statement import-from-ispA term reject-routes then reject


    !!! Add the community for export to OSPF !!!

    set policy-options policy-statement import-from-ispA term all_else from as-path 1234

    set policy-options policy-statement import-from-ispA term all_else then community add ispA

    set policy-options policy-statement import-from-ispA term all_else then accept


    Change the policy name export-to-ispB :

    set policy-options policy-statement export-to-ispA term get-routes from prefix-list AS100_public_prefixes

    set policy-options policy-statement export-to-ispA term get-routes then accept

    set policy-options policy-statement export-to-ispA term others then reject


    This doesnot make any change because Local preference is local to the AS you cannot set and advertise LP.
    MED you can change and advertise


    !!! set the local preference to 50 when advertised to iBGP peers !!!

    set policy-options policy-statement set-local-pref term 1 from as-path 1234

    set policy-options policy-statement set-local-pref term 1 then local-preference add 50

    set policy-options policy-statement set-local-pref term 1 then accept

     

    Like Below:

    set policy-options policy-statement set-local-pref term 1 then metric <>


    Hope this helps
    --------------------------------------------------------------------------------------------------------
    If this post was helpful, please mark this post as an "Accepted Solution".
    Kudos are always appreciated!
    --------------------------------------------------------------------------------------------------------



  • 3.  RE: Adding a BGP community to prefixes for export to OSPF and iBGP peers

    Posted 03-13-2018 09:55

    Hi vvadivel,

     

    Thanks very much for the detail ed reply. Of course... that was stupid of me to apply the local preference outbound towards the iBGP peer.  I can apply a local preference to any prefix learned FROm that peer, as I will need to perform a similar action on the peer router. The configuration will look like the following:

    set protocols bgp group AS100 type internal

    set protocols bgp group AS100 local-preference 50

    set protocols bgp group AS100 neighbor 192.168.1.2

     

    I really need to invest soe time in a lab, but for now, does the following configuration look like it will achieve the key tasks of:

    1. setting the communities (community ispA and community ispB)

    2. accepting any prefix asdie form our own from eeBGP peers (prefix-list AS100_private_prefixes)

    3. export our prefixes to our eBGP peers (export-to-ispA andexport-to-ispB)

    4. export prefixes learned form eBGP peers to our OSPF process ( policy-statement bgp-to-ospf)

     

    On a related note, would people recommend exporting prefixes form BGP to OSPf in general?

     

    Here is the corrected configuration for R1:

    !!! R1 !!!

    !

    !!! Set the communities we would like to assign a community to private (ispA) and public (ispB) prefixes learned from AS1234 !!!

    set policy-options community ispA members 1234:1

    set policy-options community ispB members 1234:2

    !

    set policy-options policy-statement set-community-isp-a term 1 from as-path 1234

    set policy-options policy-statement set-community-isp-a term 1 then community add ispA

    set policy-options policy-statement set-community-isp-a term 1 then accept

    !

    set policy-options policy-statement set-community-isp-b term 1 from as-path 1234

    set policy-options policy-statement set-community-isp-b term 1 then community add ispB

    set policy-options policy-statement set-community-isp-b term 1 then accept

    !

    !!! RFC1918 prefixes which we will advertise to ispA !!!

    set policy-options prefix-list AS100_private_prefixes 10.1.0.0/16

    set policy-options prefix-list AS100_private_prefixes 10.2.0.0/16

    !

    !!! Public prefixes which we will advertise to ispB !!!

    set policy-options prefix-list AS100_public_prefixes 255.255.1.0/24

    !

    !!! Accept any prefix from our ISP aside from our own (originated from AS100) and add the appropriate community !!!

    set policy-options policy-statement import-from-ispA from protocol bgp

    set policy-options policy-statement import-from-ispA term reject-routes from prefix-list AS100_private_prefixes

    set policy-options policy-statement import-from-ispA term reject-routes then reject

    !!! Add the community for export to OSPF !!!

    set policy-options policy-statement import-from-ispA term all_else from as-path 1234

    set policy-options policy-statement import-from-ispA term all_else then community add ispA 

    set policy-options policy-statement import-from-ispA term all_else then accept

    !

    set policy-options policy-statement import-from-ispB from protocol bgp

    set policy-options policy-statement import-from-ispB term reject-routes from prefix-list AS100_public_prefixes

    set policy-options policy-statement import-from-ispB term reject-routes then reject

    !!! Add the community for export to OSPF !!!

    set policy-options policy-statement import-from-ispB term all_else from as-path 1234

    set policy-options policy-statement import-from-ispB term all_else then community add ispB

    set policy-options policy-statement import-from-ispB term all_else then accept

    !

     

    !

    set policy-options policy-statement export-to-ispA term get-routes from prefix-list AS100_private_prefixes

    set policy-options policy-statement export-to-ispA term get-routes then accept

    set policy-options policy-statement export-to-ispA term others then reject

    !

    set policy-options policy-statement export-to-ispB term get-routes from prefix-list AS100_public_prefixes

    set policy-options policy-statement export-to-ispB term get-routes then accept

    set policy-options policy-statement export-to-ispB term others then reject

    !

    !

    !!! eBGP peering with our ISP !!!

    set protocols bgp group ispA type external

    set protocols bgp group ispA import import-from-ispA

    set protocols bgp group ispA export export-to-ispA

    set protocols bgp group ispA peer-as 1234

    set protocols bgp group ispA neighbor 10.0.0.1

    !

    set protocols bgp group ispB type external

    set protocols bgp group ispB import import-from-ispB

    set protocols bgp group ispB export export-to-ispB

    set protocols bgp group ispB peer-as 1234

    set protocols bgp group ispB neighbor 10.0.0.3

    !

    !!! iBGP peer !!!

    !

    set protocols bgp group AS100 type internal

    set protocols bgp group AS100 local-preference 50

    set protocols bgp group AS100 neighbor 192.168.1.2

    !

    !!! Export all prefixes learned from ISP A and ISP B to OSPF !!!

    set policy-options policy-statement bgp-to-ospf term 1 from protocol bgp

    set policy-options policy-statement bgp-to-ospf term 1 from community ispA

    set policy-options policy-statement bgp-to-ospf term 1 from community ispB

    set policy-options policy-statement bgp-to-ospf term 1 then accept


    @vvadivel wrote:

    Hi Ottimo,

     

    Please find the observations from your configuration provided for your design

     

    set policy-options policy-statement import-from-ispB from protocol bgp == > import-from-ispA instead of import-from-ispB

    set policy-options policy-statement import-from-ispA term reject-routes from prefix-list AS100_private_prefixes

    set policy-options policy-statement import-from-ispA term reject-routes then reject


    !!! Add the community for export to OSPF !!!

    set policy-options policy-statement import-from-ispA term all_else from as-path 1234

    set policy-options policy-statement import-from-ispA term all_else then community add ispA

    set policy-options policy-statement import-from-ispA term all_else then accept


    Change the policy name export-to-ispB :

    set policy-options policy-statement export-to-ispA term get-routes from prefix-list AS100_public_prefixes

    set policy-options policy-statement export-to-ispA term get-routes then accept

    set policy-options policy-statement export-to-ispA term others then reject


    This doesnot make any change because Local preference is local to the router you cannot advertise LP.
    MED you can change and advertise


    !!! set the local preference to 50 when advertised to iBGP peers !!!

    set policy-options policy-statement set-local-pref term 1 from as-path 1234

    set policy-options policy-statement set-local-pref term 1 then local-preference add 50

    set policy-options policy-statement set-local-pref term 1 then accept

     

    Like Below:

    set policy-options policy-statement set-local-pref term 1 then metric <>


    Hope this helps
    --------------------------------------------------------------------------------------------------------
    If this post was helpful, please mark this post as an "Accepted Solution".
    Kudos are always appreciated!
    --------------------------------------------------------------------------------------------------------



    @vvadivel wrote:

    Hi Ottimo,

     

    Please find the observations from your configuration provided for your design

     

    set policy-options policy-statement import-from-ispB from protocol bgp == > import-from-ispA instead of import-from-ispB

    set policy-options policy-statement import-from-ispA term reject-routes from prefix-list AS100_private_prefixes

    set policy-options policy-statement import-from-ispA term reject-routes then reject


    !!! Add the community for export to OSPF !!!

    set policy-options policy-statement import-from-ispA term all_else from as-path 1234

    set policy-options policy-statement import-from-ispA term all_else then community add ispA

    set policy-options policy-statement import-from-ispA term all_else then accept


    Change the policy name export-to-ispB :

    set policy-options policy-statement export-to-ispA term get-routes from prefix-list AS100_public_prefixes

    set policy-options policy-statement export-to-ispA term get-routes then accept

    set policy-options policy-statement export-to-ispA term others then reject


    This doesnot make any change because Local preference is local to the router you cannot advertise LP.
    MED you can change and advertise


    !!! set the local preference to 50 when advertised to iBGP peers !!!

    set policy-options policy-statement set-local-pref term 1 from as-path 1234

    set policy-options policy-statement set-local-pref term 1 then local-preference add 50

    set policy-options policy-statement set-local-pref term 1 then accept

     

    Like Below:

    set policy-options policy-statement set-local-pref term 1 then metric <>


    Hope this helps
    --------------------------------------------------------------------------------------------------------
    If this post was helpful, please mark this post as an "Accepted Solution".
    Kudos are always appreciated!
    --------------------------------------------------------------------------------------------------------




    set protocols ospf export bgp-to-ospf

    !

     

     



  • 4.  RE: Adding a BGP community to prefixes for export to OSPF and iBGP peers

    Posted 03-13-2018 11:13

    Hi,

     

    Configuration looks to be fine.

    Kindly find the answers for your queries

     

    1. On a related note, would people recommend exporting prefixes form BGP to OSPf in general?
    It depends on your requirement whether do you really want your IGP should know the route or not. depends on case scenario it varies.

     

    one observation:

     

    set protocols bgp group AS100 local-preference 50
    this will change the LP for all routes received from the neighbor

     

     

    Hope this helps
    --------------------------------------------------------------------------------------------------------
    If this post was helpful, please mark this post as an "Accepted Solution".
    Kudos are always appreciated!
    --------------------------------------------------------------------------------------------------------

     

     



  • 5.  RE: Adding a BGP community to prefixes for export to OSPF and iBGP peers

    Posted 03-13-2018 16:11

    Thanks again for the reply vvadivel. Yes, that local preference will be applied to ALL prefixes learned from my iBGP peer. Our iBGP neighbour will peer with the same ISP int he same manner, so these routers will provde routing redundancy for eachother. I will export direclty connected prefixes form my iBGP peer along with those external prefixes from the ISP. Based on what I've read, the external prefixes should be advertised by default to iBGP peers.



  • 6.  RE: Adding a BGP community to prefixes for export to OSPF and iBGP peers
    Best Answer

    Posted 03-13-2018 20:18

    Yes your understanding is correct, eBGP learned routes will be advertised to your ibgp peers by default.

    let me know you have any other quries or you can mark solution for this thread

     

    Hope this helps

    ---------------------------------------------------------------------------------------------------------------------------------------

    If this post was helpful, please mark this post as an "Accepted Solution". Kudos are always appreciated!

    ---------------------------------------------------------------------------------------------------------------------------------------



  • 7.  RE: Adding a BGP community to prefixes for export to OSPF and iBGP peers

    Posted 03-14-2018 00:40

    Hi vvadivel,

     

    Thanks again for confirming that. I will let you know how the implementation goes.