Learn / Stage 3: Networking and CCNA / Lesson 3.8

$ lesson 3.8 --track ccna --domain routing

Single Area OSPFv2: Neighbours, DR/BDR, Cost and Troubleshooting

Static routes do not notice when a link dies. OSPF does. Learn how routers discover each other, agree on one map of the network, elect a DR on shared LANs, choose paths by cost, and how a single mismatched timer can quietly break it all.

  • Stage 3 Networking and CCNA
  • Level Intermediate to advanced
  • 70 min
  • 6 sections, quiz, lab

Start the lesson Jump to the lab

By the end of this lesson you can

  • Explain how OSPF neighbours form and build a shared LSDB
  • Configure single area OSPFv2 with a fixed router ID and passive interfaces
  • Predict DR and BDR election results and use point to point links
  • Read OSPF costs and equal cost paths in the routing table
  • Troubleshoot neighbours that will not reach FULL
3.8.01

Link state routing in plain words

Static routes from lesson 3.7 work until a link fails and nobody updates them. A dynamic routing protocol lets routers tell each other what they can reach and recalculate when something changes. OSPF (Open Shortest Path First) is the open standard one you will meet everywhere, and OSPFv2 carries IPv4.

  1. Each router finds neighbours by sending hello packets out of its OSPF interfaces (to multicast 224.0.0.5).
  2. Neighbours exchange LSAs (link state advertisements): descriptions of each router's links, subnets and costs.
  3. Every router in an area ends up with an identical link state database (LSDB), a map of the area.
  4. Each router runs the SPF (Dijkstra) algorithm on that map, with itself as the root, and installs the lowest cost paths in its routing table as O routes with administrative distance 110.

This lesson covers single area OSPF: everything is in area 0, the backbone. Multi area design exists for large networks and is beyond CCNA depth.

3.8.02

Becoming neighbours: states, timers and the must-match list

OSPF neighbour states from Down to FullDownInit2-WayExStartExchangeLoadingFullno hello yetheard a hellosaw my RID in theirsDR/BDR elected hereswap database summariesrequest missing LSAsdatabases match
Two routers move through these states. Full means their databases are synchronised. On a shared LAN, two routers that are neither DR nor BDR stop at 2-Way with each other, and that is normal.

Hellos go out every 10 seconds on Ethernet, and a neighbour is declared dead after 40 seconds of silence (the dead interval). Two routers only become neighbours when these match:

OSPF neighbour requirements
Must matchWhat happens if it does not
Area IDNo adjacency. The hello is ignored.
Subnet and mask on the linkNo adjacency on broadcast links.
Hello and dead intervalsNo adjacency. Changing one side drops an existing neighbour when the dead timer runs out.
Authentication settingsNo adjacency.
Stub area flagNo adjacency (not used in this lesson).
MTUNeighbours get stuck in ExStart or Exchange.

What does not need to match: the process ID in router ospf 1. It is local to the router. Router IDs must be unique.

Router ID (a 32 bit name written like an IPv4 address) is chosen in this order: the router-id command; else the highest IP on a loopback interface that is up; else the highest IP on an active physical interface. A router ID only changes when the process restarts, so after changing it you run clear ip ospf process.

3.8.03

DR and BDR on shared LANs, and why point to point skips it

If ten routers share one Ethernet segment and every pair formed a full adjacency, that would be 45 adjacencies flooding the same updates. OSPF instead elects a designated router (DR) and a backup (BDR). Everyone forms a Full adjacency with the DR and BDR; the others (DROTHERs) stay at 2-Way with each other.

  • Highest OSPF interface priority wins (default 1, range 0 to 255). Priority 0 means "never be DR or BDR".
  • On a tie, the highest router ID wins.
  • The election is not preemptive. A router that joins later with a higher priority does not take over. The DR changes only if it fails (then the BDR is promoted) or the OSPF processes are restarted.

A link with only two routers (a /30 between R1 and R3, say) gains nothing from an election. ip ospf network point-to-point on both ends removes the DR/BDR step and the wait that comes with it, so the adjacency forms faster. Both ends must use the same network type.

DR related commands
CommandWhereEffect
ip ospf priority 200InterfaceMakes this router the likely DR on that segment (at the next election).
ip ospf priority 0InterfaceNever DR or BDR on that segment.
ip ospf network point-to-pointInterface, both endsNo DR/BDR election; neighbour shows FULL/ -.
3.8.04

Configuring single area OSPF

