Keyboard shortcuts

Press or to navigate between chapters

Press S or / to search in the book

Press ? to show this help

Press Esc to hide this help

OSPFv2

OSPFv2 is protocol 89.

Terms

LS — Link State

LSA — Link State Advertisement

LSDB — Link-State Database

RID — Router ID

  • Unique 32-bit number to identify the router in a graph
  • Doesn’t have to be an on-the-box IP, but is usually a loopback
  • Should be easy to identify from a Router-ID subnet

Process ID

  • Where the databases lives
  • Not transmitted
  • Allows multiple OSPFv2 processes

DR — Designated Router

  • Network vertex for a broadcast or NBMA network
  • Used to reduce the number of FULL adjacencies

Advertising Router

  • Router that created the LSA
  • Value in this field is the RID

The Update Rule

  • Routers can only modify LSAs they originate
  • Its RID is inside the “Advertising Router” field

LS Sequence

  • The first sequence number in any LSA is 0x80000001
  • Higher sequence numbers are newer LSAs

LS Checksum

  • Used to ensure the LSA was transmitted without corruption
  • Everything is checked except LS Age

LS Age

  • LSAs time out in an hour
  • Refreshed every 30 minutes
  • LSA Age increments traveling through routers

IFF — If and only if

Packet types

TypeNameShort NamePurpose
1HelloHelloOSPFv2 puts the neighbor ID into it’s hello messages
2Database DescriptionDBD/DDPA LSA that contains LSA headers, “I have these LSAs”
3LS RequestLSRRequesting a specific LSA
4LS UpdateLSUSend a specific LSA
5LS AcknowledgmentLSAckAcknowledging a specific LSA

Hello packets

These things must match for an adjacency to form

  • Hello time
  • Dead time
  • Subnet
  • Subnet mask
  • Interface MTU
  • Area
  • Area flags (NSSA, Stub)
  • Is DR/BDR enabled
  • Authentication

These must not match

  • Router ID

Check with debug ip ospf event

Identical databases

Each router can perform its own SPT via Dijkstra’s algorithm.

LSAs are flooded throughout an area, all routers in the same area should have the same LSAs and same database.

R1# show ip ospf database database-summary  | s Area 0
Area 0 database summary
  LSA Type      Count    Delete   Maxage
  Router        5        0        0       
  Network       5        0        0       
  Summary Net   8        0        0       
  Summary ASBR  2        0        0       
  Type-7 Ext    0        0        0       
    Prefixes redistributed in Type-7  0
  Opaque Link   0        0        0       
  Opaque Area   0        0        0       
  Subtotal      20       0        0
R2# show ip ospf database database-summary | s Area 0
Area 0 database summary
  LSA Type      Count    Delete   Maxage
  Router        5        0        0       
  Network       5        0        0       
  Summary Net   8        0        0       
  Summary ASBR  2        0        0       
  Type-7 Ext    0        0        0       
    Prefixes redistributed in Type-7  0
  Opaque Link   0        0        0       
  Opaque Area   0        0        0       
  Subtotal      20       0        0

Can also check with checksums

show ip ospf | i Checksum

Adjacency state machine

StateDescription
DownOSPFv2 is running, no hello packets received yet.
AttemptNBMA mode, the router has sent OSPFv2 packets.
InitThe router sees hello packets.
2-WayThe router sees it’s own router-id in the hello packet.
ExStartRouters vote on who exchanges LSDB first.
LoadingRouter DB has been exchanged, router is requesting specific LSAs.
FullLSDBs for this area are identical on both sides.

Routing hierarchy

OSPFv2 has four levels of routing hierarchy.

PreferenceRoutePurpose
1OIntra-area (same area)
2O IAInter-area (same OSPFv2 domain)
3E1External type 1 (seed metric + IGP metric)
4E2External type 2 (just seed metric)

The bit E is what makes E1 and E2 routes. The bit being set is an E2 route, which is considered less preferred.

Default route

OSPFv2 has two ways of originating a default route.

default-information originate if a default route is present.

default-information originate always do it anyway.

Cost

Should be set manually on each node.

The defaults make 100Mbps and above all the same cost.

auto-cost reference-bandwidth 40,000

Area summary

These will show up as an O IA route in OSPFv2, and a route-to-null on the ABR.

  • Requires a route present in the RIB

v4

router ospf 1
 router-id 2.2.2.2
 area 1 range 10.0.0.0 255.255.224.0

v6

router ospfv3 1
 !
 address-family ipv6 unicast
  area 1 range 2001:DB8::/56

Route-Filtering

You can use the same command to tell the router to … exclude these routes from the backbone, via the not-advertise keyword.

Using range

The area command is now a route-filter.

Range v4

router ospf 1
 router-id 2.2.2.2
 area 1 range 10.0.0.0 255.255.224.0 not-advertise

Range v6

router ospfv3 1
 !
 address-family ipv6 unicast
  area 1 range 2001:DB8::/56 not-advertise
 exit-address-family

Using Filter-Lists

These are a bit harder to use, in and out are inbound and outbound to the area.

For this topology

             Area 0                               Area 1            
                                                               
                                 |           10.0.10.0/24           
                                 |         2001:db8:0:10/64         
                                 |                            +----+
                              +----+       +------------------+ R3 |
+----+                        |    +-------+                  +----+
| R1 +------------------------+ R2 |                        
+----+                        |    +------+     
             10.0.0.0/24      +----+      |                   +----+
           2001:db8:0:0/64       |        +-------------------+ R4 |
                                 |           10.0.20.0/24     +----+
                                 |         2001:db8:0:20/64         

v4

ip prefix-list PREFIX_LIST_LOOPBACK_v4 seq 10 deny 1.1.1.1/32
ip prefix-list PREFIX_LIST_LOOPBACK_v4 seq 20 deny 2.2.2.2/32
ip prefix-list PREFIX_LIST_LOOPBACK_v4 seq 30 deny 3.3.3.3/32
!
router ospf 1
 area 0 filter-list prefix PREFIX_LIST_LOOPBACK_v4 in
 area 1 filter-list prefix PREFIX_LIST_LOOPBACK_v4 in

v6

!
ipv6 prefix-list PREFIX_LIST_v6 seq 10 deny FD::1/128
ipv6 prefix-list PREFIX_LIST_v6 seq 20 deny FD::3/128
ipv6 prefix-list PREFIX_LIST_v6 seq 30 deny FD::4/128
!
router ospfv3 1
 !
 address-family ipv6 unicast
  area 0 filter-list prefix PREFIX_LIST_v6 in
  area 1 filter-list prefix PREFIX_LIST_v6 in

OSPF graceful restart

  • Restart OSPF without dropping adjacencies
  • Keeps the OSPF table in memory while OSPF rebuilds.

Area types

I made a chart.

References

RFC 2328 - OSPF Version 2

J. T. Moy, OSPF: Anatomy of an Internet Routing Protocol. Reading, MA: Addison-Wesley, 1998.

Last Modified • Tuesday, June 30, 2026. 1:01 am UTC+00:00 • Commit: 20e2aad