3.5 Single-Area OSPFv2 — Configuration

Key Takeaways

  • The OSPF Router ID is chosen from: (1) manually configured, (2) highest loopback IP, (3) highest active interface IP.
  • The 'network' command with wildcard mask tells OSPF which interfaces to activate.
  • Passive interfaces receive OSPF routes but do not send Hello packets (used on LAN-facing interfaces).
  • On broadcast networks (Ethernet), a DR and BDR are elected to reduce OSPF overhead.
  • The DR is elected based on highest OSPF priority (default 1), then highest Router ID.
Last updated: March 2026

Single-Area OSPFv2 — Configuration

OSPF Router ID

Every OSPF router needs a unique Router ID (RID), which is a 32-bit number written in dotted decimal (like an IP address).

Router ID Selection Order

  1. Manually configured via router-id command (highest priority)
  2. Highest IP on any loopback interface (if no manual RID)
  3. Highest IP on any active physical interface (if no loopback)
Router(config)# router ospf 1
Router(config-router)# router-id 1.1.1.1           ! Best practice: set manually

On the Exam: If you change the Router ID, it does not take effect until OSPF is restarted (clear ip ospf process). The Router ID must be unique across all OSPF routers.

Basic OSPF Configuration

Step-by-Step Configuration

Router(config)# router ospf 1                                ! Process ID (locally significant)
Router(config-router)# router-id 1.1.1.1                     ! Set Router ID
Router(config-router)# network 192.168.10.0 0.0.0.255 area 0  ! Enable OSPF on matching interfaces
Router(config-router)# network 10.0.0.0 0.0.0.3 area 0        ! Point-to-point link
Router(config-router)# passive-interface GigabitEthernet0/1    ! Stop Hellos on LAN interface
Router(config-router)# auto-cost reference-bandwidth 10000     ! Fix cost for Gigabit links
Router(config-router)# default-information originate           ! Advertise default route

The Network Command and Wildcard Masks

The network command tells OSPF which interfaces to activate:

network <ip-address> <wildcard-mask> area <area-number>

Wildcard mask = inverse of subnet mask:

  • Subnet mask 255.255.255.0 → Wildcard 0.0.0.255
  • Subnet mask 255.255.255.252 → Wildcard 0.0.0.3
CommandEffect
network 192.168.10.0 0.0.0.255 area 0Activates interfaces with IP in 192.168.10.0/24
network 10.0.0.0 0.0.0.3 area 0Activates interfaces with IP in 10.0.0.0/30
network 0.0.0.0 255.255.255.255 area 0Activates ALL interfaces in Area 0

Alternative: Interface-Level OSPF Configuration

Router(config)# interface GigabitEthernet0/0
Router(config-if)# ip ospf 1 area 0              ! Enable OSPF directly on the interface

This is often clearer and less error-prone than using the network command.

Passive Interfaces

A passive interface participates in OSPF (its network is advertised) but does not send or receive Hello packets.

When to use passive interfaces:

  • LAN interfaces facing end users (no OSPF neighbors on that segment)
  • Interfaces connected to non-OSPF networks
Router(config-router)# passive-interface GigabitEthernet0/1     ! Specific interface
Router(config-router)# passive-interface default                ! All interfaces passive
Router(config-router)# no passive-interface GigabitEthernet0/0   ! Then enable specific ones

On the Exam: If two OSPF routers are directly connected but cannot form a neighbor adjacency, check if one side has a passive interface configured. Passive interfaces will not send Hellos.

DR/BDR Election (Broadcast Networks)

On broadcast multi-access networks (Ethernet), OSPF elects a Designated Router (DR) and a Backup Designated Router (BDR) to reduce the number of adjacencies and LSA flooding.

Why DR/BDR?

On a network with N routers, without DR/BDR:

  • Each router forms an adjacency with every other router: N×(N-1)/2 adjacencies
  • With 10 routers: 45 adjacencies

With DR/BDR:

  • Each router forms adjacencies only with the DR and BDR: 2 adjacencies per router
  • With 10 routers: 18 adjacencies (much less overhead)

DR/BDR Election Rules

  1. Highest OSPF priority wins (default priority = 1, range 0-255)
  2. If priorities are equal: Highest Router ID wins
  3. Priority 0 means the router will not participate in the election
  4. The election is non-preemptive — a new router with higher priority doesn't displace the current DR
Router(config-if)# ip ospf priority 100    ! Increase priority to win election
Router(config-if)# ip ospf priority 0      ! Exclude from DR/BDR election

Adjacency Types on Broadcast Networks

Router RelationshipForm Full Adjacency?
DR ↔ Every other routerYes (Full)
BDR ↔ Every other routerYes (Full)
DROther ↔ DROtherNo (stuck at 2-Way)
  • DR receives LSAs on 224.0.0.6 (AllDRouters) and floods them to 224.0.0.5 (AllSPFRouters)
  • BDR monitors the DR and takes over if the DR fails

Point-to-Point Networks

On point-to-point links (serial interfaces, or Ethernet configured as point-to-point), there is no DR/BDR election because there are only two routers.

Router(config-if)# ip ospf network point-to-point     ! Configure Ethernet as P2P

Advantages of point-to-point on Ethernet:

  • No DR/BDR election (faster adjacency formation)
  • No need to worry about DR failure
  • Simpler topology

On the Exam: Know that DR/BDR election only occurs on broadcast (and NBMA) network types, not on point-to-point links. Changing Ethernet interfaces to point-to-point is a common OSPF optimization.

OSPF Verification Commands

Router# show ip ospf                          ! OSPF process info, Router ID
Router# show ip ospf neighbor                  ! Neighbor status (Full, 2-Way, etc.)
Router# show ip ospf interface                 ! OSPF info per interface (cost, area, DR/BDR)
Router# show ip ospf interface brief           ! Quick summary
Router# show ip ospf database                  ! Link-state database
Router# show ip route ospf                     ! Only OSPF routes

Sample "show ip ospf neighbor" Output

Neighbor ID     Pri   State           Dead Time   Address         Interface
2.2.2.2           1   FULL/DR         00:00:35    10.0.0.2        Gi0/0
3.3.3.3           1   FULL/BDR        00:00:37    10.0.0.3        Gi0/0
4.4.4.4           1   2WAY/DROTHER    00:00:31    10.0.0.4        Gi0/0

OSPF Troubleshooting Checklist

ProblemCauseCommand to Check
No neighbor seenWrong area, passive interface, ACL blockingshow ip ospf interface, show ip ospf neighbor
Stuck in InitOne-way communication (Hello not reaching neighbor)show ip ospf neighbor, debug ip ospf hello
Stuck in ExStartMTU mismatchshow ip ospf interface (check MTU)
Route not in tableMissing network statementshow ip ospf interface brief
Wrong cost/pathReference bandwidth mismatchshow ip ospf interface (check cost)
Test Your Knowledge

What is the default OSPF Hello interval on a broadcast network (Ethernet)?

A
B
C
D
Test Your Knowledge

On a broadcast network with 5 OSPF routers, which router becomes the DR?

A
B
C
D
Test Your Knowledge

What is the purpose of a passive interface in OSPF?

A
B
C
D
Test Your Knowledge

How is the OSPF Router ID selected if no router-id command is configured and no loopback interfaces exist?

A
B
C
D