OSPF fundamentals recap
OSPF is a link-state routing protocol that builds a complete map of the network topology in each router's Link-State Database (LSDB). Routers exchange Link-State Advertisements (LSAs) describing their directly connected links. Each router runs the Dijkstra SPF algorithm on its LSDB to calculate the shortest path to every destination.
OSPF uses multicast for hello packets and LSA flooding: 224.0.0.5 (all OSPF routers) and 224.0.0.6 (all Designated Routers). OSPF runs directly over IP protocol number 89 — not TCP or UDP. OSPF areas allow large networks to be divided into smaller domains that limit LSA flooding scope. Area 0 (backbone area) must connect all other areas.
Router ID selection
Every OSPF router has a Router ID (RID) — a 32-bit number written in dotted decimal format that uniquely identifies it in the OSPF domain. The RID is not an IP address used for routing — it's an identifier. However, it is selected using IP address rules.
RID selection order: (1) Manually configured RID with `router-id <x.x.x.x>` — always preferred. (2) Highest loopback interface IP address. (3) Highest active physical interface IP address. The key word is 'highest' — not the first configured, not the management interface, but the numerically highest IP.
Always configure the RID manually in production. RID instability (changing because an interface came up with a higher IP) causes OSPF reconvergence. Loopback interfaces are UP/UP as long as the router is running — they provide a stable RID source even if physical interfaces go down.
DR and BDR election on broadcast networks
On multi-access broadcast networks (Ethernet), all OSPF routers would form adjacencies with every other router, resulting in N*(N-1)/2 adjacencies. For 5 routers, that's 10 full adjacencies, each maintaining synchronized LSDBs. This doesn't scale.
OSPF solves this with Designated Router (DR) and Backup Designated Router (BDR) election. All routers form full adjacency only with the DR and BDR. Other routers (DROther) form 2-way relationships with each other but don't fully synchronize LSDBs. LSAs are sent to 224.0.0.6 (AllDRRouters) and the DR redistributes to 224.0.0.5 (AllSPFRouters).
DR/BDR election: the router with the highest OSPF interface priority wins DR (default priority = 1). Ties are broken by Router ID. Priority 0 means the router never becomes DR or BDR — useful to prevent access layer switches from becoming DR.
Critical point: DR/BDR election is non-preemptive. Once elected, a DR keeps its role until it fails, even if a router with a higher priority/RID comes online later. To force a new election, the existing DR must be removed from the network.
Neighbor adjacency states
OSPF neighbors progress through states before full adjacency. The states: Down → Init → 2-Way → Exstart → Exchange → Loading → Full.
Down: no hellos received. Init: hello received, but our router ID isn't in the neighbor's hello. 2-Way: bidirectional communication confirmed (both Router IDs in each other's hellos); DR/BDR election occurs at this state. Exstart: master/slave relationship established for LSDB exchange. Exchange: routers exchange Database Description (DBD) packets summarizing their LSDB. Loading: one router requests LSAs it's missing. Full: LSDBs are synchronized — full adjacency achieved.
On broadcast networks, DROther routers only reach Full state with the DR and BDR. With other DROthers they remain at 2-Way. On point-to-point links, there is no DR/BDR — both routers reach Full state directly.
A stuck neighbor (not reaching Full) is a common CCNA troubleshooting scenario. Causes: MTU mismatch (Exchange/Loading stuck), area ID mismatch, authentication mismatch, hello/dead timer mismatch, or duplicate Router IDs.
OSPF network types
OSPF network type determines whether DR/BDR election occurs and how hellos are sent. The two most important: Broadcast (default on Ethernet) — uses multicast hellos, elects DR/BDR. Point-to-Point (default on serial links and recommended on point-to-point Ethernet links) — no DR/BDR, uses multicast hellos, both routers reach Full adjacency directly.
On point-to-point links, DR/BDR election is unnecessary and wastes convergence time. Configure `ip ospf network point-to-point` on both ends of a point-to-point Ethernet link to skip DR/BDR election and speed up adjacency formation.
OSPFv3 is OSPF for IPv6. The configuration is similar but uses IPv6 addresses and the `ipv6 ospf` command set. OSPFv3 uses link-local addresses as the source for hello packets and supports multiple address families in newer implementations.