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
- List what must match before two routers become OSPF neighbors, and name the states they pass through on the way to
Full. - Enable OSPF with a
networkstatement or with interface-levelip ospf ... area, and explain what each actually does. - Predict who wins a DR/BDR election and how to influence it with the interface priority.
- Say how a router ID is chosen and why changing it does not take effect immediately.
- Read
show ip ospf neighbor,show ip ospf interface briefandshow ip route ospfto prove adjacencies and routes.
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 match | Why it matters |
|---|---|
| Area ID | A neighbor in a different area on the same link is ignored. |
| Subnet and mask | On Ethernet the two interfaces must be in the same subnet. |
| Hello and dead timers | Defaults are 10 s and 40 s on Ethernet and point-to-point links. Different values stop the adjacency. |
| Authentication | Type and key must be identical. |
| Stub-area flag | Both 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:
| State | Meaning |
|---|---|
| Down | No hello heard yet. |
| Init | A hello was heard, but it does not yet list our router ID. |
| 2-Way | Two-way communication confirmed. On a broadcast segment, routers that are neither DR nor BDR stay here with each other, and that is normal. |
| ExStart / Exchange | Master and slave are chosen and database descriptions are swapped. A stuck pair here usually points to an MTU mismatch. |
| Loading | Missing link-state advertisements are requested. |
| Full | Databases 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-pointBroadcast 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.
- Highest interface priority wins (0 to 255, default 1).
- Ties go to the highest router ID.
- 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/BDRRouter 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:
- A
router-idconfigured under the OSPF process. - Otherwise the highest IP address on a loopback interface.
- 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 processWhere 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 0Commands
show ip ospf neighbor | Neighbors, their state (for example FULL/DR) and the interface they are reached on. |
show ip ospf interface brief | Which interfaces run OSPF, their area, cost, state (DR, BDR, P2P) and neighbor counts. |
show ip route ospf | Only the OSPF routes. O is intra-area, O IA inter-area, O E1/E2 external. |
show ip protocols | Router ID, networks being advertised, passive interfaces and the administrative distance (110). |
show ip ospf database | The link-state database the SPF algorithm runs on. |
clear ip ospf process | Restarts OSPF so a new router ID or new DR/BDR roles take effect. |
Exam traps
- Two DROthers sitting in 2-Way with each other is correct on a broadcast network. Do not "fix" it.
- A neighbor stuck in ExStart or Exchange is usually an MTU mismatch. Init usually means hellos only travel one way (a filter, or mismatched settings).
- The OSPF process ID is local to the router and does not need to match between neighbors. The area ID does.
passive-interfacestops hellos on that interface, so no adjacency forms there, but the connected network is still advertised.- The
networkcommand takes a wildcard mask (0.0.0.3), not a subnet mask (255.255.255.252). - Cost is based on a 100 Mbps reference bandwidth by default, so FastEthernet, Gigabit and faster links all cost 1 until
auto-cost reference-bandwidthis raised.
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 configurerouter-idexplicitly. - 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 0on 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