R1(config)#interface Loopback0
R1(config-if)#ip address 1.1.1.1 255.255.255.255
R1(config-if)#exit
R1(config)#router ospf 1
R1(config-router)#router-id 1.1.1.1
R1(config-router)#network 172.16.100.0 0.0.0.255 area 0
R1(config-router)#network 10.0.13.0 0.0.0.3 area 0
R1(config-router)#network 192.168.1.0 0.0.0.255 area 0
R1(config-router)#network 1.1.1.1 0.0.0.0 area 0
R1(config-router)#passive-interface GigabitEthernet0/0/1
R1(config-router)#auto-cost reference-bandwidth 10000
! alternative to network statements, per interface:
R1(config)#interface GigabitEthernet0/0/1
R1(config-if)#ip ospf 1 area 0
  • A network statement does not advertise a prefix by itself. It says "run OSPF on every interface whose IP falls in this range", and those interfaces' subnets get advertised. It uses a wildcard mask: 0.0.0.255 for a /24, 0.0.0.3 for a /30, 0.0.0.0 for exactly one address.
  • passive-interface stops hellos on a LAN port but still advertises its subnet. Every user facing interface should be passive. passive-interface default followed by no passive-interface on router links is the safer habit.
  • default-information originate shares this router's default route with the rest of the area. Others see it as O*E2 0.0.0.0/0.
3.8.05

Cost: how OSPF picks the best path

OSPF's metric is cost, added up along the path. Interface cost = reference bandwidth / interface bandwidth, with a minimum of 1. The default reference is 100 Mb/s, which means FastEthernet, Gigabit and 10 Gigabit links all cost 1 and OSPF cannot tell them apart.

Interface cost by reference bandwidth
LinkCost, reference 100 (default)Cost, reference 10000
100 Mb/s1100
1 Gb/s110
10 Gb/s11

Fix it with auto-cost reference-bandwidth 10000 (in Mb/s) on every router, or set a link's cost directly with ip ospf cost N. In the routing table, [110/20] means AD 110 and total cost 20. If two paths have the same cost, OSPF installs both (up to 4 by default on IOS) and shares the load.

3.8.06

Practise on R1

R1's interfaces are already addressed. R2 and R3 are modelled by this console: R2 has already been given OSPF priority 200 on the shared LAN by a colleague, and R3's end of the point to point link is configured to match whatever you do. All three routers use the same reference bandwidth. Treat outputs as a close guide, not a real protocol run.

console: R1 (R1 OSPF console)

