Routelearn.net
Course menu

Course 9: OSPFLesson 1.1 (1 of 4 in this course)62 of 91 in the CCNA series

OSPF neighbours and adjacencies

Hello packets, the neighbour states from Down to Full, and the settings that must match for routers to become neighbours.

Intermediate · 12 min read

OSPF neighbour is another OSPF router on the same link whose hello packets have been received and whose key settings, such as area, subnet, hello and dead timers and authentication, match. When two neighbours also synchronise their link-state databases, they reach the Full state and are called adjacent.

In simple terms: Two routers have to meet and agree on a few basic settings before they will share routes. Once they agree, they swap their maps of the network.

A real-life situation

You have enabled OSPF on R1 and R2 in the lab. R1 learns every route from R2 within seconds. Then a colleague changes the hello timer on R2's Gi0/0 to 5 seconds "to make it faster". Forty seconds later R1 logs that its neighbour is down, and all the OSPF routes through R2 vanish. Nothing is wrong with the cable. The two routers simply stopped agreeing on how to talk. This lesson explains what that agreement is and how it forms.

If you have not met OSPF yet, start with the OSPF overview. It introduces link-state routing, the LSDB, SPF and cost. This lesson goes one level deeper into the first job OSPF does: finding neighbours.

Gi0/2Gi0/1 .1.2 Gi0/010.0.12.0/30Gi0/1 .1.2 Gi0/010.0.23.0/30Gi0/0Gi0/2Gi0/1ISP203.0.113.1R1RID 1.1.1.1R2RID 2.2.2.2R3RID 3.3.3.3LAN 1192.168.1.0/24LAN 2192.168.2.0/24LAN 3192.168.3.0/24
  1. 1. R1 and R2 send hellos on 10.0.12.0/30. Each router multicasts a hello to 224.0.0.5 every 10 seconds out of Gi0/1 (R1) and Gi0/0 (R2).
  2. 2. R2 and R3 do the same on 10.0.23.0/30. Hellos never leave the link they are sent on: they are only for routers on the same subnet.
  3. 3. Not towards the LANs (once configured as passive). There are no routers on LAN 1, 2 or 3, so later in the course you stop hellos there with passive-interface.

What an OSPF neighbour is

An OSPF neighbour is another OSPF router on the same link that your router has heard from, and that agrees with it on a few basic settings. Routers keep a list of these in the neighbour table. OSPF only shares routing information with neighbours. No neighbour, no routes.

There is a second, stronger relationship called an adjacency. Two routers are adjacent when they have also copied each other's link-state database (the LSDB, the map of the network). Adjacent routers end in the Full state. On point-to-point links every neighbour becomes adjacent. On shared Ethernet segments some neighbours deliberately stop before that; the lesson on DR/BDR election and network types explains why.

The five OSPF packet types

OSPF does not use TCP or UDP. It sits directly on top of IP with IP protocol number 89. It has its own reliability: updates are acknowledged and resent if needed. There are five packet types:

TypeNameWhat it does
1HelloFinds neighbours and keeps them alive. Carries the settings that must match.
2DBD (database description)A summary of the LSAs a router holds, like a table of contents.
3LSR (link-state request)"Please send me these LSAs, I don't have them."
4LSU (link-state update)Carries the full LSAs (link-state advertisements).
5LSAckConfirms that an LSU arrived.

What is inside a hello

Every OSPF packet starts with the same header, which names the sender's router ID (a 32-bit name written like an IP address, for example 1.1.1.1) and the area. A hello then adds the fields below. The highlighted ones must match on both routers, or they will never become neighbours.

