3.4 Configure and verify single-area OSPFv2

CCNA 200-301 v1.1 · 3.0 IP Connectivity

OSPF is a link-state protocol: every router in an area builds the same map of the network (the link-state database) and runs the SPF algorithm on it to find the lowest-cost path to each prefix. For a single area you need to get neighbors up, decide who is DR/BDR on shared segments, set a router ID, and read the routing table to prove it works.

What you must know

Neighbor adjacencies

Routers discover each other with Hello packets sent to the multicast address 224.0.0.5. Two routers on a link only form an adjacency if their hellos agree on the essentials.

Must matchWhy it matters
Area IDA neighbor in a different area on the same link is ignored.
Subnet and maskOn Ethernet the two interfaces must be in the same subnet.
Hello and dead timersDefaults are 10 s and 40 s on Ethernet and point-to-point links. Different values stop the adjacency.
AuthenticationType and key must be identical.
Stub-area flagBoth ends must agree on whether the area is a stub.

Router IDs must also be unique, and a mismatched interface MTU leaves the pair stuck while they exchange databases.

An adjacency climbs through these states:

StateMeaning
DownNo hello heard yet.
InitA hello was heard, but it does not yet list our router ID.
2-WayTwo-way communication confirmed. On a broadcast segment, routers that are neither DR nor BDR stay here with each other, and that is normal.
ExStart / ExchangeMaster and slave are chosen and database descriptions are swapped. A stuck pair here usually points to an MTU mismatch.
LoadingMissing link-state advertisements are requested.
FullDatabases are synchronised. Routes are calculated from here.

Point-to-point networks

On a point-to-point link there are only two routers, so there is no DR/BDR election. They go straight to Full. Serial and tunnel links default to this type; on Ethernet you can ask for it explicitly when exactly two routers share the cable, which also removes the election delay.

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

Broadcast networks and DR/BDR election

On a shared segment every router could form an adjacency with every other, which does not scale. OSPF elects a Designated Router (DR) and a Backup (BDR). Everyone else (DROthers) becomes Full only with the DR and BDR. Updates go to the DR at 224.0.0.6, and the DR floods them to 224.0.0.5.

  1. Highest interface priority wins (0 to 255, default 1).
  2. Ties go to the highest router ID.
  3. A priority of 0 means the router can never be DR or BDR.
interface GigabitEthernet0/0
 ip ospf priority 255   ! favour this router as DR
!
interface GigabitEthernet0/0
 ip ospf priority 0     ! never DR/BDR

Router ID

The router ID is a 32-bit number written like an IPv4 address that names the router inside OSPF. It is chosen in this order:

  1. A router-id configured under the OSPF process.
  2. Otherwise the highest IP address on a loopback interface.
  3. Otherwise the highest IP address on an active physical interface.

It is selected when the process starts. Adding a better loopback later changes nothing until the process is restarted.

router ospf 1
 router-id 1.1.1.1
!
R1# clear ip ospf process

Where to enable OSPF is the other half of getting started. A network statement uses a wildcard mask and enables OSPF on every interface whose address falls inside the range. It advertises the interface's own connected network, not the range you typed.

router ospf 1
 network 10.0.12.0 0.0.0.3 area 0
 passive-interface GigabitEthernet0/1
!
! or, per interface:
interface GigabitEthernet0/0
 ip ospf 1 area 0

Commands

show ip ospf neighborNeighbors, their state (for example FULL/DR) and the interface they are reached on.
show ip ospf interface briefWhich interfaces run OSPF, their area, cost, state (DR, BDR, P2P) and neighbor counts.
show ip route ospfOnly the OSPF routes. O is intra-area, O IA inter-area, O E1/E2 external.
show ip protocolsRouter ID, networks being advertised, passive interfaces and the administrative distance (110).
show ip ospf databaseThe link-state database the SPF algorithm runs on.
clear ip ospf processRestarts OSPF so a new router ID or new DR/BDR roles take effect.

Exam traps

Check yourself

Two routers on the same Ethernet segment show each other as 2-Way, not Full. Is something broken?
Not necessarily. On a broadcast network only the DR and BDR become Full with every router. Routers that are neither stay in 2-Way with each other. Check that each one is Full with the DR and BDR.
R1 has Loopback0 10.1.1.1 and Gi0/0 192.168.1.1, with no router-id command. What is its router ID? What happens if you then add Loopback1 10.9.9.9?
10.1.1.1, because a loopback beats a physical interface and 10.1.1.1 is the highest loopback at that moment. Adding Loopback1 changes nothing until the process is restarted with clear ip ospf process, or you configure router-id explicitly.
A new neighbor sits in ExStart. What do you check first?
The interface MTU on both ends (database descriptions exceed the smaller MTU), then duplicate router IDs.
How do you make R3 ineligible to be DR or BDR on a segment?
Set ip ospf priority 0 on its interface on that segment.
You enter network 10.0.12.0 0.0.0.3 area 0. Which interfaces start running OSPF, and what network is advertised?
Every interface whose IP address is inside 10.0.12.0 to 10.0.12.3. The interface's own connected network and mask are advertised, not the range you typed.

Labs

Try it live: Single-area OSPFv2

More topics in 3.0 IP Connectivity