OSPF tuning: costs, timers, DR placement and network types
An OSPF interface's cost is the reference bandwidth divided by the interface bandwidth, and the default reference is 100 Mbps, so every link of 100 Mbps and faster costs 1. Raise it with auto-cost reference-bandwidth, the same on every router, or set ip ospf cost by hand. Hello and dead timers must match neighbours, and a two-router Ethernet link can run as point-to-point.
By Arif, founder of Daveth · Updated
The full 9 min walkthrough is in Daveth Pro (Network). See what the plan opens
What this page answers
What is the OSPF reference bandwidth?
The number OSPF divides by an interface's bandwidth to get its cost; the default is 100 Mbps, so FastEthernet, Gigabit and 10 Gigabit all cost 1. auto-cost reference-bandwidth changes it, and it should be the same on every router. Read it in “4.1 What a link costs”
How do you change OSPF timers?
ip ospf hello-interval sets the hello, from 1 to 65,535 seconds, and changes the default dead interval too; ip ospf dead-interval sets the dead interval, which must stay greater than the hello. Read it in “4.1 What a link costs”
When should you use the OSPF point-to-point network type?
On an Ethernet link with only two OSPF routers: ip ospf network point-to-point skips the DR election and its wait, so the adjacency forms faster and SPF is simpler. Read it in “4.1 What a link costs”
4.1 What a link costs
SPF picks the path with the lowest total cost, and that total is simply every outgoing interface's cost added up from this router to the destination. So where does an interface's cost come from? One division: the reference bandwidth over the interface bandwidth, and the default reference is 100 Mbps. That gives these defaults:
| Interface | Cost at the default reference |
|---|---|
| T1 (1.544 Mbps) | 64 |
| Ethernet (10 Mbps) | 10 |
| FastEthernet (100 Mbps) | 1 |
| GigabitEthernet (1,000 Mbps) | 1 |
| 10 GigabitEthernet (10,000 Mbps) | 1 |
Look at the bottom three. At 100 Mbps and above, everything costs 1: OSPF can't tell FastEthernet from 10 GigabitEthernet. If you scaled that down to a kitchen scale that tops out at 100 grams, a bag of flour and a bag of sugar would both read "max", and you'd swear they weighed the same. Raise the reference and the fast links separate again, but push it too high and the slow ones stop being distinguishable at the other end. And there's a ceiling: the LSA's metric field (LSAs: 02-4) is 16 bits, so an interface cost can't go above 65,535. (The arithmetic truncates: 100 / 1.544 is 64.77, and the table says 64.)
At the default reference bandwidth, a 10 Gbps link and a 100 Mbps link cost exactly the same. OSPF isn't cheap; it just can't count past a hundred.
auto-cost reference-bandwidth bandwidth-in-mbps, under the process, changes the reference for every interface in that process. Change it on one router and you've swapped the ruler on that router only. That's roughly equivalent to one family member measuring the new sofa in inches while everyone else uses centimetres: every number is right, and the plan is still wrong. The guide's rule is the same reference on every OSPF router, so SPF works from the same logic everywhere and routing loops are avoided. Or set a cost by hand with ip ospf cost 1-65535 on the interface. That cap applies to one interface only; a path's total can go past 65,535, because each router adds the costs up locally, the way no single item on a till receipt costs more than the shop's price tags allow, but the total at the bottom can be anything.
D1

Hellos have a second job: proving the neighbour is still alive. Every router sends them on its hello timer, and keeps a second clock per neighbour, the dead interval, which defaults to four times the hello. Each hello from the neighbour resets that clock to the full dead interval, and it starts counting down again. It's basically like waiting up for a teenager on a night out: every text resets your worry clock. If the clock reaches 0 before the next hello, the neighbour is declared down; the router immediately sends an LSA describing the change, and SPF runs on every router in the area.
So the time a silent failure goes unnoticed is up to the dead interval, not the hello: on Ethernet's defaults, 40 seconds. The Dead Time column in show ip ospf neighbor is that countdown, live.
OSPF gives a silent neighbour forty seconds' benefit of the doubt. Generous, for a protocol that recalculates the whole area in a heartbeat once it finally notices.
The default hello depends on the network type (section 4.5). You can set it from 1 to 65,535 seconds with ip ospf hello-interval, and changing it changes the default dead interval too. The dead interval has its own command, ip ospf dead-interval, also 1 to 65,535 seconds, and the guide's warning: keep it greater than the hello, or it can run out between two perfectly healthy hellos. Picture yourself in a situation where the smoke alarm is set to complain if it hasn't heard from its sensor for 8 seconds, and the sensor only checks in every 10: it goes off every few seconds with nothing on fire. Check both timers with show ip ospf interface (the guide filters it with | i Timer|line to show just the timer and interface lines: Hello 10, Dead 40, Wait 40, Retransmit 5, Example 8-13), and remember they must match on both ends for an adjacency to form at all. (That's 02-2's checklist.)
D2

