OSPF explained: adjacencies, LSAs, areas and cost

Two routers, one cable, the link is up, OSPF is enabled on both sides, and still no route. The neighbour sits in ExStart and never moves. The cause is usually one number, and it is not the one you check first.

This page covers how OSPF builds its map, the eight neighbour states, the designated router, areas and LSA types, and the defaults that make Cisco, Huawei, Aruba and Juniper disagree about the same link.

Link state in one minute

OSPF is a link state protocol. Every router describes its own links in link state advertisements and floods them, so every router in an area holds the same database, the same map. Each router then runs the shortest path first algorithm on that map and builds its own tree of best routes.

OSPF runs directly over IP, protocol 89, and sends its hellos to the multicast address 224.0.0.5.

The router ID

Every router needs a 32 bit router ID, unique in the network. If you do not set one, each vendor picks it differently. Cisco, Huawei and Aruba take the highest loopback address, then the highest interface address. Juniper does the opposite: the lowest loopback, then the lowest physical address.

And once chosen, it only changes when the OSPF process restarts. Juniper's own advice is the right one for everybody: configure it explicitly.

Eight neighbour states

Two routers become neighbours step by step. Down. Init, when a hello arrives that does not list me yet. Two way, when each sees itself in the other's hello. Then ExStart, where they agree who leads the exchange, Exchange, where they describe their databases, Loading, where they request what they miss, and Full.

Before any of that, the hellos must agree on the subnet mask, the hello and dead intervals, the area and the stub flag. Any mismatch, and the packet is simply dropped.

The designated router

On a shared segment like Ethernet, routers do not all become fully adjacent with each other. They elect a designated router and a backup. The highest priority wins, then the highest router ID. Priority zero means never. The election is not preemptive: a router that joins later with a better priority waits.

The default priority is 1 on Cisco, Huawei and Aruba, and 128 on Juniper, so in a mixed segment the Juniper router wins unless you set priorities yourself.

Areas and LSA types

Large networks are cut into areas around the backbone, area zero. Type 1 router LSAs and type 2 network LSAs stay inside their area. Area border routers summarise into type 3. Type 4 points to the routers that inject external routes, and those externals travel as type 5 across the whole network.

In a not so stubby area, external routes enter as type 7 and are translated to type 5 at the border.

Stub, totally stubby, NSSA

A stub area refuses type 5 external routes and gets a default route from its border router instead. Totally stubby, a vendor term that is not in the standard, also blocks the type 3 summaries. A not so stubby area is a stub that still imports externals of its own, as type 7.

One catch, documented by Juniper, Aruba and Huawei in their own ways: the stub area only receives its default route when the border router is configured or connected the way it expects.

Cost, and the reference bandwidth trap

The standard leaves the interface cost to the administrator. Vendors compute it from a reference bandwidth divided by the link speed, and they do not agree on the reference. Cisco IOS XE, Huawei and Juniper use 100 megabits. Cisco NX-OS uses 40 gigabits. Aruba uses 100 gigabits.

The same gigabit link costs 1 on one switch, 40 on another and 100 on a third. In a mixed network, set the reference bandwidth to the same value everywhere.

Timers

Hello every 10 seconds, dead after 40, on broadcast and point to point links; 30 and 120 on non broadcast networks. Both sides must match exactly. Huawei adds a guard: it will not use a dead interval below 20 seconds unless you insist.

Authentication

OSPF authentication has three types in the original standard: none, a simple password in clear text, and a cryptographic MD5 digest. RFC 5709 added HMAC SHA.

Huawei marks simple, MD5 and HMAC MD5 as security risks in its own documentation and recommends HMAC SHA256. If your routers can do it, use the strongest algorithm both sides support.

Three classic failures

First, the neighbour stuck in ExStart or Exchange. Cisco calls an MTU mismatch the most common cause. Huawei behaves differently: by default it advertises an MTU of zero and skips the check, so the adjacency reaches Full, and then large updates can be lost and routes never learned. Huawei's fix is ospf mtu enable.

Second, a duplicate router ID: Cisco documents the symptoms, flooding warnings and the shortest path calculation running every few seconds.

Third, the stub area that never gets its default route.

Reading it on four vendors

The first question is always the neighbours. Cisco: show ip ospf neighbor. Huawei: display ospf peer brief. Aruba: show ip ospf neighbors. Juniper: show ospf neighbor.

Then the database, to check every router really holds the same map.

What NacTrack shows

Comparing databases router by router does not scale. NacTrack reads OSPF from every router over SSH, whatever the vendor, and shows neighbours, areas and the link state database on one page, with an analysis of the topology they describe.

See this protocol on your own network

NacTrack reads these protocols off your devices, over SSH and read-only.