Version8 bits2
Type8 bits1 = Hello
Packet length16 bits
Router ID32 bitsunique name of the sender
Area ID32 bits0.0.0.0 for area 0
Checksum16 bits
Auth type16 bits
Authentication64 bits
Network mask32 bits
Hello interval16 bits
Options8 bitsincl. stub flag
Priority8 bitsfor DR election
Dead interval32 bits
Designated router32 bits
Backup designated router32 bits
Neighbour router IDs4 bytes eachevery router ID heard on this link
OSPFv2 common header (first four rows) followed by the hello body. Highlighted fields must agree between neighbours (the network mask is checked on Ethernet, not on point-to-point links).

The last field matters most for the states below. A router lists every router ID it has heard hellos from on that link. When R2 sees its own router ID in R1's hello, it knows the conversation works in both directions.

Why it works this way

Link-state routing only works if every router in an area has an identical map. If two routers disagreed on the area, or one expected hellos twice as often as the other sent them, they would keep timing each other out or build different maps. So OSPF checks the important settings in every hello, before any routing information is shared. It is strict on purpose: a neighbour that does not match is ignored rather than half-trusted.

The hello interval is how often hellos are sent. The dead interval is how long a router waits without a hello before it declares the neighbour dead. Defaults on Ethernet and point-to-point links are 10 and 40 seconds (dead = 4 × hello). Hellos keep flowing for as long as the routers run; they are the "I'm still here" heartbeat.

How it works: the neighbour states

Two routers move through a fixed series of states. You will see these names in show ip ospf neighbor, so knowing them tells you exactly where a problem is.

Down
No hello heard yet (or the dead timer expired).
Init
A hello arrived, but it does not list my router ID yet.
2-Way
I see my own router ID in its hello. Two-way talk works. DR/BDR election happens here on Ethernet.
ExStart
The two routers agree who leads the exchange (master = higher router ID) and the starting sequence number.
Exchange
They swap DBD packets: summaries of every LSA they hold.
Loading
Each asks for what it is missing (LSR) and receives it (LSU, then LSAck).
Full
Databases match. The routers are adjacent and SPF can run.
OSPF neighbour states on an Ethernet or point-to-point link. A healthy adjacency ends in Full; neighbours that are not meant to be adjacent stop at 2-Way.

Here is the same process as a message exchange between R1 and R2 on the 10.0.12.0/30 link:

Step 1 of 7 · Hello (neighbours: none)
R1
Gi0/1 10.0.12.1 · RID 1.1.1.1
R2
Gi0/0 10.0.12.2 · RID 2.2.2.2

1. Hello (neighbours: none) · To 224.0.0.5

R1 announces itself. R2 receives it and moves R1 to Init: it has heard R1, but R1 has not heard R2 yet.

Tap this step's arrow for the details.

End result
State:
FULL on both routers
LSDB:
identical
Next:
each router runs SPF
R1 (1.1.1.1) and R2 (2.2.2.2) go from Down to Full.

After Full, the routers keep sending hellos. When something changes, such as a link going down, the router that notices sends an LSU describing the change, neighbours acknowledge it and pass it on, and every router reruns SPF. Each LSA is also refreshed every 30 minutes even if nothing changes, so stale information never lives forever.

What must match to become neighbours

Two routers on the same link become neighbours only if all of these agree:

SettingWhy it mattersWhere you set it
Area IDBoth ends of a link must be in the same area.network ... area 0 or ip ospf 1 area 0
Subnet and maskBoth interfaces must be in the same subnet (mask checked on Ethernet).ip address
Hello and dead intervalsMust be exactly equal, not just "compatible".ip ospf hello-interval, ip ospf dead-interval
AuthenticationSame type and same key, if used.ip ospf authentication, ip ospf message-digest-key
Stub area flagBoth must agree whether the area is a stub (beyond CCNA detail).area 1 stub (area 0 can never be a stub)

Three more conditions are not in the hello check list but still break things:

  • Unique router IDs. Two routers with the same router ID will not form a working adjacency, and the router logs a duplicate router ID message.
  • Matching IP MTU. The MTU is carried in DBD packets. If it differs, the routers get stuck in ExStart or Exchange.
  • Not passive. A passive interface sends no hellos and ignores the ones it receives, so it can never form a neighbour.

💡 The process ID (the 1 in router ospf 1) does not need to match. It only identifies the OSPF process inside one router.

How to configure the neighbour-related settings

Most of the time you leave the timers at their defaults. The full OSPF setup is covered in Configuring single-area OSPFv2. These are the interface commands that affect neighbours directly:

interface GigabitEthernet0/1 ip ospf hello-interval 5 ip ospf dead-interval 20

Interface configuration on R1. Changing the hello interval also changes the dead interval to 4 × hello automatically, but setting both makes the intent obvious. Configure the same values on R2's Gi0/0, or the neighbourship drops.

interface GigabitEthernet0/1 no ip ospf hello-interval no ip ospf dead-interval

Return to the defaults (10 and 40 seconds on Ethernet).

A full example with matching timers on both sides of the R1–R2 link:

! R1 router ospf 1 router-id 1.1.1.1 network 10.0.12.0 0.0.0.3 area 0 ! interface GigabitEthernet0/1 ip address 10.0.12.1 255.255.255.252 ip ospf hello-interval 5 ip ospf dead-interval 20 ! R2 router ospf 1 router-id 2.2.2.2 network 10.0.12.0 0.0.0.3 area 0 ! interface GigabitEthernet0/0 ip address 10.0.12.2 255.255.255.252 ip ospf hello-interval 5 ip ospf dead-interval 20

Both ends of the link agree on area 0, subnet 10.0.12.0/30 and 5/20-second timers.

How to verify it

Example output · based on Cisco documentation; exact format varies by platform and software version
R1#show ip ospf neighbor
Neighbor ID     Pri   State           Dead Time   Address         Interface
2.2.2.2           1   FULL/DR         00:00:17    10.0.12.2       GigabitEthernet0/1
Neighbor ID is R2's router ID, not an IP address. FULL is the state; /DR is R2's role on this Ethernet link. Dead Time counts down from 20 (the new dead interval) and jumps back each time a hello arrives. Address is R2's interface IP.
Example output · based on Cisco documentation; exact format varies by platform and software version
R1#show ip ospf interface GigabitEthernet0/1
GigabitEthernet0/1 is up, line protocol is up
  Internet Address 10.0.12.1/30, Area 0, Attached via Network Statement
  Process ID 1, Router ID 1.1.1.1, Network Type BROADCAST, Cost: 1
  ...
  Transmit Delay is 1 sec, State BDR, Priority 1
  Designated Router (ID) 2.2.2.2, Interface address 10.0.12.2
  Backup Designated router (ID) 1.1.1.1, Interface address 10.0.12.1
  Timer intervals configured, Hello 5, Dead 20, Wait 20, Retransmit 5
    Hello due in 00:00:02
  ...
  Neighbor Count is 1, Adjacent neighbor count is 1
    Adjacent with neighbor 2.2.2.2  (Designated Router)
The timer line shows the values this interface uses, and which must match the neighbour. The last lines show how many neighbours were found and how many are fully adjacent. Lines shown as ... were left out.

If the state is stuck or the table is empty, the router often tells you why in its log. You can also watch hellos arrive with a debug (use debugs carefully on busy production routers):

debug ip ospf hello

Shows each hello sent and received, and reports mismatched parameters. Turn it off with undebug all.

Example output · based on Cisco documentation; exact format varies by platform and software version
OSPF: Mismatched hello parameters from 10.0.12.2
OSPF: Dead R 40 C 20, Hello R 10 C 5  Mask R 255.255.255.252 C 255.255.255.252
R is what was received from the neighbour, C is what is configured here. R2 is still on 10/40 while R1 uses 5/20, so they cannot be neighbours. The exact wording differs between IOS versions.

What goes wrong and how to troubleshoot it

The state a neighbour is stuck in points straight at the cause:

