OSPF · Topic 5 of 5
OSPF Routing Policy and Troubleshooting Tools
Learn OSPF import and export policy on Junos and troubleshoot OSPF with ping, traceroute, traceoptions, show commands and logs for the JN0-352 exam.
- 6 min
- Export policy puts non-OSPF routes into OSPF as external LSAs; the default export rejects them.
- Import policy applies to OSPF external routes only.
then external type 1sets the metric type; default is type 2.
What it is
Routing policy controls which routes OSPF brings in and which routes it advertises. On Junos OS, an export policy decides what OSPF advertises as external routes, and an import policy decides which OSPF external routes enter the routing table.
Troubleshooting tools are the commands and logs that show why a neighbor will not form, why a route is missing or why traffic takes the wrong path.
How it works
Export policy
OSPF advertises the subnets of its own interfaces automatically. Routes from any other source (static, direct, BGP, IS IS) are not advertised unless an export policy accepts them. The default OSPF export policy rejects everything else.
user@ASBR# set policy-options policy-statement STATIC-TO-OSPF term 1 from protocol static
user@ASBR# set policy-options policy-statement STATIC-TO-OSPF term 1 from route-filter 192.168.0.0/16 orlonger
user@ASBR# set policy-options policy-statement STATIC-TO-OSPF term 1 then external type 1
user@ASBR# set policy-options policy-statement STATIC-TO-OSPF term 1 then accept
user@ASBR# set protocols ospf export STATIC-TO-OSPF
The exported routes become type 5 external LSAs, and the router becomes an ASBR. then external type 1 chooses external metric type 1; without it, the default is type 2. then metric sets the cost, and then tag adds a tag that other routers can match.
Policy is evaluated top to bottom, and a route that matches no term falls to the default action. In an export policy for OSPF, an unmatched route is rejected.
Import policy
An OSPF import policy filters routes before they enter the routing table. In Junos it applies to external routes only. You cannot use import policy to remove internal or inter-area routes, because every router in an area must hold the same database and the same view of the area.
user@router# set policy-options policy-statement NO-EXT-10 term 1 from route-filter 10.99.0.0/16 orlonger
user@router# set policy-options policy-statement NO-EXT-10 term 1 then reject
user@router# set protocols ospf import NO-EXT-10
| Export | Import | |
|---|---|---|
| Direction | From the routing table into OSPF | From OSPF into the routing table |
| What it affects | The LSAs the router originates | Routes the router installs |
| Applies to | Routes from other protocols | OSPF external routes only |
| Default | Reject all non-OSPF routes | Accept |
To filter internal or inter-area routes, use the design tools: area types, area-range with restrict, and stub areas. A policy is the wrong tool.
The troubleshooting sequence
Start at the lowest layer and move up. The same sequence works for a lab and for the exam.
Ping and traceroute
user@R1> ping 10.1.1.2 rapid count 5
user@R1> ping 10.255.0.2 source 10.255.0.1 rapid
user@R1> traceroute 10.255.0.2
user@R1> traceroute 10.255.0.2 no-resolve
ping proves the IP link works. A failed ping to the neighbor address means the problem is below OSPF. Use source to test with the loopback as the source address, which proves return routes exist for that address. traceroute shows the path hop by hop and shows where forwarding goes wrong.
Show commands
| Command | Shows |
|---|---|
show ospf neighbor | Neighbor state, priority and dead timer |
show ospf interface detail | Interface in OSPF, network type, metric, timers, authentication |
show ospf database | LSAs per area; add extensive for the full LSA |
show ospf overview | Router ID, areas, area types |
show ospf route | The OSPF route table |
show ospf statistics | Counters of packets sent and received, and errors |
show route protocol ospf | OSPF routes in the routing table |
Match the symptom to the command. No neighbor at all: show ospf interface and show ospf statistics. Neighbor present but no route: show ospf database and show route protocol ospf. Route present but wrong: show route <prefix> detail for the preference and next hop.
Traceoptions
Traceoptions write protocol events to a file under /var/log.
user@R1# set protocols ospf traceoptions file ospf-trace size 1m files 5
user@R1# set protocols ospf traceoptions flag hello detail
user@R1# set protocols ospf traceoptions flag error
user@R1# set protocols ospf traceoptions flag state
user@R1# commit
user@R1> show log ospf-trace
user@R1> monitor start ospf-trace
user@R1> monitor stop
Useful flags are hello, packets, lsa-update, spf, state and error. The error flag shows the reason for a rejected Hello, such as a mismatched area or authentication failure.
Traceoptions with all and detail on a busy router uses a lot of CPU and disk space. Trace only the flags you need, keep the file size small, and delete the configuration when you finish.
Logging
The routing process writes events to the system log. Neighbor changes appear in messages.
user@R1> show log messages | match OSPF
user@R1> show log messages | last 50
Look here for a neighbor that goes up and down.
Common failure patterns
| Symptom | Likely cause |
|---|---|
| No neighbor, no Hellos in trace | Interface not in OSPF, passive, or a filter on lo0.0 or the interface drops OSPF |
| Stuck in Init | One way Hellos; filter or authentication problem on the far end |
| Stuck in ExStart | MTU mismatch |
| Neighbor Full but route missing | Import policy, wrong area, or a stub area blocking external routes |
| External route missing everywhere | No export policy, or the route is not accepted by it |
Common mistakes
Expecting a static route to be advertised by OSPF without a policy. An export policy is needed.
Using import policy to filter inter-area routes. It cannot; it only works on external routes.
Leaving traceoptions on. It consumes disk and CPU.
What to remember for the exam
- Export policy puts non-OSPF routes into OSPF as external LSAs; the default export rejects them.
- Import policy applies to OSPF external routes only.
then external type 1sets the metric type; default is type 2.- Troubleshoot in order: ping, interface, neighbor, database, route.
ospf traceoptions file ... flag ...writes to a file in/var/log; read it withshow logormonitor start.- Neighbor events are in
show log messages | match OSPF.
Check yourself
A static route exists on an ASBR but is not seen by other OSPF routers. What is missing?
An export policy that accepts the static route, applied with
protocols ospf export.Can an OSPF import policy remove an intra-area route?
No, in Junos it applies only to OSPF external routes.
Which commands show why a Hello was rejected?
Set
traceoptionswith thehelloanderrorflags and read the file withshow log, and checkshow ospf statisticsfor error counters.
Topic 5 of 5 in OSPF
Test yourself on OSPF
The full Juniper JNCIS-ENT JN0-352 question bank has 846 questions, with timed practice exams and an explanation for every answer.
This study guide is independent and is not affiliated with, endorsed by, or sponsored by Juniper. Vendor names, certification names and exam codes are trademarks of their respective owners and are used for identification only.