Home / Blogs / OSPF Explained: A Complete Guide with Concepts, CLI Commands and Outputs
Networking

OSPF Explained: A Complete Guide with Concepts, CLI Commands and Outputs

What Is OSPF? OSPF is a link-state dynamic routing protocol used inside a single organization's network (an Interior Gateway Protocol, or IGP). Routers running OSPF exchange information about their links, and each router builds the same map of the network. Each router then calculates the best path to every destination on its own.

On This Page · View TopicsOSPF Explained: A Complete Guide with ConceptsCore OSPF Mechanics

OSPF Explained: A Complete Guide with Concepts

Open Shortest Path First (OSPF) is a standards-based link-state interior gateway protocol (IGP) widely used in enterprise and campus networks. Unlike distance-vector protocols that rely on hop counts and periodic full-table updates, OSPF builds a complete topological map—the Link-State Database (LSDB)—and runs Dijkstra’s Shortest Path First (SPF) algorithm to compute loop-free best paths based on link cost.

cisco
code/configuration

R1(config)# router ospf 1
R1(config-router)# router-id 1.1.1.1
R1(config-router)# network 10.0.12.0 0.0.0.255 area 0
R1(config-router)# network 192.168.1.0 0.0.0.255 area 0
R1(config-router)# passive-interface GigabitEthernet0/1
R1(config-router)# exit
●   R2# show ip ospf neighbor
Neighbor ID     Pri   State           Dead Time   Address         Interface
1.1.1.1           1   FULL/BDR        00:00:34    10.0.12.1       GigabitEthernet0/0
3.3.3.3           1   FULL/DR         00:00:37    10.0.23.3       GigabitEthernet0/1

Core OSPF Mechanics

OSPF establishes adjacencies, synchronises topology data, and selects routes through four main processes:Neighbor Discovery (Hello Packets): Routers send Hello packets to multicast address 224.0.0.5 (all OSPF routers) on active interfaces. Adjacency forms when Hello/Dead intervals, Area ID, subnet mask (on broadcast/point-to-point links), and authentication match.Database Synchronisation (LSA Exchange): Adjacent routers exchange Link-State Advertisements (LSAs) so every router within an area shares an identical LSDB.SPF Calculation: Each router treats itself as the root of an SPF tree and installs the lowest-cost path into the routing table. Interface cost defaults to $\text{Reference Bandwidth} / \text{Interface Bandwidth}$.DR and BDR Election: On broadcast multi-access networks such as Ethernet, OSPF elects a Designated Router (DR) and Backup Designated Router (BDR) to reduce LSA flooding overhead and adjacency count.