OSPF is a link-state routing protocol used to exchange routes within an autonomous system. This guide has OSPF explained through its core building blocks: areas, Link-State Advertisements (LSAs), neighbour formation, route calculation and Cisco IOS configuration.
Before practising OSPF, you should be comfortable with IPv4 networks, subnet masks and wildcard masks. Review how IP addressing and CIDR work if you need to strengthen those foundations.
What is OSPF and how does it work?
Open Shortest Path First, or OSPF, is an open-standard Interior Gateway Protocol that uses link-state information to calculate the best path. Routers build a shared Link-State Database and run the Shortest Path First algorithm to install routes in the routing table.
OSPF operation can be understood as a sequence:
- Routers send Hello packets to discover neighbours.
- Compatible neighbours form adjacencies.
- Adjacent routers exchange LSAs.
- Each router builds a Link-State Database, or LSDB.
- The router runs the SPF algorithm with itself as the root.
- The best routes are installed in the routing table.
OSPF uses IP protocol number 89; it does not use TCP or UDP. OSPFv2, used for IPv4, commonly sends packets to multicast addresses 224.0.0.5 for all OSPF routers and 224.0.0.6 for designated routers on supported network types.
The default OSPF administrative distance on Cisco IOS is 110. Path selection uses cost, which is commonly calculated as:
OSPF cost = reference bandwidth / interface bandwidthCisco IOS traditionally uses a reference bandwidth of 100 Mbps. This makes many modern high-speed interfaces appear with the same cost, so production networks often set a higher reference bandwidth consistently on every OSPF router.
router ospf 10
auto-cost reference-bandwidth 10000The value is in Mbps. In this example, 10000 represents 10 Gbps.
How do OSPF areas work?
OSPF areas divide a routing domain into smaller link-state databases, reducing the amount of flooding and SPF processing required on every router. Area 0 is the backbone, and normal inter-area traffic must pass through it.
A router with all OSPF interfaces in one area is an internal router. A router connecting Area 0 to another area is an Area Border Router, or ABR. A router redistributing routes from another routing protocol or source is an Autonomous System Boundary Router, or ASBR.
Diagram in words
Imagine the following topology from left to right:
LAN A -- R1 -- Area 0 -- R2 -- Area 10 -- R3 -- LAN B
|
R2 is the ABRR1 has interfaces only in Area 0. R3 has interfaces only in Area 10. R2 has one interface in Area 0 and another in Area 10, so it maintains a separate LSDB for each area and advertises inter-area reachability.
Common OSPF area types
| Area type | External Type 5 LSAs | Typical purpose |
|---|---|---|
| Backbone Area 0 | Allowed | Connects other OSPF areas |
| Standard area | Allowed | Normal OSPF operation |
| Stub area | Blocked | Reduces external routing information; ABR supplies a default route |
| Totally stubby area | Blocked | Cisco extension that also suppresses most inter-area summary routes |
| NSSA | Replaced by Type 7 inside the area | Allows limited redistribution within a stub-like area |
| Totally NSSA | Type 7 allowed locally | Combines NSSA redistribution with stronger summary suppression |
All routers sharing an OSPF link must agree on the area ID and relevant area options. A stub-area mismatch, for example, prevents neighbour formation.
For CCNA-level labs covering OSPF configuration and verification, see the CCNA course. Multi-area design, route filtering and advanced OSPF behaviour are developed further in the CCNP Enterprise course.
What are OSPF LSA types?
An LSA is a structured description of a router, network or reachable prefix that OSPF floods through the routing domain. Different LSA types have different creators, contents and flooding scopes.
The LSDB is not the same as the routing table. The LSDB contains topology information, while the routing table contains the best routes calculated from that information.
| LSA type | Name | Generated by | Main purpose |
|---|---|---|---|
| 1 | Router LSA | Every OSPF router | Describes the router's links within one area |
| 2 | Network LSA | DR on a multi-access network | Lists routers attached to the shared segment |
| 3 | Summary LSA | ABR | Advertises networks from one area into another |
| 4 | ASBR Summary LSA | ABR | Tells other areas how to reach an ASBR |
| 5 | AS External LSA | ASBR | Advertises routes redistributed into OSPF |
| 7 | NSSA External LSA | ASBR inside an NSSA | Carries external routes through an NSSA |
Type 1 and Type 2 LSAs
Every OSPF router creates a Type 1 Router LSA for each area to which it belongs. This LSA describes links, costs and neighbour relationships but does not leave its area.
A Designated Router creates a Type 2 Network LSA for a broadcast or non-broadcast multi-access segment when applicable. It describes the segment as a shared network and lists the attached OSPF routers.
Type 3 and Type 4 LSAs
An ABR creates Type 3 Summary LSAs to advertise prefixes between areas. Despite the name, summarisation does not happen automatically; the LSA carries inter-area reachability whether or not manual summarisation is configured.
A Type 4 LSA describes how to reach an ASBR located in another area. Other routers need this information before they can use external routes originated by that ASBR.
Type 5 and Type 7 LSAs
An ASBR creates Type 5 LSAs when routes are redistributed into a normal OSPF area. These LSAs are flooded through the OSPF domain except into stub areas.
An ASBR inside an NSSA uses Type 7 LSAs instead. An NSSA ABR normally translates eligible Type 7 LSAs into Type 5 LSAs before advertising them to the rest of the OSPF domain.
Cisco route tables identify OSPF route sources with codes such as O for intra-area, O IA for inter-area, O E1 or O E2 for external routes, and O N1 or O N2 for NSSA external routes.
What are the OSPF neighbour states?
OSPF neighbour states show the progress from initial discovery to a fully synchronised LSDB. The normal sequence is Down, Init, 2-Way, ExStart, Exchange, Loading and Full, with Attempt appearing mainly on manually configured NBMA networks.
| State | Meaning |
|---|---|
| Down | No recent Hello packet has been received |
| Attempt | Router is actively contacting a manually configured NBMA neighbour |
| Init | A Hello was received, but the local router ID was not listed in it |
| 2-Way | Bidirectional Hello communication is confirmed |
| ExStart | Routers negotiate master/slave roles and database sequence numbers |
| Exchange | Database Description packets summarise each router's LSDB |
| Loading | Missing LSAs are requested and received |
| Full | The neighbours' LSDBs are synchronised |
A neighbour remaining in 2-Way is not always a fault. On an Ethernet broadcast network, DROTHER routers normally form full adjacencies with the Designated Router and Backup Designated Router but remain 2-Way with other DROTHER routers.
DR and BDR election
Broadcast networks elect a Designated Router and Backup Designated Router to reduce the number of adjacencies. The election first uses OSPF interface priority, followed by the router ID as a tie-breaker.
interface GigabitEthernet0/0
ip ospf priority 100A priority of 0 prevents the interface from becoming DR or BDR. Elections are non-preemptive, so adding a router with a higher priority does not automatically replace the existing DR.
How do you configure multi-area OSPF on Cisco IOS?
A basic multi-area configuration assigns interfaces to Area 0 and a non-backbone area, then verifies that neighbour relationships reach the expected state. The OSPF process ID is locally significant and does not need to match between routers.
Use this addressing plan:
| Router | Interface | Address | Area |
|---|---|---|---|
| R1 | G0/0 | 10.0.12.1/30 | 0 |
| R1 | Loopback0 | 1.1.1.1/32 | 0 |
| R2 | G0/0 | 10.0.12.2/30 | 0 |
| R2 | G0/1 | 10.0.23.1/30 | 10 |
| R3 | G0/0 | 10.0.23.2/30 | 10 |
| R3 | Loopback0 | 3.3.3.3/32 | 10 |
R1 configuration
router ospf 10
router-id 1.1.1.1
passive-interface default
no passive-interface GigabitEthernet0/0
network 10.0.12.0 0.0.0.3 area 0
network 1.1.1.1 0.0.0.0 area 0R2 configuration
router ospf 10
router-id 2.2.2.2
passive-interface default
no passive-interface GigabitEthernet0/0
no passive-interface GigabitEthernet0/1
network 10.0.12.0 0.0.0.3 area 0
network 10.0.23.0 0.0.0.3 area 10R3 configuration
router ospf 10
router-id 3.3.3.3
passive-interface default
no passive-interface GigabitEthernet0/0
network 10.0.23.0 0.0.0.3 area 10
network 3.3.3.3 0.0.0.0 area 10passive-interface stops OSPF Hello packets on an interface while still advertising its connected network. It is appropriate for loopbacks and user-facing LAN interfaces where no OSPF neighbour should exist.
How do you verify OSPF operation?
Start verification with neighbour status, interface settings, the LSDB and the routing table. A Full adjacency alone does not prove that every intended prefix has been advertised or installed.
Check neighbours:
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 Gi0/0
3.3.3.3 1 FULL/DR 00:00:31 10.0.23.2 Gi0/1FULL/BDR means the LSDB is synchronised and the neighbour currently has the BDR role. Actual DR and BDR results depend on priority, router ID and election timing.
Inspect the LSDB:
show ip ospf database
show ip ospf database router
show ip ospf database summaryOn R1, R3's loopback should appear as an inter-area route because it originates in Area 10:
R1# show ip route ospf
O IA 3.3.3.3/32 [110/3] via 10.0.12.2, GigabitEthernet0/0The value 110 is the administrative distance, while 3 is the accumulated OSPF cost in this example.
Other useful commands include:
show ip protocols
show ip ospf
show ip ospf interface brief
show ip ospf interface GigabitEthernet0/0
show ip ospf border-routersHow do you troubleshoot OSPF neighbour problems?
Troubleshoot from the interface and Hello parameters toward database exchange rather than changing random settings. The neighbour state usually indicates which stage is failing and which checks should come next.
1. Confirm interface and IP connectivity
show ip interface brief
show interfaces GigabitEthernet0/0
ping 10.0.12.2The interface must be up/up, and both addresses must belong to the correct connected subnet.
2. Confirm that OSPF is enabled on the interface
show ip ospf interface brief
show running-config | section router ospfA wrong wildcard mask may prevent the network statement from matching the interface. You can also enable OSPF directly under an interface with ip ospf 10 area 0.
3. Compare neighbour parameters
The routers must agree on the area ID, Hello and Dead timers, authentication settings and compatible area type. Router IDs must be unique.
show ip ospf interface GigabitEthernet0/0On Ethernet broadcast links, default Hello and Dead intervals are commonly 10 and 40 seconds. Do not assume these values on every OSPF network type.
4. Investigate a 2-Way state correctly
If both routers are DROTHER devices on a multi-access segment, 2-Way may be normal. If one side should be DR or BDR, inspect interface priorities, network type and election results.
5. Investigate ExStart or Exchange failures
An MTU mismatch is a common cause of neighbours becoming stuck in ExStart or Exchange. Compare interface MTUs on both sides:
show interfaces GigabitEthernet0/0 | include MTUCorrecting the MTU is preferable. The command ip ospf mtu-ignore can bypass OSPF's MTU check, but it should be used only when the underlying design is understood.
6. Use debugging carefully
debug ip ospf adj
undebug allDebugging can produce substantial output, so use it carefully on production equipment. Read the messages for area mismatches, duplicate router IDs, authentication failures or sequence negotiation problems.
Summary
OSPF uses Hello packets to form neighbours, LSAs to describe topology and SPF calculations to select routes. Areas control flooding scope, Area 0 connects the design, and neighbour states reveal the progress of adjacency formation.
A strong lab routine is to configure the topology, predict neighbour states and LSA types, and then confirm the result with show ip ospf neighbor, show ip ospf database and show ip route ospf.
To practise OSPF with guided Cisco labs and troubleshooting exercises, enquire about upcoming batch details for the Network Rhinos CCNA course.
Reviewed by Network Rhinos networking trainers.
Related reading: Spanning Tree Protocol Explained: Root Bridge and Port States
