OSPF · Topic 4 of 5
Configuring OSPF Areas, Interfaces, Neighbors and Basic Options
Configure and verify OSPF on Junos: areas, interfaces, passive loopback, authentication, metric, reference bandwidth, BFD, overload and show commands.
- 6 min
- Enable OSPF by putting interfaces under
protocols ospf area <id> interface <name>; there is nonetworkstatement. passiveadvertises the subnet but forms no neighbors.- Defaults: hello 10, dead 40, retransmit 5, priority 128, reference bandwidth 100 Mbps.
What it is
On Junos OS, OSPF is configured under [edit protocols ospf]. You do not write network statements as on some other platforms. You place interfaces inside areas, and the router advertises the subnets of those interfaces and tries to form neighbors on them.
This page covers the minimum working configuration, how to check it, and the options the exam expects you to know: authentication, metric, passive interfaces, timers, reference bandwidth, BFD and the overload bit.
How it works
A basic configuration
user@R1# set routing-options router-id 10.255.0.1
user@R1# set interfaces ge-0/0/1 unit 0 family inet address 10.1.1.1/30
user@R1# set interfaces lo0 unit 0 family inet address 10.255.0.1/32
user@R1# set protocols ospf area 0.0.0.0 interface ge-0/0/1.0
user@R1# set protocols ospf area 0.0.0.0 interface lo0.0 passive
user@R1# commit
The same in curly-brace form:
protocols {
ospf {
area 0.0.0.0 {
interface ge-0/0/1.0;
interface lo0.0 {
passive;
}
}
}
}
Notes on the configuration:
- The interface needs
family inetand an address. Refer to it with its logical unit, such asge-0/0/1.0. - Area IDs are shown in dotted notation. Area
1and0.0.0.1are the same area. - A passive interface is advertised into OSPF but sends no Hellos and forms no neighbors. Use it for loopbacks and for links to end users.
interface allenables OSPF on every interface in the area, including interfaces you may not want. Name the interfaces instead.- The router ID can be set with the
routing-options router-idstatement; see the earlier page.
Verifying neighbors, interfaces and routes
user@R1> show ospf neighbor
Address Interface State ID Pri Dead
10.1.1.2 ge-0/0/1.0 Full 10.255.0.2 128 36
user@R1> show ospf interface
Interface State Area DR ID BDR ID Nbrs
ge-0/0/1.0 DR 0.0.0.0 10.255.0.1 10.255.0.2 1
user@R1> show ospf route
user@R1> show route protocol ospf
show ospf interface detail lists the metric, timers and network type per interface. show ospf route shows the OSPF route table and the type of each route.
Interface options
Interface options go under area <id> interface <name>.
| Option | Purpose | Default |
|---|---|---|
metric | Cost of the interface | Calculated from the reference bandwidth |
priority | DR election priority | 128 |
hello-interval | Seconds between Hellos | 10 |
dead-interval | Seconds before a neighbor is declared down | 40 |
retransmit-interval | Seconds before an LSA is resent | 5 |
interface-type | p2p, p2mp, nbma or broadcast | Broadcast on Ethernet |
passive | Advertise but form no neighbors | Not passive |
authentication | Simple password or MD5 | None |
bfd-liveness-detection | Fast failure detection | Off |
user@R1# set protocols ospf area 0.0.0.0 interface ge-0/0/1.0 metric 20
user@R1# set protocols ospf area 0.0.0.0 interface ge-0/0/1.0 hello-interval 5
user@R1# set protocols ospf area 0.0.0.0 interface ge-0/0/1.0 dead-interval 20
If you change the hello and dead intervals on one router, make the same change on the neighbor. Both routers must match.
Metric and reference bandwidth
The OSPF cost of an interface is the reference bandwidth divided by the interface bandwidth. The Junos default reference bandwidth is 100 Mbps, which gives every link of 100 Mbps and faster a cost of 1. On a network with Gigabit and 10 Gigabit links, raise the reference bandwidth so the paths can be told apart:
user@R1# set protocols ospf reference-bandwidth 100g
Set the same value on every router in the domain, or the costs will not be consistent. A fixed metric on an interface overrides the calculation.
Authentication
user@R1# set protocols ospf area 0.0.0.0 interface ge-0/0/1.0 authentication md5 1 key "S3cret"
user@R1# set protocols ospf area 0.0.0.0 interface ge-0/0/1.0 authentication simple-password "S3cret"
The two lines are alternatives. MD5 uses a key ID (here 1) and a key, and both sides must match. A mismatch stops the Hellos being accepted, so the neighbor does not come up.
BFD and overload
Bidirectional Forwarding Detection detects a failed link in well under a second, much faster than the 40 second dead interval:
user@R1# set protocols ospf area 0.0.0.0 interface ge-0/0/1.0 bfd-liveness-detection minimum-interval 300
user@R1# set protocols ospf area 0.0.0.0 interface ge-0/0/1.0 bfd-liveness-detection multiplier 3
The overload option makes the router advertise its links with the maximum metric, so other routers avoid using it for transit traffic. Use it for maintenance:
user@R1# set protocols ospf overload
Use show | compare before commit on OSPF changes. A wrong area ID or an interface placed in the wrong area is easy to see in the diff and expensive to find later.
Common mistakes
Forgetting the unit. The interface is referred to as ge-0/0/1.0, with its logical unit.
Placing the loopback in OSPF without passive. It works, but the router sends Hellos on a loopback for no reason.
Different area IDs on the two ends. The Hellos are rejected, and no neighbor appears.
Different reference bandwidth on routers. The routers calculate different costs, and the paths chosen are not what you expect.
Setting a custom hello interval without matching the dead interval. The neighbor flaps or never forms.
Putting interface all in area 0 can pull the management interface into OSPF and advertise the management network into the production routing table.
What to remember for the exam
- Enable OSPF by putting interfaces under
protocols ospf area <id> interface <name>; there is nonetworkstatement. passiveadvertises the subnet but forms no neighbors.- Defaults: hello 10, dead 40, retransmit 5, priority 128, reference bandwidth 100 Mbps.
- Authentication, area ID, timers and subnet must match on both ends.
interface-type p2premoves the DR election on a two router Ethernet link.overloadadvertises maximum metric; BFD speeds up failure detection.- Check with
show ospf neighbor,show ospf interface,show ospf routeandshow route protocol ospf.
Check yourself
How do you advertise a loopback subnet in OSPF without forming neighbors on it?
Place the loopback interface in an area and mark it
passive.What is the effect of the default reference bandwidth of 100 Mbps on a network of 1 Gbps links?
Every link gets a cost of 1, so you raise the reference bandwidth with
reference-bandwidthto separate links by speed.Two routers have different hello and dead intervals on a link. What happens?
They do not become neighbors, because the timers must match.
Topic 4 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.