Routing

Expand all | Collapse all

How to redistribute bgp into ospf with different area.

Jump to Best Answer
  • 1.  How to redistribute bgp into ospf with different area.

    Posted 07-31-2016 01:29

    I have a topology like this 

     

    ToplogyToplogy

    I have 3 routers: router r1 connect to router r2 and run ospf area 23. beside, router r1 also connect to router r3 and run ospf with area 18. In router r1 receive protobgp with router-fillter is 0.0.0.0/0. 
    And now, I only want router r1 redistribute bgp into ospf with area 23 to router r2. 

    I have configed: 

    policy-options policy-statement ADV_BGP_TO_OSPF

     

    term Default-Route {

        from {

            protocol bgp;

            route-filter 0.0.0.0/0 exact;

        }

        to {

            area 0.0.0.23;

        }

        then accept;

    }

    term final {

        then reject;

    }

     

    And export policy into ospf. However, the router r2 don't see anything router 0.0.0.0/0 learn from router r1. 

    Then, I try deactive to area 0.0.0.23 in policy. The result is see that router r2 and r3 have both router 0.0.0.0/0 learn from router r1. I want only router r2 recevie 0.0.0.0/0 from router r1, and don't want router r3 also recevie 0.0.0.0/0 from router r1. 

    How to deal with this issue? 
    Thank you.



  • 2.  RE: How to redistribute bgp into ospf with different area.

     
    Posted 07-31-2016 06:52

    Hi, 

     

    The "to" statement in the policy is a matching condition:

    > from                 Conditions to match the source of a route
    > then                 Actions to take if 'from' and 'to' conditions match
    > to                   Conditions to match the destination of a route

    I am not sure the external route can be exported to selected areas in OSPF, because external routes have an interarea flooding scope, hence policies are applied globally and external routes are exported to all areas under ospf.  Statement "to area 0.0.0.23" is not a matching condition I suppose, hence 0/0 is not exported when the statement is present.

     

    You could use an import filter on R3's OSPF to reject the default route from being installed in the routing table.  However, this may not be a scalable solution if you have multiple neighbors in area 0.0.0.18 because of the LSA flooding.

     

    Cheers,

    Ashvin



  • 3.  RE: How to redistribute bgp into ospf with different area.
    Best Answer

     
    Posted 07-31-2016 07:40

    Agree with Ashwin.

     

    Below are the configs:

     

    R1

     


    set policy-options policy-statement ADV_BGP_TO_OSPF term Default-Route from protocol bgp
    set policy-options policy-statement ADV_BGP_TO_OSPF term Default-Route from route-filter 0.0.0.0/0 exact
    set policy-options policy-statement ADV_BGP_TO_OSPF term Default-Route then accept
    set policy-options policy-statement ADV_BGP_TO_OSPF term rest then reject

     

    R3 


    set policy-options policy-statement filter-default term Default-Route from route-filter 0.0.0.0/0 exact
    set policy-options policy-statement filter-default term Default-Route then reject

     

    [edit]
    R3

     

    R3 show protocols ospf


    import filter-default;
    area 0.0.0.18 {
    interface ge-0/0/1.0;
    interface lo0.0;
    }


    R3 commit
    commit complete

    [edit]



  • 4.  RE: How to redistribute bgp into ospf with different area.

    Posted 07-31-2016 18:37

    Thank vinodc. 

    I think it will work. I will try follow the step which you show. 
    Thank you so much




  • 5.  RE: How to redistribute bgp into ospf with different area.

     
    Posted 07-31-2016 18:54

    Thanks Nguyen Huy Hoang for accepting solution

     

    I have tried it in local lab , it works . 

     

    Do a show route for 0.0.0.0(Global RIB) prefix in R3 ,before and after applying import policy , you can observe 0.0.0.0 prefix disappearing after applying import policy.

     

    Thanks ,

    Vinod

     



  • 6.  RE: How to redistribute bgp into ospf with different area.

     
    Posted 08-01-2016 03:07

    Hi, 

     

    You might also want to add a default explicit-accept statement:

    # show policy-options policy-statement OSPF-IMPORT
    term reject-default {
        from {
            route-filter 0.0.0.0/0 exact;
        }
        then reject;
    }
    then accept;

    Although for policy-statements the default is implicit-accept, I consider it a good practice. This would ensure all other external LSAs will be accepted.

     

     

    Cheers,

    Ashvin



  • 7.  RE: How to redistribute bgp into ospf with different area.

    Posted 08-01-2016 03:37

    Hi AshvinO, 

    That's right. I agree with you. 
    Many thanks. 

    Regards, 
    Hoang Nguyen Huy