When you reset the OSPF process, it drops all neighbor adjacencies. Other OSPF routers will have to rerun the SPF algorithm and figure out a new path in the network. With OSPF graceful restart, it allows you to restart the OSPF process on your router without dropping neighbor adjacencies. Your router will keep forwarding traffic while OSPF restarts and the network will not be interrupted.
Here’s an example topology:

Above we have three routers and two hosts. If the OSPF process on R2 is reset, there is no way for R1 and R3 to reach each other anymore. H1 and H2 will be unable to exchange any data. If we use graceful restart on R2, forwarding will not be interrupted while R2 restarts its OSPF process.
How does it work?
Graceful restart works by informing OSPF neighbors that it is going to restart. The router that is going to restart is called the restarting router, the restarting process is called the graceful restart mode. It starts by sending a link-local type 9 LSA called the grace LSA with a specified time called the grace period:

When the neighbors of R2 receive the grace LSA, they will respond with an acknowledgment:

R1 and R3, the neighbors of R2, are going to help with the graceful restart. These two routers will enter helper mode and are called the helper neighbors. During the grace period, R1 and R3 will act as if R2 is still out there even though they don’t receive any hello packets but will only do so if the topology doesn’t change during the graceful restart.
During the time that the router is restarting, there are no changes to the routing table and forwarding tables, so traffic will be forwarded as usual:

Once OSPF has restarted, it will re-establish neighbor adjacencies with the helper routers:

When the graceful restart has completed, the restarting router flushes the grace LSA. The restarting router continues with its regular OSPF tasks. It will re-originate its LSAs to its neighbors:

The restarting router continues with its regular OSPF tasks. It will re-originate its LSAs to its neighbors:

And it will rerun SPF to refresh the routing table:

R2 has now successfully restarted while there was no network downtime.
OSPF graceful restart is covered in RFC 3623.. Before the RFC, Cisco already implemented its own version of graceful restart called NSF (Non-Stop Forwarding). Cisco IOS supports both NSF and the RFC version of graceful restart.
Most routers support helper mode but only routers with specific hardware support graceful restart. This is because routers require autonomous hardware for forwarding that is separated from the CPU. Cisco calls devices that support helper mode NSF-aware and devices that support graceful restart are called NSF-capable.
Now you have an idea of how OSPF graceful restart works, let’s add some more detail to this story.
Restarting Router
Entering graceful restart
Performing the graceful restart occurs when you use the appropriate command on a router that has OSPF graceful restart enabled. The grace period should not exceed the LSRefreshTime (1800 seconds) to avoid LSAs from aging out on the restarting router.
The restarting router enters the graceful restart by flooding the grace LSA. This is a type 9 LSA with a link-local scope. The grace LSA will be retransmitted until all adjacent neighbors have responded with an acknowledgment. If you don’t receive an acknowledgment from all neighbors, graceful restart will exit.
During graceful restart
During the graceful restart the restarting router will:
- Not originate any LSA types 1-5 and 7. The idea behind graceful restart is that other routers in the network will use the LSAs of the restarting router that were originated before the graceful restart.
- Not modify or flush any self-originated LSAs that it receives from neighbors.
- Run some calculations to restore virtual links if required but does not install new OSPF routes in the routing table. It will use the entries in the routing table from before the graceful restart.
- Elect itself as the DR (Designated Router) if it was the DR before the graceful restart. It knows that it was the DR by looking at the hello packet of a neighbor, which lists the restarting router as the DR on the segment.
Exiting graceful restart
The restarting router will exit the graceful restart if any of the following events occurs:
- The restarting router has re-established all neighbor adjacencies. It knows this by looking at the neighbors in the router LSA (and the network LSA if it is the DR) from before the graceful restart and comparing those with the current neighbor adjacencies.
- The restarting router receives a router LSA that is not consistent with the router LSA from before the graceful restart. For example, if in our topology, R2 would receive a router LSA from R3 that does not include the link to R2 then something went wrong:
- R3 doesn’t support graceful restart.
- R3 never received the grace LSA and never entered helper mode.
- R3 exited the helper mode before the graceful restart has ended.
- The grace period has expired.
Once the restarting router has exited the graceful restart, it will continue with its regular OSPF tasks. When the restarting router exits the graceful restart successfully or unsuccessfully, it will perform the following tasks:
- Router LSAs are re-originated to ensure they are up-to-date.
- Network LSAs are re-originated on segments where the restarting router is the DR.
- SPF runs and the routing table is updated. Any entries in the routing table that are no longer valid are removed.
- LSA type 3, 5 and 7 are originated if required.
- Any LSAs that were originated by the restarting router are flushed if no longer valid.
- Grace LSAs that the restarting router originated are flushed.
Helper Neighbor
The helper neighbor has an important role to help the restarting router.
Entering helper mode
When a router receives a grace LSA it enters helper mode and becomes a helper neighbor as long as it passed the following checks:
- The router has a full adjacency with the restarting router.
- There have been no changes in LSA type 1-5 and 7. It checks this by looking at the retransmission list for the restarting router:
- If the list has any LSA type 1-5 or 7 then they must be periodic refreshes.
- If there are LSA type 1-5 or 7 on the list where the content has changed, then the helper neighbor will refuse to enter helper mode.
- The grace period has not yet expired. The LS age of the grace LSA is less than the grace period that is specified in the body of the grace LSA.
- The router is to allow being a helper neighbor. This is something you can enable or disable.
- The router is not doing its own graceful restart.
Exiting helper mode
The neighbor helper will exit helper mode when any of the following events happen:
- The grace LSA is flushed by the restarting router. This is a signal that the graceful restart has ended.
- The grace period in the grace LSA expires.
- The LSDB changes which tells us that there is a topology change, this terminates the graceful restart.
When the neighbor helper exits helper mode, it re-originates its LSAs:
- It recalculates the DR for the segment.
- It re-originates its router LSA for the segment.
- If the neighbor helper is the DR, it re-originates the network LSA.
- If the segment is a virtual link, the neighbor helper re-originates the router LSA for the virtual link’s transit area.
Conclusion
In this lesson, you have learned how OSPF graceful restart allows you to keep forwarding traffic while the OSPF process is reset. If you want to know more details, you can find them in RFC 3623.
Unit 1: Introduction to OSPF
- Introduction to OSPF
- Basic OSPF Configuration
- OSPF Multi Area Configuration
- OSPF Reference Bandwidth
- OSPF Plain Text Authentication
- OSPF MD5 Authentication
- OSPF SHA-HMAC Authentication
- OSPF TTL Security Check
- OSPF Default Route
Unit 2: OSPF Neighbor Adjacency
- OSPF LSA Types
- OSPF LSAs and LSDB Flooding
- OSPF Hello and Dead Interval
- OSPF Router ID
- OSPF Packets and Neighbor Discovery
- OSPF DR/BDR Election
- OSPF Passive Interface
- Troubleshooting OSPF Neighbor Adjacency
Unit 3: OSPF Network Types
- OSPF Non-Broadcast Network Type
- OSPF Broadcast Network Type
- OSPF Point-to-Multipoint Network Type
- OSPF Point-to-Multipoint Non-Broadcast Network Type
- OSPF Point-to-Point Network Type
- OSPF Next Hop with Network Types
Unit 4: OSPF Stub Areas
- Introduction to OSPF Stub Areas
- How to configure OSPF Stub Area
- How to configure OSPF Totally Stub
- How to configure OSPF NSSA (Not So Stubby) Area
- How to configure OSPF Totally NSSA (Not So Stubby) Area
- OSPF NSSA P-bit explained
Unit 5: Advanced OSPF Topics
- OSPF Summarization
- OSPF Distribute-List Filtering
- OSPF LSA Type 3 Filtering
- OSPF LSA Type 5 Filtering
- OSPF Virtual Link
- OSPF Virtual Link Authentication
- OSPF Path Selection Explained
- How to read the OSPF Database
- OSPFv3 for IPv4
- Troubleshooting OSPF Route Advertisement
- OSPF SPF Scheduling and Throttling
- OSPF LSA Throttling
- OSPF Incremental SPF
- OSPF Prefix Suppression
- OSPF Stub Router
- OSPF Graceful Shutdown
- OSPF Graceful Restart
- OSPF Loop-Free Alternate (LFA) Fast Reroute (FRR)
- OSPF Remote Loop-Free Alternate (LFA) Fast Reroute (FRR)