Example: Controlling OSPF Route Selection in the Forwarding Table
This example shows how to control OSPF route selection in the forwarding table.
Requirements
Before you begin:
- Configure network interfaces. See the Junos OS Interfaces Configuration Guide for Security Devices.
- Configure security filters. See the Junos OS Security Configuration Guide.
- Configure the router identifiers for the devices in your OSPF network. See Example: Configuring an OSPF Router Identifier.
- Control OSPF designated router election. See Example: Controlling OSPF Designated Router Election.
- Create the backbone area for your OSPF network
and add the appropriate interfaces to the area. See Example: Configuring a Single-Area OSPF Network.

Note: Once you complete this step, OSPF begins sending LSAs. No additional configuration is required to enable OSPF traffic on the network.
- Configure a multiarea OSPF network. See Example: Configuring a Multiarea OSPF Network.
- Configure OSPF stub and not-so-stubby areas. See Example: Configuring OSPF Stub and Not-So-Stubby Areas.
- Enable authentication for OSPF exchanges. See Example: Enabling Authentication for OSPF Exchanges.
- Control the cost of individual OSPF network segments. See Example: Controlling the Cost of Individual OSPF Network Segments.
Overview
In this example, you set the external route preference to 130 and the internal route preference to 7.
Configuration
Step-by-Step Procedure
To control OSPF route selection in the forwarding table:
- Configure OSPF and set the external
and internal routing preferences.[edit]user@host# set protocols ospf external-preference 130 preference 7
- If you are done configuring
the device, commit the configuration.[edit]user@host# commit
Verification
To verify the configuration is working properly, enter the show protocols ospf command.
- Verifying OSPF-Enabled Interfaces
- Verifying OSPF Neighbors
- Verifying the Number of OSPF Routes
- Verifying Reachability of All Hosts in an OSPF Network
Verifying OSPF-Enabled Interfaces
Purpose
Verify that OSPF is running on a particular interface and that the interface is in the desired area.
Action
From operational mode, enter the show ospf interface command.
user@host> show ospf interfaceIntf State Area DR ID BDR ID Nbrs at-5/1/0.0 PtToPt 0.0.0.0 0.0.0.0 0.0.0.0 1 ge-2/3/0.0 DR 0.0.0.0 192.168.4.16 192.168.4.15 1 lo0.0 DR 0.0.0.0 192.168.4.16 0.0.0.0 0 so-0/0/0.0 Down 0.0.0.0 0.0.0.0 0.0.0.0 0 so-6/0/1.0 PtToPt 0.0.0.0 0.0.0.0 0.0.0.0 1 so-6/0/2.0 Down 0.0.0.0 0.0.0.0 0.0.0.0 0 so-6/0/3.0 PtToPt 0.0.0.0 0.0.0.0 0.0.0.0 1
Meaning
The output shows a list of the device interfaces that are configured for OSPF. Verify the following information:
- Each interface on which OSPF is enabled is listed.
- Under Area, each interface shows the area for which it was configured.
- Under Intf and State, the device loopback (lo0.0) interface and LAN interface that are linked to the OSPF network's designated router (DR) are identified.
- Under DR ID, the IP address of the OSPF network's designated router appears.
- Under State, each interface shows a state of PtToPt to indicate a point-to-point connection. If the state is Waiting, check the output again after several seconds. A state of Down indicates a problem.
- The designated router addresses always show a state of DR.
Verifying OSPF Neighbors
Purpose
OSPF neighbors are interfaces that have an immediate adjacency. On a point-to-point connection between the device and another router running OSPF, verify that each router has a single OSPF neighbor.
Action
From operational mode, enter the show ospf neighbor command.
user@host> show ospf neighborAddress Intf State ID Pri Dead 192.168.254.225 fxp3.0 2Way 10.250.240.32 128 36 192.168.254.230 fxp3.0 Full 10.250.240.8 128 38 192.168.254.229 fxp3.0 Full 10.250.240.35 128 33 10.1.1.129 fxp2.0 Full 10.250.240.12 128 37 10.1.1.131 fxp2.0 Full 10.250.240.11 128 38 10.1.2.1 fxp1.0 Full 10.250.240.9 128 32 10.1.2.81 fxp0.0 Full 10.250.240.10 128 33
Meaning
The output shows a list of the device's OSPF neighbors and their addresses, interfaces, states, router IDs, priorities, and number of seconds allowed for inactivity (“dead” time). Verify the following information:
- Each interface that is immediately adjacent to the device is listed.
- The device's own loopback address and the loopback addresses of any routers with which the device has an immediate adjacency are listed.
- Under State, each neighbor shows a state of Full. Because full OSPF connectivity is established over a series
of packet exchanges between clients, the OSPF link might take several
seconds to establish. During that time, the state might be displayed
as Attempt, Init, or 2way, depending on
the stage of negotiation.
If, after 30 seconds, the state is not Full, the OSPF configuration between the neighbors is not functioning correctly.
Verifying the Number of OSPF Routes
Purpose
Verify that the OSPF routing table has entries for the following:
- Each subnetwork reachable through an OSPF link
- Each loopback address reachable on the network
For example, Figure 21 shows a sample network with an OSPF topology.
Figure 21: Sample OSPF Network Topology

In this topology, OSPF is being run on all interfaces. Each segment in the network is identified by an address with a /24 prefix, with interfaces on either end of the segment being identified by unique IP addresses.
Action
From operational mode, enter the show ospf route command.
user@host> show ospf routePrefix Path Route NH Metric NextHop Nexthop
Type Type Type Interface addr/label
10.10.10.1/24 Intra Network IP 1 ge-0/0/2.0 10.0.21.1
10.10.10.2/24 Intra Network IP 1 ge-0/0/2.0 10.0.21.1
10.10.10.4/24 Intra Network IP 1 ge-0/0/1.0 10.0.13.1
10.10.10.5/24 Intra Network IP 1 ge-0/0/2.0 10.0.21.1
10.10.10.6/24 Intra Network IP 1 ge-0/0/1.0 10.0.13.1
10.10.10.10/24 Intra Network IP 1 ge-0/0/2.0 10.0.21.1
10.10.10.11/24 Intra Network IP 1 ge-0/0/1.0 10.0.13.1
10.10.10.13/24 Intra Network IP 1 ge-0/0/1.0
10.10.10.16/24 Intra Network IP 1 ge-0/0/1.0 10.0.13.1
10.10.10.19/24 Intra Network IP 1 ge-0/0/1.0 10.0.13.1
10.10.10.20/24 Intra Network IP 1 ge-0/0/2.0 10.0.21.1
10.10.10.21/24 Intra Network IP 1 ge-0/0/2.0
192.168.5.1 Intra Router IP 1 ge-0/0/2.0 10.0.21.1
192.168.5.2 Intra Router IP 1 lo0
192.168.5.3 Intra Router IP 1 ge-0/0/1.0 10.0.13.1
192.168.5.4 Intra Router IP 1 ge-0/0/1.0 10.0.13.1
192.168.5.5 Intra Router IP 1 ge-0/0/1.0 10.0.13.1
192.168.5.6 Intra Router IP 1 ge-0/0/2.0 10.0.21.1
192.168.5.7 Intra Router IP 1 ge-0/0/2.0 10.0.21.1
192.168.5.8 Intra Router IP 1 ge-0/0/2.0 10.0.21.1
192.168.5.9 Intra Router IP 1 ge-0/0/1.0 10.0.13.1
Meaning
The output lists each route, sorted by IP address. Routes are shown with a route type of Network, and loopback addresses are shown with a route type of Router.
For the example shown in Figure 22, verify that the OSPF routing table has 21 entries, one for each network segment and one for each router's loopback address.
Verifying Reachability of All Hosts in an OSPF Network
Purpose
By using the traceroute tool on each loopback address in the network, verify that all hosts in the network are reachable from each device.
Action
For each device in the OSPF network:
- In the J-Web interface, select Troubleshoot>Traceroute.
- In the Host Name box, type the name of a host for which you want to verify reachability from the device.
- Click Start. Output appears on a separate page.
1 172.17.40.254 (172.17.40.254) 0.362 ms 0.284 ms 0.251 ms 2 routera-fxp0.englab.mycompany.net (192.168.71.246) 0.251 ms 0.235 ms 0.200 ms
Meaning
Each numbered row in the output indicates a routing “hop” in the path to the host. The three-time increments indicate the round-trip time (RTT) between the device and the hop, for each traceroute packet. To ensure that the OSPF network is healthy, verify the following information:
- The final hop in the list is the host you want to reach.
- The number of expected hops to the host matches the number of hops in the traceroute output. The appearance of more hops than expected in the output indicates that a network segment is likely not reachable. In this case, verify the routes with the show ospf route command.
Related Topics
- Junos OS Feature Support Reference for SRX Series and J Series Devices
- Understanding OSPF Traffic Control on page 52
Hide Navigation Pane
Show Navigation Pane
Download
SHA1