Routing

Expand all | Collapse all

Redistribute BGP into OSPF and change next hop value

Jump to Best Answer
  • 1.  Redistribute BGP into OSPF and change next hop value

    Posted 11-29-2012 18:04

    Transferred over from Security (SRX) Forum:

     

    Hi all,

    Don't make me explain why, it'll take too long. Suffice to say this is my only remaining option - and I wish it wasn't.

    I need to redistribute routes learned via BGP into OSPF, which is easy enough. The part I cannot get to work is that I need the route to be advertised to the OSPF neighbour with a next-hop value that is NOT the IP of advertising router. I can't find any documentation that says I shouldn't be able to do this, but I just cannot make it work.

    So:

    Router A: IP 1.1.1.1 -> talks to Router B via BGP

    Router B: IP 1.1.1.2 -> talks to Router A via BGP and to another device (Device Z - 1.1.1.3) via OSPF (this device speaks OSPF but not BGP)

    I need routes advertised from Router A to Router B via BGP to be installed on Device Z, via OSPF, but with a next-hop value equal to 1.1.1.1 instead of 1.1.1.2. On Router B, BGP routes are successfully exported into OSPF but when they get to the neighbour device (Device Z) the next hop is 1.1.1.2.

    Config ======================

    protocols {

    ospf {
    export imp-bgp-2-ospf;
    area 0.0.0.0 {
    interface vlan.1275;
    }
    }
    }

    policy-statement imp-bgp-2-ospf {
    term 1 {
    from {
    route-filter 10.10.0.0/16 exact;
    }
    then {
    next-hop 1.1.1.1;
    accept;
    }
    }
    term 2 {
    from {
    route-filter10.20.30.0/24 exact;
    }
    then {
    next-hop 1.1.1.1;
    accept;
    }
    }
    term 10 {
    then reject;
    }
    }

    end config=============================

    Any help appreciated.

     

    In the customer's network this works, but they're using Cisco 2801 router and route-maps.  I figured the same should be achievable using Juniper hardware.

    Cheers,
    Ben.



  • 2.  RE: Redistribute BGP into OSPF and change next hop value

    Posted 11-30-2012 13:09

    You say this "works" in the customers' network using Cisco?  I find that surprising.  The problem, as I see it, is that if you redistribute BGP into OSPF, these external routes will be advertised into OSPF via type 5 LSAs...and there is no field for "next- hop" within the LSA.  That would sort of be counter to how OSPF works, i.e. flooding of ink and (exernal) route information into the network, with the SPF algorithm being run on the resulting database and that algorithm determining what the next hop IP is for the various networks...

     

    What you are attempting seems fundamentally at odds with how OSPF works, I'd be curious to see how it is done in Cisco.



  • 3.  RE: Redistribute BGP into OSPF and change next hop value
    Best Answer

    Posted 11-30-2012 14:19

    Hello,

    Cisco IOS sets "forwarding-address" in Type-5 LSAs to enable 3rd party next-hop

    http://www.cisco.com/en/US/tech/tk365/technologies_tech_note09186a008009405a.shtml

    There is no equivalent feature in JUNOS, sorry

    HTH

    Thanks

    Alex

     

     



  • 4.  RE: Redistribute BGP into OSPF and change next hop value

    Posted 11-30-2012 15:44

    Thanks to both of you.

     

    B2: My experience certainly supports what you've said. I don't know OSPF well enough to have known this shouldn't work. 

     

    Alex: Yep, that's exactly what I see when doing a detailed look at the OSPF data. I figured it was going to another one of those Cisco-doing-it's-own-thing scenarios. 



  • 5.  RE: Redistribute BGP into OSPF and change next hop value

    Posted 10-06-2017 05:48

    Hi B2,

     

    I think you ( or someone else here 🙂 ) can help me with same question,

     

    I'm importing routes from master(default) routing table inet.0 into another, just say - test.inet.0, and I need to change next-hop of that routes, but looks like next policy doesn't work

     

    show policy-options policy-statement test_import

     

    term 1 {
        from {
            instance master;
            next-hop 20.0.0.2;
            route-filter 1.1.1.1/32 exact;
        }
        then {
            next-hop 30.0.0.1;
            accept;
        }
    }

     

    show routing-instances test routing-options instance-import


    instance-import test_import;