The DR and BDR do more work than everyone else, keeping full adjacencies with every router on the segment, so the guide's advice is to put those roles on routers with the resources to spare, just like when you choose the friend with the big kitchen to host the family dinner. To do that, you need to know how the election runs.
It happens at the end of the 2-Way state, just before ExStart, and a router joining a segment whose hellos already name a DR and BDR simply accepts them. (The hello's DR and BDR fields carry the routers' interface addresses; the guide calls them RIDs here, but its own Table 8-3 and the RFC say addresses.) Any interface with priority 1 to 255 can become DR; the default is 1, and each router puts its RID and priority in its hellos. Highest priority wins; on a tie, the higher RID wins, and a router that hears a better candidate than itself starts naming that candidate in its own hellos. It acts kind of like a club electing a chairperson: the member with the strongest claim stands, seniority breaks a tie, and everyone ends up writing the same name on the ballot. Once all agree on a DR, everyone becomes adjacent with it. The BDR is chosen the same way, and the DR doesn't put itself forward as BDR. (RFC 2328 actually calculates the BDR first and promotes it if nobody has declared DR; for a normal start the result is the same.)
Then the rule that surprises everyone: no preemption. Once elected, the DR and BDR keep their roles. Only a failure, or a restart of the DR's or BDR's OSPF process, triggers an election for the missing role. A more qualified member joining the club next week doesn't unseat the chair.
The OSPF DR is the only elected official who can't be voted out by a better candidate. It has to fall over, or be switched off and on again.
That's why the wait timer exists. When hellos name no DR or BDR, a router waits before taking part, so everyone on the segment has a chance to start first. It lasts the dead interval by default and starts when OSPF starts on the interface; that's also why a router alone on a segment still becomes DR, just a little later. Have you ever noticed how the first people at a restaurant table wait for everyone before ordering? Otherwise the early arrivals choose for the whole table.
Check the result with show ip ospf interface brief (Example 8-14): R1's Gi0/2 is DR of a segment with nobody else on it, R1's Gi0/1 is DROTHER, and R3's Gi0/1 is BDR 3/3, fully adjacent with all three others. Only the DR and BDR become adjacent with everyone.
In the 02-2 sample, R4 won DR and R3 BDR: all priorities were 1, and they had the highest RIDs. Changing RIDs to move the DR is bad design; change the priority instead, higher than the current DR's. And because roles aren't preempted, the OSPF process may need restarting on the current DR or BDR before the change shows.
The command is ip ospf priority 0-255 on the interface. 0 takes the interface out of the election immediately; anything above 1 makes it more favourable than the defaults. If you scaled that down to a queue at a bakery, priority is your ticket number, and 0 means you've decided not to queue at all.
The guide's requirement (Figure 8-10): R1 must always be DR, and R4 must never be DR or BDR. So R4 gets priority 0 and R1 gets 100 (Example 8-15).
Predict before you read on: with R1 at 100 and R4 at 0, who is DR?
Here's what happens. Setting R4 to 0 makes it give up the DR role on the spot. R3, the BDR, is promoted to DR, and a new BDR is elected: R1, with its 100. So R1 ends up BDR, not DR. Picture yourself being promised the chair, the old chair resigning, and the deputy stepping up instead of you: you get the deputy's job. The guide's log on R4 shows the one adjacency that changes, %OSPF-5-ADJCHG: ... Nbr 192.168.1.1 on GigabitEthernet0/1 from LOADING to FULL: R4, now a DROTHER, goes full with R1 because R1 is now BDR, and every half-open neighbourship does the same. From R2 (Example 8-16): 192.168.1.1 100 FULL/BDR, 192.168.3.3 1 FULL/DR, 192.168.4.4 0 2WAY/DROTHER. That's normal: the DR role doesn't preempt.
R1 was given priority 100 and still got the deputy's job. OSPF respects priority, just not retrospectively.
Had all four routers started together with these priorities, R1 would simply have won, thanks to the wait timer. To finish the move, restart OSPF on the router holding the DR role: clear ip ospf process on R3 (Example 8-17), which asks Reset ALL OSPF processes? [no]: first. R3's neighbours all go from FULL to DOWN, Neighbor Down: Interface down or detached, R1 steps up from BDR to DR, and R3's own view afterwards shows 192.168.1.1 100 FULL/DR. In the guide's output R3 comes back as BDR (it's FULL with both DROTHERs). By the RFC's election order, R2 could equally have taken the BDR role if the others re-elected before R3 was back at 2-Way: which one wins depends on timing, and the guide's capture shows R3 (unconfirmed).
D3

