OSPF
- IP Protocol 89
- Administrative distance (Cisco): 110
- Link state protocol (Dijkstra SPF algorithm)
Adjacency states and process
| State | Notes |
|---|---|
| Down | No hellos received from neighbor |
| Attempt | Only valid for manual NBMA configured neighbors. Unicast. |
| Init | Received hello from neighbor but receiving routers router ID not in hello |
| Two-way | Received hello from neighbor that includes router ID (Active neighbor) |
| Exstart | Highest router ID goes first (master/slave). Master chooses initial sequence num. MTU has to match in DBD packet. |
| Exchange | Exchange DBD packets |
| Loading | Exchange link state information (LSA/LSU) |
| Full | Routers are fully adjacent and synchronized |
- Hello and dead intervals must match (10/40 default)
- 224.0.0.5 (AllSPF Address)
-
224.0.0.6 (AllDR Address)
-
Ensure routers have same IP mask, MTU, hello and dead intervals for adjacency
- Ensure neighbors in same area and have same area type configured (stub)
- Authentication has to match if configured
Updates
- LSA's have sequence numbers
- If device receives a new LSA, the route is added to the database, the route is flooded out other links so other routers are updated, and SPF is rerun.
- If device receives an LSA with the same sequence number, it ignores it
- If device receives an LSA with a lower sequence number it transmits an LSU containing the newer LSA to the original sender
-
If device receives an LSA with a higher sequence number it updates its database, sends an LSAck, runs SPF, floods LSA
-
LSU sent on topology change
- Summary LSA sent every 30 minutes (LSA refresh)
Metrics
- Cost metric
- Check "Reference Bandwidth". Standard now is 100G. 100Mbps by default on cisco.
- Default cost of T1 is 64 (with 100 Mbps refernce bandwidth)
(config-router)#auto-cost reference-bandwidth 1000000- Cisco routers automatically load balance 4 equal cost paths (configurable up to 16)
Packet Types
5 types:
- Hello
- DBD (Database Descriptor): List of RIDs whom the router has an LSA and current sequence num. Summary of LSDB.
- LSR (Link State Request): Follow DBDs to ask for missing LSAs
- LSU (Link State Update): Replies to LSRs. Full LSA entries (RID, cost). Can contain multiple LSAs.
- LSAck (Link State Acknowledgement): Confirm receipt of link state info
DR/BDR
Routers on multi-access segment become adjacent with the DR instead of with all other routers. This reduces the number of adjacencies required.
- Default priority is 1. 0 cannot be elected DR
- DR preemption will not occur unless DR is reset
clear ip ospf process *on DR will also force a DR/BDR election
The BDR passively listens (224.0.0.6) and promotes itself to DR when it stops sending Hellos
All other (Non DR / DROTHER) routers stop at 2-way state and only peer with DR/BDR
Elected by highest priority and tie is broken by highest router-id IP address
Router ID is highest IP address of a loopback interface. If there is no loopback it will be the highest IP assigned to a physical interface
Was of manipulating DR/BDR election (summary):
(config-if)# ip ospf priority 10
Set the RID with (config-router)# router-id 10.1.1.1 (requires reload of OSPF process)
Set an IP address on the loopback interface
Network Types
| Network Types | NBMA | P2MP Broadcast | P2MP Non-Broadcast | Broadcast | P2P |
|---|---|---|---|---|---|
| DR/BDR Elected | Yes | No | No | Yes | No |
| Neighbor Discovery | No | Yes | No | Yes | Yes |
| Hello/Dead Timers | 30/120 | 30/120 | 30/120 | 10/40 | 10/40 |
| Topology | Full Mesh | Any | Any | Full Mesh | P2P |
| RFC/Proprietary | RFC | RFC | Cisco | Cisco | Cisco |
Generally anything "point-to-point" does not elect a DR and anything "non-broadcast" requires neighbors to be manually specified.
- Multipoint subinterfaces are NBMA by default
- Point-to-point subinterfaces are point-to-point by default
- NBMA / P2MP Non-Broadcast neighbors must be manually defined (only needs to be defined on hub router)
- OSPF point-to-multipoint non-broadcast was designed to allow for the assignment of the cost on a per neighbor basis as opposed to using the interface’s cost.
router ospf 1
neighbor 172.12.123.2
neighbor 172.12.123.3 cost 25
- Setting network type on an interface
(config-if)# ip ospf network {broadcast | non-broadcast | point-to-multipoint [non-broadcast]}
Router Types
| Type | Description |
|---|---|
| Internal | Maintains LSAs within area |
| Backbone | Router within backbone area 0 |
| ABR | Area border router. Connects 2 or more |
| ASBR | Connects to external routing domains |
LSA Types
| Type | Description |
|---|---|
| Router Link (1) | Lists neighboring routers and the cost to each; flooded within an area O |
| Network Link (2) | Generated by DR; lists all routers on adjacent segment; flooeded within an area O |
| Network Summary (3) | Generated by ABR; Inter-area O IA |
| ASBR Summary (4) | ASBR generated; ABR injects into backbone area; path to ASBR O IA |
| External Link (5) | LSA originated by ASBR; External routes O E1 or O E2 |
| Multicast (6) | Used in Multicast OSPF operations |
| NSSA External (7) | Generated by ASBR in NSSA; Converted to type 5 by ABR when leaving area O N1 or O N2 |
| External Attributes (8) | OSPF/BGP Interworking |
| Opaque LSA (9,10,11) | Type 10 used for MPLS/CSPF. These have area-local scope |
Area Types
| Type | Description |
|---|---|
| Stub | Does not accept external Type 5 ; replaced with default route |
| Totally Stubby | Type 3,4,5 replaced with default route |
| NSSA | Stub area containing an ASBR; Type 5 converted to type 7 within area. NSSA is a stub area that allows an ASBR. |
| Totally NSSA | Type 3, 4 replaced with default route |
Example stub config:
router ospf 1
area 1 stub
Example totally stubby config:
Same as stub but add no-summary on ABR
router ospf 1
area 1 stub no-summary
Not-so-stubby:
router ospf 1
area 5 nssa
Note: ABR in NSSA does not auto-generate a default route. Need:
router ospf 1
area 5 nssa default-information originate
Totally NSSA (ABR generates a default route):
router ospf 1
area 5 nssa no-summary
External Route Types
- E1 - Cost to ASBR plus the external route cost
- E2 (Default) - Only considers cost to ASBR
Changing types:
(config)# router ospf 1
(config-router)# redistribute connected subnets metric-type 1
Summary routes
Summarize at an ABR (area 5 is the area where routes originate)
router ospf 1
area 5 range 8.0.0.0 252.0.0.0
Summarize routes redistributed into OSPF at an ASBR:
router ospf 1
redistribute connected subnets
summary-address 4.0.0.0 252.0.0.0
Setting the cost on default route generated by ABR for stub area:
area 1 stub
area 1 default-cost 15
This is helpful if there are multiple ABRs attached to an area and need to specify which ABR traffic should default towards. Defaults to cost to the ABR plus one.
Virtual Links
- Tunnel to join 2 areas across an intermediate area
- Both routers must share a common area
- At least one router must reside in backbone area
- Cannot traverse stub area
Configure to router-id of virtual-link neighbor on each end
(config-router)# area 34 virtual-link 4.4.4.4
Authentication
Plain-text:
(config-if)# ip ospf authentication-key CCNP
MD5:
(config-if)# ip ospf message-digest-key 1 md5 CCNP
(config-if)# ip ospf authentication message-digest
Commands
- Show commands
show ip ospf
show ip ospf database
show ip ospf neighbor
show ip ospf interface
show ip ospf virtual-link
show ip ospf border-routers
show ip protocols
debug ip ospf events
Basic Config Examples
Network statement
router ospf 1
network 10.1.1.0 0.0.0.255 area 0
Setting interface cost
(config-if)# ip ospf cost 10
Setting interface priority (for DR/BDR election):
(config-if)# ip ospf priority 0
Misc Notes
- Max age of an LSA is 3600 per RFC 2328
- Every LSA has to be refreshed ever 1800 seconds (30 minutes)
- Intra-area routes are always preferred over inter-area, which area preferred over externals
- Highest loopback is the RID by default. If no loopbacks configured, highest IP address on an active OSPF process interface
passive-interfaceprevents OSPF from sending Hello messages out an interface. Recommended to usepassive-interface defaultO N1andO N2are functionally the same asE1andE2in regards to cost-
Standard NSSA area, type 5 to 7 conversion does not inject a default route
-
OSPF route type order of precedence: internal > inter-area > external (E1 preferred over E2)
Sample packet headers
Hello (2 way):

DBD:

LSU:
