Help us improve your experience.

Let us know what you think.

Do you have time for a two-minute survey?

Navigation
Guide That Contains This Content
[+] Expand All
[-] Collapse All

    Example: Configuring a Route Filter Policy to Specify Priority for Prefixes Learned Through OSPF

    This example shows how to create an OSPF import policy that prioritizes specific prefixes learned through OSPF.

    Requirements

    Before you begin:

    Overview

    In a network with a large number of OSPF routes, it can be useful to control the order in which routes are updated in response to a network topology change. In Junos OS Release 9.3 and later, you can specify a priority of high, medium, or low for prefixes included in an OSPF import policy. In the event of an OSPF topology change, high priority prefixes are updated in the routing table first, followed by medium and then low priority prefixes.

    OSPF import policy can only be used to set priority or to filter OSPF external routes. If an OSPF import policy is applied that results in a reject terminating action for a nonexternal route, then the reject action is ignored and the route is accepted anyway. By default, such a route is now installed in the routing table with a priority of low. This behavior prevents traffic black holes, that is, silently discarded traffic, by ensuring consistent routing within the OSPF domain.

    In general, OSPF routes that are not explicitly assigned a priority are treated as priority medium, except for the following:

    • Summary discard routes have a default priority of low.
    • Local routes that are not added to the routing table are assigned a priority of low.
    • External routes that are rejected by import policy and thus not added to the routing table are assigned a priority of low.

    Any available match criteria applicable to OSPF routes can be used to determine the priority. Two of the most commonly used match criteria for OSPF are the route-filter and tag statements.

    In this example, the routing device is in area 0.0.0.0, with interfaces fe-0/1/0 and fe-1/1/0 connecting to neighboring devices. You configure an import routing policy named ospf-import to specify a priority for prefixes learned through OSPF. Routes associated with these prefixes are installed in the routing table in the order of the prefixes’ specified priority. Routes matching 200.3.0.0/16 orlonger are installed first because they have a priority of high. Routes matching 200.2.0.0/16 orlonger are installed next because they have a priority of medium. Routes matching 200.1.0.0/16 orlonger are installed last because they have a priority of low. You then apply the import policy to OSPF.

    Note: The priority value takes effect when a new route is installed, or when there is a change to an existing route.

    Configuration

    CLI Quick Configuration

    To quickly configure an OSPF import policy that prioritizes specific prefixes learned through OSPF, copy the following commands, removing any line breaks, and then paste the commands into the CLI.

    [edit]set interfaces fe-0/1/0 unit 0 family inet address 192.168.8.4/30set interfaces fe-0/1/0 unit 0 family inet address 192.168.8.5/30set policy-options policy-statement ospf-import term t1 from route-filter 200.1.0.0/16 orlongerset policy-options policy-statement ospf-import term t1 then priority lowset policy-options policy-statement ospf-import term t1 then acceptset policy-options policy-statement ospf-import term t2 from route-filter 200.2.0.0/16 orlongerset policy-options policy-statement ospf-import term t2 then priority mediumset policy-options policy-statement ospf-import term t2 then acceptset policy-options policy-statement ospf-import term t3 from route-filter 200.3.0.0/16 orlongerset policy-options policy-statement ospf-import term t3 then priority highset policy-options policy-statement ospf-import term t3 then acceptset protocols ospf import ospf-importset protocols ospf area 0.0.0.0 interface fe-0/1/0set protocols ospf area 0.0.0.0 interface fe-1/1/0

    Step-by-Step Procedure

    The following example requires you to navigate various levels in the configuration hierarchy. For information about navigating the CLI, see Modifying the Junos OS Configuration in CLI User Guide.

    To configure an OSPF import policy that prioritizes specific prefixes:

    1. Configure the interfaces.
      [edit]user@host# set interfaces fe-0/1/0 unit 0 family inet address 192.168.8.4/30user@host# set interfaces fe-0/2/0 unit 0 family inet address 192.168.8.5/30
    2. Enable OSPF on the interfaces.

      Note: For OSPFv3, include the ospf3 statement at the [edit protocols] hierarchy level.

      [edit]user@host# set protocols ospf area 0.0.0.0 interface fe-0/1/0user@host# set protocols ospf area 0.0.0.0 interface fe-0/2/0
    3. Configure the policy to specify the priority for prefixes learned through OSPF.
      [edit ]user@host# set policy-options policy-statement ospf-import term t1 from route-filter 200.1.0.0/16 orlongeruser@host# set policy-options policy-statement ospf-import term t1 then priority lowuser@host# set policy-options policy-statement ospf-import term t1 then acceptuser@host# set policy-options policy-statement ospf-import term t2 from route-filter 200.2.0.0/16 orlongeruser@host# set policy-options policy-statement ospf-import term t2 then priority mediumuser@host# set policy-options policy-statement ospf-import term t2 then acceptuser@host# set policy-options policy-statement ospf-import term t3 from route-filter 200.3.0.0/16 orlongeruser@host# set policy-options policy-statement ospf-import term t3 then priority highuser@host# set policy-options policy-statement ospf-import term t3 then accept
    4. Apply the policy to OSPF.
      [edit]user@host# set protocols ospf import ospf-import
    5. If you are done configuring the device, commit the configuration.
      [edit]user@host# commit

    Results

    Confirm your configuration by entering the show interfaces, show policy-options, and the show protocols ospf commands. If the output does not display the intended configuration, repeat the instructions in this example to correct the configuration.

    user@host# show interfaces
    fe-0/1/0 {unit 0 {family inet {address 192.168.8.4/30;}}}fe-0/2/0 {unit 0 {family inet {address 192.168.8.5/30;}}}
    user@host# show policy-options
    policy-statement ospf-import {term t1 {from {route-filter 200.1.0.0/16 orlonger;}then {priority low;accept;}}term t2 {from {route-filter 200.2.0.0/16 orlonger;}then {priority medium;accept;}}term t3 {from {route-filter 200.3.0.0/16 orlonger;}then {priority high;accept;}}}
    user@host# show protocols ospfimport ospf-import;
    area 0.0.0.0 {interface fe-0/1/0.0;interface fe-0/2/0.0;}

    To confirm your OSPFv3 configuration, enter the show interfaces, show policy-options, and show protocols ospf3 commands.

    Verification

    Confirm that the configuration is working properly.

    Verifying the Prefix Priority in the OSPF Routing Table

    Purpose

    Verify the priority assigned to the prefix in the OSPF routing table.

    Action

    From operational mode, enter the show ospf route detail for OSPFv2, and enter the show ospf3 route detail command for OSPFv3.

    Published: 2014-05-15