IP Routing · Topic 3 of 4

OSPFv2 and OSPFv3

Configure and verify single area OSPFv2 and OSPFv3: neighbor adjacencies, point to point and broadcast networks, DR and BDR election, router ID and neighbor output.

  • 6 min
  • Includes a diagram
In a nutshell
  • OSPF is link-state, uses cost, has AD 110 and runs in area 0 here.
  • Router ID order: manual, highest up loopback, highest active interface.
  • Hellos use 224.0.0.5 (OSPFv2) and FF02::5 (OSPFv3).

What it is

OSPF (Open Shortest Path First) is a dynamic routing protocol that lets routers find each other and learn routes automatically.

It is a link-state protocol. Routers share their links, so every router builds the same map of the area and runs the shortest path algorithm on it. The metric is cost, based on bandwidth, and the AD is 110.

OSPFv2 carries IPv4 routes. OSPFv3 carries IPv6 routes and works the same way. In a single area design, all routers are in area 0.

How it works

Routers pick an ID, become neighbors and, on shared segments, elect a DR.

Router ID

Every OSPF router needs a unique 32 bit ID, written like an IPv4 address. It is chosen in this order:

  1. A manually configured router-id.
  2. Otherwise, the highest IP address on an up loopback interface.
  3. Otherwise, the highest IP address on an active physical interface.

Setting it by hand is best practice. OSPFv3 also uses a 32 bit router ID, so a router with no IPv4 address needs router-id set by hand.

Becoming neighbors

Routers find each other by sending hello packets. OSPFv2 sends them to multicast 224.0.0.5, and OSPFv3 sends them to FF02::5.

R1router ID 1.1.1.1hello to all OSPF routersR2router ID 2.2.2.2

On broadcast and point to point links, hellos go out every 10 seconds, and a neighbor is declared dead after 40 seconds of silence. Non-broadcast network types use 30 and 120.

For two routers to become neighbors, these must agree:

  • the area
  • the hello and dead timers
  • the subnet and mask of the link (OSPFv2)
  • the MTU of the link

The router IDs must be different. OSPFv3 forms adjacencies over link-local addresses and runs per link, so the global prefix on the link is not what holds it together.

A neighbor moves through states:

StateMeaning
DownNo hello heard
InitA hello arrived, but this router's ID is not yet in it
2-WayEach router has seen itself in the other's hello
ExStart, Exchange, LoadingDatabases are being compared and exchanged
FullDatabases match, and the adjacency is complete

Network types, DR and BDR

Four routers on one Ethernet segment in area 0; the DR and BDR are fully adjacent to the others. On a point to point link only two routers share the segment. They become fully adjacent, and no election happens.

On a broadcast network, such as an Ethernet segment with several routers, OSPF elects a Designated Router (DR) and a Backup Designated Router (BDR). Every other router, a DROTHER, is Full only with the DR and BDR, and stays at 2-Way with other DROTHERs.

DROTHER 1FullDRcollects and sends updatesDROTHER 1FullBDRstandby for the DRDROTHER 12 Way onlyDROTHER 2

The election:

  • The highest OSPF priority wins DR (default 1), then the highest router ID. The runner up is BDR.
  • A priority of 0 means the router can never be DR or BDR.
  • The election is not pre-emptive. A better router that joins later waits until the DR fails or OSPF restarts.
Watch out

Two DROTHERs correctly stay at 2-Way with each other. That is not a fault.

Ethernet defaults to the broadcast type. For two routers on one link, set point to point on both ends to skip the election:

interface GigabitEthernet0/0
 ip ospf network point-to-point

Set priority with ip ospf priority (ipv6 ospf priority in OSPFv3).

Configuring OSPFv2

router ospf 1
 router-id 1.1.1.1
 network 10.1.1.0 0.0.0.255 area 0
 network 192.168.10.0 0.0.0.255 area 0
  • router ospf 1 starts the process. The process ID has only local meaning.
  • network ADDRESS WILDCARD area 0 enables OSPF on interfaces whose address falls in that range. It uses a wildcard mask, the inverse of a subnet mask.