Step 1 of 5 All priorities are 1, so the highest RIDs win: R4 is DR and R3 BDR. This is the 02-2 sample.

Step 2 of 5 R1 now has priority 100, higher than anyone. Nothing changes: no election is running, and the DR role isn’t preempted.

Step 3 of 5 Priority 0 takes R4 out at once. The BDR, R3, steps up to DR, and a new BDR is elected: R1, with its 100. R1 is BDR, not DR (Example 8-16).

Step 4 of 5 Restarting OSPF on R3 empties the DR’s chair: the BDR, R1, becomes DR. In the guide’s capture R3 comes back as BDR (Example 8-17); had the others re-elected before R3 was back at 2-Way, R2 could have taken it. That part is timing (unconfirmed).

Step 5 of 5 A fresh start with the same priorities gives the same result straight away: R1 DR, R3 BDR. Priority only matters at the moment of an election.
Some media carry more than two routers on a segment, Ethernet and Frame Relay among them, so a DR is useful there. Others, like serial links running HDLC or PPP, only ever have two, and a DR there would waste CPU. OSPF picks a network type from the media by default, you can override it, and Cisco's implementation has five:
| Type | Default on | DR/BDR in hellos | Hello / wait / dead (s) |
|---|---|---|---|
| Broadcast | Ethernet | yes | 10 / 40 / 40 |
| Non-broadcast | Frame Relay main interfaces and multipoint subinterfaces | yes | 30 / 120 / 120 |
| Point-to-point | Frame Relay point-to-point subinterfaces (and serial, GRE) | no | 10 / none / 40 (Table 8-9 prints a wait of 40) |
| Point-to-multipoint | nothing by default; advertises the interface as a /32 host route, hub-and-spoke | no | 30 / 120 / 120 |
| Loopback | loopback interfaces; advertised as a /32 | n/a | n/a |
Non-broadcast and point-to-multipoint are beyond the Enterprise Core exam's scope, says the guide, so the rest is about the other three.
Broadcast. More than two devices, and a broadcast sent out one interface reaches them all, which is why the guide prefers the full name, broadcast multi-access. It's the default on Ethernet, it needs a DR to keep LSA flooding under control, and its hello is 10 seconds; the guide says RFC 2328 defines that, though the RFC gives 10 seconds only as a sample value for a LAN. ip ospf network broadcast sets it explicitly. Think of it as a meeting: with six people in the room, somebody has to chair.
Point-to-point. Exactly two devices; no ARP, and broadcasts aren't the limiting factor. It's the default on serial interfaces (HDLC or PPP), GRE tunnels (04-2) and Frame Relay point-to-point subinterfaces. No DR, hello 10 seconds. The guide's serial pair (Figure 8-11, Example 8-18) needs no special commands at all. The proof: the interface shows Network Type POINT_TO_POINT, Cost: 64 (Example 8-19), and the neighbour shows FULL/ -, the hyphen where a role would be, with its priority shown as 0, since priority plays no part where there's no election (Example 8-20). Because there's no election and no wait timer, a point-to-point adjacency forms faster, so an Ethernet link with only two OSPF routers on it could be changed to point-to-point, says the guide, with ip ospf network point-to-point: faster adjacencies and a simpler SPF. It's basically like a phone call rather than a meeting: two people don't need a chairperson.
Continue the lesson
The whole lesson, with its drawings and its questions. The rest of this section and 9 more after it.








