Interior Gateway Protocols · Topic 3 of 3
Routing Policy for IGPs and Troubleshooting
JN0-650 study page on routing policy with OSPF on Junos: import and export, external routes, summary LSA filters, plus show commands and traceoptions.
- 5 min
- OSPF import policy filters external routes only; internal routes cannot be blocked.
- Export policy is how static, direct and other routes enter OSPF; they appear as external LSAs.
- Default external type is 2; use
then external type 1for cost accumulation.
What it is
Junos routing policy controls which routes a protocol accepts from, or announces to, the routing table. A policy is a policy-statement made of terms, each with from match conditions and then actions. For IGPs, policy is used mainly to bring other protocols into OSPF, to filter external routes, and to set metrics.
The key idea is that policy meets the routing table at two points, import and export, and OSPF treats them in a special way.
How it works
Import policy: only external routes
A link state protocol must keep identical databases, so you cannot remove internal routes from the SPF result. An OSPF import policy therefore applies only to external (type 5 and type 7) routes being installed in the routing table. The LSAs stay in the database and keep flooding, but the matching external routes are not installed.
set policy-options policy-statement BLOCK-EXT term 1 from route-filter 192.168.0.0/16 orlonger
set policy-options policy-statement BLOCK-EXT term 1 then reject
set protocols ospf import BLOCK-EXT
An import policy cannot stop internal OSPF routes. To keep a prefix out of an area, summarize or filter it where the LSA is created, not on the receiving router.
Export policy: creating external LSAs
OSPF exports nothing from other protocols by default. An export policy selects routes from direct, static, BGP or another protocol, and the router becomes an ASBR that advertises them as type 5 LSAs (type 7 in an NSSA).
set policy-options policy-statement STATIC-TO-OSPF term 1 from protocol static
set policy-options policy-statement STATIC-TO-OSPF term 1 from route-filter 10.9.0.0/16 orlonger
set policy-options policy-statement STATIC-TO-OSPF term 1 then external type 1
set policy-options policy-statement STATIC-TO-OSPF term 1 then metric 50
set policy-options policy-statement STATIC-TO-OSPF term 1 then accept
set protocols ospf export STATIC-TO-OSPF
Without the final accept, a term that matches without a terminating action falls through to the next term, and then to the default policy for that protocol, which rejects routes that OSPF did not learn itself.
Match conditions and actions
| Match | Meaning |
|---|---|
from protocol | The route's source protocol, such as direct or static |
from route-filter prefix match-type | A prefix with exact, orlonger, longer, upto or prefix-length-range |
from interface | The route's outgoing interface |
then metric | Sets the OSPF metric |
then external type 1 or 2 | Sets the external metric type |
then accept or reject | Ends policy evaluation |
then next term or next policy | Continues to the next term or to the next policy in the chain |
Policies listed in a chain, such as export [ P1 P2 ], are evaluated left to right until one accepts or rejects.
Summary LSA filters on an ABR
area-range creates a summary from an area's routes, and the keyword restrict stops that summary from being advertised at all:
set protocols ospf area 0.0.0.1 area-range 10.1.0.0/16 restrict
An ABR can also filter the summary LSAs it sends into an area with an export policy applied at area level using network-summary-export under the area. This is how you hide specific inter-area prefixes.
Monitoring and troubleshooting
Work in the order the protocol works: interface, neighbor, database, route.
| Question | Command |
|---|---|
| Is OSPF running on the interface? | show ospf interface |
| Are neighbors Full? | show ospf neighbor and show ospf neighbor detail |
| Is the LSA in the database? | show ospf database and show ospf database extensive |
| Is the route installed? | show ospf route and show route protocol ospf |
| Overall settings, router ID and areas | show ospf overview |
| Packet counters and errors | show ospf statistics |
For OSPFv3 replace ospf with ospf3. When you need to see packets, use traceoptions:
set protocols ospf traceoptions file ospf.trace size 1m files 3
set protocols ospf traceoptions flag error
set protocols ospf traceoptions flag hello detail
show log ospf.trace
| Symptom | Likely cause |
|---|---|
| No neighbor at all | Interface not in OSPF, passive, filter dropping protocol 89, or Hellos not arriving |
| Stuck in Init | Hellos are received but not returned; one way path, filter or authentication |
| Stuck in ExStart or Exchange | MTU mismatch |
| Neighbor up, route missing | Import policy rejected an external route, or an LSA is not reaching the area |
| External route not seen in a stub area | Type 5 LSAs are blocked in stub areas |
Run show ospf database and look at the LSA type column. If the type 5 LSA exists but the route does not, suspect an import policy or an unreachable ASBR (no type 4 or unusable forwarding address).
Common mistakes
Writing an import policy to block an internal prefix. OSPF import affects external routes only.
Exporting without accept. The route falls through and is rejected by default.
Forgetting that exporting makes the router an ASBR. External LSAs are then type 5, or type 7 in an NSSA.
Putting the policy on the wrong protocol. protocols ospf import and protocols ospf export are separate statements.
Reading show ospf neighbor only. A Full neighbor says nothing about whether the route reached the table.
What to remember for the exam
- OSPF import policy filters external routes only; internal routes cannot be blocked.
- Export policy is how static, direct and other routes enter OSPF; they appear as external LSAs.
- Default external type is 2; use
then external type 1for cost accumulation. area-range ... restrictsuppresses a summary at the ABR.- Troubleshoot in order: interface, neighbor, database, route, policy.
traceoptionswrites to a file under/var/log, read withshow log.
Check yourself
Can an OSPF import policy keep an internal route out of the routing table?
No, import policy applies to external routes only, because all routers must keep the same database.
Why does an export policy term with only
from protocol staticadvertise nothing?It has no terminating action, so the route falls through to the default policy and is rejected; add
then accept.A neighbor is Full but a type 5 route is missing from the routing table. Where do you look first?
At the import policy on
protocols ospf, then at the route to the ASBR.
Topic 3 of 3 in Interior Gateway Protocols
Test yourself on Interior Gateway Protocols
The full Juniper JNCIP-ENT JN0-650 question bank has 858 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.