What you seeLikely causeCheck with
No neighbour at allInterface not in OSPF, passive, down, area or timer or subnet mismatch, authentication mismatch, an ACL blocking OSPFshow ip ospf interface brief, show ip protocols, logs
Stuck in InitHellos only arrive one way: for example an ACL drops them inbound on the other routerACLs on both ends, debug ip ospf hello
2-Way between two DROthersNormal on Ethernet, not a faultshow ip ospf neighbor (look for DROTHER)
Stuck in ExStart / ExchangeIP MTU mismatch, or a duplicate router IDshow interfaces (MTU), show ip ospf
Flapping between Full and DownDead timer too short for a lossy link, or an unstable linkshow ip ospf interface, interface error counters

Verifying and troubleshooting OSPF walks through each of these with the commands to fix them.

Common mistakes

  • Thinking the process ID must match. It doesn't; the area does.
  • Changing the hello interval on one side only. The routers do not negotiate: they simply refuse each other.
  • Reading the Neighbor ID column as an IP address. It is the router ID. The interface IP is in the Address column.
  • Treating 2-WAY/DROTHER as a fault. Between two DROthers on Ethernet it is exactly what should happen.
  • Making the LAN interface passive and then wondering why a router on that LAN never becomes a neighbour.

💡 Exam tip: know the neighbour states in order (Down, Init, 2-Way, ExStart, Exchange, Loading, Full), and the settings that must match: area, subnet, hello/dead timers and authentication, plus unique router IDs and matching MTU. Expect questions like "R1 and R2 are not neighbours, which change fixes it?", where the answer is often a timer or area mismatch and a distractor is a different process ID. Remember 224.0.0.5 and 224.0.0.6 and the 10/40 default timers.

Key takeaways

✅ Key takeaways
  • Hellos (to 224.0.0.5, every 10 s on Ethernet) find neighbours and keep them alive; 40 s of silence kills the neighbour.
  • Neighbours must agree on area, subnet, hello/dead timers and authentication; router IDs must be unique.
  • States: Down → Init → 2-Way → ExStart → Exchange → Loading → Full.
  • DBD, LSR, LSU and LSAck synchronise the LSDB; Full means the databases match.
  • Verify with show ip ospf neighbor and show ip ospf interface.

Check yourself

Predict · scenario 1

R1 uses router ospf 1 and R2 uses router ospf 20. Area, subnet and timers all match on their shared link. What happens?

Predict · scenario 2

show ip ospf neighbor on R1 shows R2 in the INIT state and never moves on. What does that tell you?

Predict · scenario 3

R1's Gi0/1 has hello 10 / dead 40. R2's Gi0/0 has hello 10 / dead 30. What happens?

Predict · scenario 4

Two routers are stuck in EXSTART. Hellos are fine. What is the classic cause?

Predict · scenario 5

Which OSPF packet does a router send to ask for LSAs it saw in its neighbour's DBD but does not have?

FAQ

What is the difference between an OSPF neighbour and an adjacency?
A neighbour is a router you have exchanged hellos with and that agrees on the key settings (2-Way state). An adjacency is a neighbour you have also synchronised your link-state database with, which ends in the Full state. On Ethernet, two ordinary routers (DROthers) stay neighbours at 2-Way without becoming adjacent.
Do OSPF process IDs have to match between routers?
No. The number in router ospf 1 is only meaningful on the local router. Two routers using process 1 and process 10 can still become neighbours. The area, timers, subnet and authentication are what must match.
How quickly does OSPF notice that a neighbour has gone?
If the interface goes down, straight away. If the link stays up but the neighbour stops sending hellos, OSPF waits for the dead interval, which is 40 seconds by default on Ethernet and point-to-point links.
Which IP protocol and addresses does OSPF use?
OSPF runs directly over IP as protocol number 89, not over TCP or UDP. Hellos go to the multicast address 224.0.0.5 (all OSPF routers). Updates towards the DR and BDR on a shared LAN go to 224.0.0.6.