Junos OS

Expand all | Collapse all

Redistribute static routes into OSPF

Jump to Best Answer
  • 1.  Redistribute static routes into OSPF

    Posted 06-24-2020 18:57

    Hi,

     

    I am currently learning the redistributing static routes into OSPF, a couple of questions due to the confusions:


    Topology:   RouterA.  ------------- (interface1) RouterB (interface2: ospf-enabled)   -------------- (Rest of OSPF routers)

     

    Config: "set protocols ospf export STATIC-ROUTES" 

    On what router can the config statement above be manually configured?
    Case 1) If it is configured on RouterA, does RouterB receive the imported static routes without doing any import? But I read that OSPF protocol does not allow import, so how can RouterB learn about these imported static routes from RouterA without any import config?
    Futhermore, once OSPF-enabled RouterB is aware of these static routes, how can the rest of OSPF routers in the network know/learn about these static routes?

    Case 2) If it is configured on RouterB, then we are basically exporting static routes from RouterB to RouterA; is it allowed?

    Thanks,



  • 2.  RE: Redistribute static routes into OSPF

     
    Posted 06-24-2020 22:48

    Hi PL2,

     

    Redistribution of routes is done with the help of routing policies. The process of moving routes between a routing protocol and the routing table is described always from the point of view of the routing table. That is, routes are imported into a routing table from a routing protocol and they are exported from a routing table to a routing protocol. 

     

    Please Note: The routes are not exported/imported between two nodes or routers but rather between the routing tables.

     

    In the above case where we are looking at redistributing static into ospf; it goes like this:

    1. We need to configure a policy on RouterB where we shall export static routes into OSPF database (in the same node)

     

    set policy-options policy-statement static-to-ospf term static-accept from protocol static
    set policy-options policy-statement static-to-ospf term static-accept then accept

    set protocols ospf export static-to-ospf

     

    2. To answer next part of your question, ospf by default imports all routes into it's lsdb because ospf requires that all routers in an area have the same lsdb to have a loop-free network. We cannot change/modify this default import policy. So, only export policy is sufficient to redistribute static into ospf!

     

    Now once redistributed into the OSPF network, all other OSPF routers will see this as an OSPF route until Router B and router B acts as a Border router. This information is shared as LSA type 7 and further as LSA type 5 in the backbone area. This is how all OSPF routers learn about this redistribution.

     

    I hope this answers your queries, 

    Accept as Solution = cool ! (Help fellow community members with similar query be redirected here instead of them reposting again)
    Accept as Solution+Kudo = You are a Star !

    Good day Smiley Happy

    //Nex



  • 3.  RE: Redistribute static routes into OSPF

    Posted 06-24-2020 23:11

    Hello PL2,

     

    Greetings !!

     

    The below docs helps in understanding Redistribution of static routes into OSPF along with example .i hope it will help you understanding basic routing policy techniques 

    https://www.juniper.net/documentation/en_US/junos/topics/topic-map/configuring-ospf-routing-policy.html#id-example-redistributing-static-routes-into-ospf

     

    Please mark this post "Accept as solution" if this answers your query.

     

    Kudos are always appreciated!



  • 4.  RE: Redistribute static routes into OSPF
    Best Answer

     
    Posted 06-24-2020 23:43

    Hi PL2,

     

    Good day!!

     

    Below doucument has Simple senario, for better understanding please go the the below document and let me know if need any help.

     

    https://netwx.wordpress.com/2011/08/02/redistribution-of-static-connected-routes-to-ospf-in-junos/

     

    Please mark "Accepted Solution" if this helps.

    Kudos are always appreciated

     

    Thanks 

    Suraj



  • 5.  RE: Redistribute static routes into OSPF

     
    Posted 06-25-2020 10:44

    Hi PL2,

     

    While Routers advertise OSPF routes learned from one OSPF neighbor to another OSPF neighbor, they do not automatically advertise routes learned by other routing information sources such as static routes, routes learned by BGP etc. via OSPF.

     

    In order to advertise routes learned by other routing information sources, an explicit routing policy has to be configured and applied at the [edit  protocols ospf] hierarchy as an export policy. 

     

    Here is an example of an export policy that advertises all statically learned routes to all the OSPF neighbors:


    Defining the Routing Policy:
    Router1> show configuration policy-options policy-statement export-static-routes
    term export-statics {
    from protocol static;
    then accept;
    }

     

    Applying the Routing Policy:
    Router1> show configuration protocols ospf export
    export export-static-routes;

     

    The above example is very broad such that it advertises all static routes learned by the router, to all of its OSPF neighbors. You can configure a more granular policy where only specific prefixes are advertised to OSPF neighbors. Below is an example that shows the match condition to select specific prefixes and advertise by OSPF:

     

    Defining the Specfic Prefix list:
    Router1> run show configuration policy-options prefix-list rfc-1918
    10.0.0.0/8;
    172.16.0.0/12;
    192.168.0.0/16;


    Defining the Routing Policy:
    Router1> run show configuration policy-options policy-statement export-static-routes

    term export-statics {

    from protocol static;

    prefix-list rfc-1918;
    then accept;
    }


    Applying the Routing Policy:
    Router1> show configuration protocols ospf export
    export export-static-routes;

     

    Please mark "Accepted Solution" if this helps.

    Kudos are always appreciated

     

    HTH

    B



  • 6.  RE: Redistribute static routes into OSPF

    Posted 06-25-2020 15:08

    Hello PL2,

     

    Case 1) If it is configured on RouterA, does RouterB receive the imported static routes without doing any import? But I read that OSPF protocol does not allow import, so how can RouterB learn about these imported static routes from RouterA without any import config?
    Futhermore, once OSPF-enabled RouterB is aware of these static routes, how can the rest of OSPF routers in the network know/learn about these static routes?

     

    Keep in mind that OSPF has already a import/export default policy, an OSPF router will learn OSPF routes from LSAs advertised by peers, LSAs will be advertise to peers according to the configuration.

     

    When you export static routes into OSPF, you are causing LSA-External type generated, you should not create import policy options for OSPF, this will restrict the LSAs from entering the 'route table' , but advertisement of the LSA will remain.

     

    Basically, you would add interfaces to OSPF causing LSA type 1 router and LSA type 2 network, when you add static routes or route prefixes via policy this will trigger External LSAs, these are global scope so all OSPF routers will have to have the LSA.

     

      Case 2) If it is configured on RouterB, then we are basically exporting static routes from RouterB to RouterA; is it allowed?

     

    It is the same, you would be adding LSA external routes into OSPF whenever you use policy-options.

     

    Hope it helps.

     

    Cheers,

    Benjamin