You can also enable OSPF under the interface with ip ospf 1 area 0.

Configuring OSPFv3

OSPFv3 has no network command. You enable it on each interface:

ipv6 unicast-routing
ipv6 router ospf 1
 router-id 1.1.1.1
!
interface GigabitEthernet0/0
 ipv6 address 2001:db8:12::1/64
 ipv6 ospf 1 area 0

Point to point uses ipv6 ospf network point-to-point.

OSPFv3 sends hellos to FF02::5, and the DR and BDR listen on FF02::6 (OSPFv2 uses 224.0.0.5 and 224.0.0.6).

Verifying and reading the output

R1# show ip ospf neighbor
Neighbor ID     Pri   State           Dead Time   Address         Interface
2.2.2.2           1   FULL/DR         00:00:35    10.1.1.2        GigabitEthernet0/0

R1# show ipv6 ospf neighbor
Neighbor ID     Pri   State           Dead Time   Interface ID    Interface
2.2.2.2           1   FULL/DR         00:00:33    4               GigabitEthernet0/0

FULL/DR means the adjacency is complete and the neighbor is the DR. FULL/BDR means it is the BDR. The OSPFv3 output shows an interface ID where OSPFv2 shows an address.

Also useful: show ip route ospf and show ipv6 route ospf.

show ip ospf interface brief lists each OSPF interface with its area, cost and state (DR, BDR, DROTH or P2P).

Troubleshooting a missing neighbor

No neighbor listedOSPF on the interface?yesPassive interface?blocks hellosnoArea and timersmust matchokSubnet and MTUmust match
What you seeLikely cause
Neighbor absentOSPF not enabled, interface set passive, wrong area, mismatched timers or subnet
Stuck in InitHellos arrive in one direction only, such as an ACL blocking them
Stuck in ExStartMTU mismatch between the two ends
Both at 2-Way, no DRBoth routers set to priority 0

Common mistakes

These two errors are the usual ones.

Duplicate router IDs. Two routers with the same ID do not work properly together.

Using a subnet mask in the network command. It needs a wildcard mask.

What to remember for the exam

Eight facts cover single area OSPF.

  • OSPF is link-state, uses cost, has AD 110 and runs in area 0 here.
  • Router ID order: manual, highest up loopback, highest active interface.
  • Hellos use 224.0.0.5 (OSPFv2) and FF02::5 (OSPFv3).
  • Ethernet defaults: hello 10 seconds, dead 40 seconds.
  • Neighbors must agree on area, timers, subnet (OSPFv2) and MTU, and have unique router IDs.
  • DR election uses the highest priority, then the highest router ID. Priority 0 never wins, and the election is not pre-emptive.
  • DROTHERs staying at 2-Way with each other is normal.
  • OSPFv3 is enabled per interface with ipv6 ospf 1 area 0.
Exam tip

On a two router Ethernet link, set point to point to skip the DR election.

Check yourself

Work through these three prompts.

  • How is the OSPF router ID chosen when none is configured?

    The highest IP address on an up loopback interface, otherwise the highest IP address on an active physical interface.

  • Why do two routers on a broadcast segment show 2-Way instead of Full with each other?

    Both are DROTHERs. They become Full only with the DR and BDR, and 2-Way between DROTHERs is normal.

  • How do you enable OSPFv3 for IPv6 on an interface?

    Enable ipv6 unicast-routing, create the process with ipv6 router ospf 1, then use ipv6 ospf 1 area 0 on the interface.

Topic 3 of 4 in IP Routing

Test yourself on IP Routing

The full Cisco CCNA 200-301 v2.0 question bank has 1,242 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 Cisco. Vendor names, certification names and exam codes are trademarks of their respective owners and are used for identification only.