
OSPF Graceful Shutdown
- Tony Mattke
- Cisco
- February 21, 2011
Striving to reach that last 9? Looking for a way to increase your uptime while still being able to do maintenance on your network? Wish you could shutdown your OSPF neighbors like your BGP peers? Ok, enough sales talk. Achieving HA uptimes when you need to do maintenance is far from simple, even if you tweak your hello timers, or use some fast detection protocol like BFD it still takes time for your protocols to converge. A much better solution would be gracefully notifying a router’s neighbors of a dramatic cost increase on all of it’s interfaces which would force an SPF calculation while the router is still online forwarding packets.
Welcome RFC 3137 — OSPF Stub Router Advertisement (aka graceful shutdown) is a feature implemented in Cisco IOS release 12.2(4)T and 12.3. To force our router into stub status we can use the max-metric router-lsa router configuration command which changes the OSPF metric for all non-stub interfaces on the router to 65535.
The new metric in the LSA does not cause the path to be ignored, it just increases the cost. The other routers in the network will select any alternate paths (if available).
Here is an example of this technique being employed in the lab network.
R1#sh ip ospf database router 192.168.2.1
OSPF Router with ID (192.168.1.1) (Process ID 1)
Router Link States (Area 0)
Routing Bit Set on this LSA
LS age: 1335
Options: (No TOS-capability, DC)
LS Type: Router Links
Link State ID: 192.168.2.1
Advertising Router: 192.168.2.1
LS Seq Number: 8000002A
Checksum: 0x2A65
Length: 60
AS Boundary Router
Number of Links: 3
Link connected to: a Transit Network
(Link ID) Designated Router address: 10.2.4.2
(Link Data) Router Interface address: 10.2.4.2
Number of TOS metrics: 0
TOS 0 Metrics: 10
Link connected to: a Transit Network
(Link ID) Designated Router address: 10.2.3.2
(Link Data) Router Interface address: 10.2.3.2
Number of TOS metrics: 0
TOS 0 Metrics: 10
Link connected to: a Transit Network
(Link ID) Designated Router address: 10.1.2.2
(Link Data) Router Interface address: 10.1.2.2
Number of TOS metrics: 0
TOS 0 Metrics: 10
R1#sh ip route
Codes: C - connected, S - static, R - RIP, M - mobile, B - BGP
D - EIGRP, EX - EIGRP external, O - OSPF, IA - OSPF inter area
N1 - OSPF NSSA external type 1, N2 - OSPF NSSA external type 2
E1 - OSPF external type 1, E2 - OSPF external type 2
i - IS-IS, su - IS-IS summary, L1 - IS-IS level-1, L2 - IS-IS level-2
ia - IS-IS inter area, * - candidate default, U - per-user static route
o - ODR, P - periodic downloaded static route
Gateway of last resort is not set
O E2 192.168.4.0/24 [110/20] via 10.1.3.3, 00:00:01, Ethernet0/1
[110/20] via 10.1.2.2, 00:00:01, Ethernet0/0
10.0.0.0/8 is variably subnetted, 5 subnets, 2 masks
C 10.1.3.0/29 is directly connected, Ethernet0/1
C 10.1.2.0/30 is directly connected, Ethernet0/0
O 10.2.3.0/29 [110/20] via 10.1.3.3, 00:00:01, Ethernet0/1
[110/20] via 10.1.2.2, 00:00:01, Ethernet0/0
O 10.2.4.0/29 [110/20] via 10.1.2.2, 00:00:01, Ethernet0/0
O 10.3.4.0/29 [110/20] via 10.1.3.3, 00:00:01, Ethernet0/1
C 192.168.1.0/24 is directly connected, Loopback0
O E2 192.168.2.0/24 [110/20] via 10.1.2.2, 00:00:01, Ethernet0/0
O E2 192.168.3.0/24 [110/20] via 10.1.3.3, 00:00:01, Ethernet0/1
As you can see there are currently three routes exiting via Eth0/0 which is a direct connection to R2 in our lab. Next we’re going to implement the OSPF Stub Advertisement on R2.
R2# R2#conf t Enter configuration commands, one per line. End with CNTL/Z. R2(config)#router ospf 1 R2(config-router)#max-metric router-lsa R2(config-router)#end R2#
Ok, now lets see what happened to those routes when we now that we’ve changed our LSAs.
R1#sh ip ospf database router adv-router 192.168.2.1
OSPF Router with ID (192.168.1.1) (Process ID 1)
Router Link States (Area 0)
Routing Bit Set on this LSA
LS age: 6
Options: (No TOS-capability, DC)
LS Type: Router Links
Link State ID: 192.168.2.1
Advertising Router: 192.168.2.1
LS Seq Number: 8000002B
Checksum: 0xA00C
Length: 60
AS Boundary Router
Number of Links: 3
Link connected to: a Transit Network
(Link ID) Designated Router address: 10.2.4.2
(Link Data) Router Interface address: 10.2.4.2
Number of TOS metrics: 0
TOS 0 Metrics: 65535
Link connected to: a Transit Network
(Link ID) Designated Router address: 10.2.3.2
(Link Data) Router Interface address: 10.2.3.2
Number of TOS metrics: 0
TOS 0 Metrics: 65535
Link connected to: a Transit Network
(Link ID) Designated Router address: 10.1.2.2
(Link Data) Router Interface address: 10.1.2.2
Number of TOS metrics: 0
TOS 0 Metrics: 65535
R1#sh ip route
Codes: C - connected, S - static, R - RIP, M - mobile, B - BGP
D - EIGRP, EX - EIGRP external, O - OSPF, IA - OSPF inter area
N1 - OSPF NSSA external type 1, N2 - OSPF NSSA external type 2
E1 - OSPF external type 1, E2 - OSPF external type 2
i - IS-IS, su - IS-IS summary, L1 - IS-IS level-1, L2 - IS-IS level-2
ia - IS-IS inter area, * - candidate default, U - per-user static route
o - ODR, P - periodic downloaded static route
Gateway of last resort is not set
O E2 192.168.4.0/24 [110/20] via 10.1.3.3, 00:00:05, Ethernet0/1
10.0.0.0/8 is variably subnetted, 5 subnets, 2 masks
C 10.1.3.0/29 is directly connected, Ethernet0/1
C 10.1.2.0/30 is directly connected, Ethernet0/0
O 10.2.3.0/29 [110/20] via 10.1.3.3, 00:00:05, Ethernet0/1
O 10.2.4.0/29 [110/30] via 10.1.3.3, 00:00:05, Ethernet0/1
O 10.3.4.0/29 [110/20] via 10.1.3.3, 00:00:05, Ethernet0/1
C 192.168.1.0/24 is directly connected, Loopback0
O E2 192.168.2.0/24 [110/20] via 10.1.2.2, 00:00:05, Ethernet0/0
O E2 192.168.3.0/24 [110/20] via 10.1.3.3, 00:00:05, Ethernet0/1
As you can see the routes for 10.2.3.0/29 and 10.2.4.0/29 have changed and the only route still directed at R2 is actually R2’s loopback address – 192.168.2.0/24. Since that is a directly connected interface we would expect that behavior.
Conclusion
This is an extremely handy feature for anyone working on a network with decent redundancy and high uptime requirements. Anytime you can bring a router down in the middle of the day to perform maintenance saves you valuable time, and still lets you brag about your network uptime!