Missions 0/16

    Simplified IOS simulator in your browser. It teaches the commands; Packet Tracer and real gear have many more.

    Flashcards: do you remember?

    Tap a card to flip it. Try to answer in your head first; recalling is what makes it stick.

    Quick quiz

    Instant feedback on every answer. Score 70% or more to pass this lesson's quiz.

    Q1Two routers on the same link show no OSPF neighbour. Which mismatch causes this?

    Q2A router with priority 255 joins a LAN that already has a DR with priority 1. What happens?

    Q3Two DROTHERs on a shared LAN show 2WAY/DROTHER with each other. This is:

    Q4With the default reference bandwidth, what is the cost of a 10 Gb/s link?

    Q5Which wildcard matches the 10.0.13.0/30 subnet in a network statement?

    Q6Why make LAN interfaces passive?

    0 / 6

    Hands-on lab

    Cisco Packet Tracer lab55 minutessimulated network

    Packet Tracer lab 3.8: OSPF with DR election and a point to point link

    You need: Cisco Packet Tracer (free with a Cisco Networking Academy account; version 9.0.1 was the current download on the NetAcad Resource Hub when this lesson was written). Devices: 3 x ISR4331, 4 x 2960 (SW0 for the shared LAN plus one per LAN), 3 x PC-PT.

    Topology and addressing

    Lab 3.8 topology: R1, R2 and R3 share 172.16.100.0/24 through SW0, each has its own LAN, and R1 and R3 also have a point to point link 10.0.13.0/30Gi0/0/0 .1Gi0/0/0 .2Gi0/0/0 .3Gi0/0/1 .1Gi0/0/1 .1Gi0/0/1 .1Gi0/0/2 .1Gi0/0/2 .2SW0shared LANR1RID 1.1.1.1R2RID 2.2.2.2R3RID 3.3.3.3LAN1192.168.1.0/24LAN2192.168.2.0/24LAN3192.168.3.0/24
    R1, R2 and R3 Gi0/0/0 on SW0 (172.16.100.0/24). Each Gi0/0/1 to its own LAN switch. R1 Gi0/0/2 to R3 Gi0/0/2 (10.0.13.0/30).
    Addressing table
    DeviceInterfaceIPv4 address / prefixDefault gateway or note
    R1Gi0/0/0 / Gi0/0/1 / Gi0/0/2172.16.100.1/24 / 192.168.1.1/24 / 10.0.13.1/30Lo0 1.1.1.1/32
    R2Gi0/0/0 / Gi0/0/1172.16.100.2/24 / 192.168.2.1/24Lo0 2.2.2.2/32
    R3Gi0/0/0 / Gi0/0/1 / Gi0/0/2172.16.100.3/24 / 192.168.3.1/24 / 10.0.13.2/30Lo0 3.3.3.3/32
    PC1 / PC2 / PC3Fa0192.168.1.10 / 192.168.2.10 / 192.168.3.10 (/24)gateway .1 in each LAN
    1. Address everything, including loopbacks

      Use the table. Bring every router interface up with no shutdown and ping across each link before touching OSPF.

    2. OSPF on R1 (adapt the networks for R2 and R3)

      R1(config)#router ospf 1
      R1(config-router)#router-id 1.1.1.1
      R1(config-router)#network 172.16.100.0 0.0.0.255 area 0
      R1(config-router)#network 10.0.13.0 0.0.0.3 area 0
      R1(config-router)#network 192.168.1.0 0.0.0.255 area 0
      R1(config-router)#network 1.1.1.1 0.0.0.0 area 0
      R1(config-router)#passive-interface GigabitEthernet0/0/1
      R1(config-router)#auto-cost reference-bandwidth 10000
      R1(config)#interface GigabitEthernet0/0/2
      R1(config-if)#ip ospf network point-to-point

      Use the same reference bandwidth on all three routers and set point to point on R3's Gi0/0/2 too.

    3. Make R2 the DR

      R2(config)#interface GigabitEthernet0/0/0
      R2(config-if)#ip ospf priority 200
      R1#clear ip ospf process
      Reset ALL OSPF processes? [no]: yes

      Run clear ip ospf process on all three routers, because the election is not preemptive.

    4. Share a default route from R1

      R1(config)#interface Loopback1
      R1(config-if)#ip address 203.0.113.1 255.255.255.255
      R1(config-if)#exit
      R1(config)#ip route 0.0.0.0 0.0.0.0 Loopback1
      R1(config)#router ospf 1
      R1(config-router)#default-information originate
    5. Break and fix

      R3(config)#interface GigabitEthernet0/0/0
      R3(config-if)#ip ospf hello-interval 5
      ! wait for the dead timer, watch the ADJCHG messages, then:
      R3(config-if)#no ip ospf hello-interval
    6. Verify

      R1#show ip ospf neighbor
      R1#show ip ospf interface brief
      R1#show ip protocols
      R2#show ip route ospf
      R1#show ip ospf database

    You are done when: On R1, show ip ospf neighbor lists R2 as FULL/DR and R3 as FULL/BDR on Gi0/0/0, and R3 again as FULL/ - on Gi0/0/2. R2 and R3 show O routes to the other LANs and an O*E2 default route. PC1 pings PC2 and PC3.

    Packet Tracer limits and notes

    • You will not see 2WAY/DROTHER with only three routers. Add a fourth router to SW0 if you want to see two DROTHERs at 2-Way with each other.
    • show ip ospf interface brief is reported by a third party site as added in Packet Tracer 8.2. UNVERIFIED against Cisco release notes; use show ip ospf interface if it is missing.
    • ip ospf network point-to-point on Packet Tracer Ethernet interfaces is UNVERIFIED. If it is rejected, leave that link as broadcast: the two routers will elect a DR and BDR, and everything else still works.
    • The interface form ip ospf 1 area 0 is UNVERIFIED on every Packet Tracer image. The network statements above are the reliable way.
    • OSPF authentication in Packet Tracer is UNVERIFIED and outside this lesson's depth.
    • Packet Tracer simulates a subset of IOS. If a command here is rejected in your version, note it, skip that step and carry on; the concept still applies to real Cisco gear.

    Download the lab checklist (.txt) Print it or keep it open beside Packet Tracer.

    Key takeaways

    • OSPF routers share one map per area and each runs SPF on it.
    • Area, subnet, timers and authentication must match; the process ID does not.
    • DR and BDR: highest priority then router ID, and the election is not preemptive.
    • Raise the reference bandwidth on every router so fast links get different costs.
    • Make user facing interfaces passive, and treat an unexpected new neighbour as an incident.

    Finished the sections, quiz and lab? Mark the lesson complete. Progress is saved only in this browser.