Sub topic 11
Floating static routes as backup paths
Prerequisites and scope
This chapter assumes you know the following:
- IPv4 addressing and CIDR prefix notation.
- How a router picks a route by longest-prefix match.
- How to enter a static route.
- That administrative distance (AD) ranks route sources, and a lower AD wins.
It builds on those ideas to show how a static route can sit unused until a better route disappears.
What a floating static route is
A normal static route has an administrative distance of 1 on Cisco IOS. That beats OSPF (110), RIP (120) and most other sources. A static route to a prefix therefore replaces any dynamic route to the same prefix.
A floating static route is a static route whose AD you set higher than the AD of the route you want to prefer. Both routes describe the same prefix. The router compares ADs and installs only the lower one in the routing table. The static route stays in the configuration but does not appear in the table. It "floats" below the preferred route and is installed only when the preferred route is withdrawn.
Typical uses:
- A cheap backup link, such as a DSL or LTE line, behind a leased line or MPLS circuit.
- A static fallback for a prefix normally learned through OSPF.
- A second default route that takes over when the first upstream fails.
How the decision works
The router keeps every candidate route for a prefix in its protocol databases. Only one source gets to install a route for each exact prefix and mask. The selection runs in this order:
- Longest-prefix match decides which prefix applies to a packet.
- For routes with the same prefix and mask, the lowest AD decides which source is installed.
- If one source offers several routes, its own metric picks among them.
A floating static route works at step 2. Metrics are not compared across sources, so the OSPF cost and the static route's AD never meet.
Configuring the backup
The primary path is learned by OSPF. The backup is a static route with AD 200.
! Cisco IOS: primary path learned by OSPF (default administrative distance 110)
router ospf 1
router-id 1.1.1.1
network 10.1.0.0 0.0.255.255 area 0
! Backup static route with administrative distance 200, used only if the OSPF route disappears
ip route 10.2.0.0 255.255.0.0 192.168.2.2 200The last number on the ip route line is the AD. Without it the route gets AD 1 and would override OSPF immediately.
Pick a value that is higher than the primary source and lower than 255. A value of 255 marks a route as unusable, so the router never installs it. Common choices are 200, or 250 when the route should lose even to other backups.
Linux equivalent
Linux has no administrative distance. Routes to the same prefix compete on the metric field, and the lowest metric wins. A static backup is therefore a route with a higher metric.
# Primary route (for example installed by a routing daemon) uses metric 100
sudo ip route add 10.2.0.0/16 via 192.168.1.2 dev eth0 metric 100
# Backup route with a higher metric; the kernel uses it only if the primary is removed
sudo ip route add 10.2.0.0/16 via 192.168.2.2 dev eth1 metric 200
ip route show 10.2.0.0/16Both routes appear in ip route show. The kernel uses the lowest-metric route among those that are usable. This differs from Cisco IOS, where the losing route is hidden.
Verifying the behavior
Check the table in the normal state, then in the failure state.
! Cisco IOS: inspect the routing table
show ip route
show ip route static
show ip route ospf
show ip route 10.2.5.7In the normal state:
show ip route 10.2.5.7reports the OSPF route with[110/metric].show ip route staticdoes not list the floating route.show running-config | include ip routestill shows it, because it is configured.
After the primary link fails and OSPF withdraws the prefix:
- The static route appears with
[200/0]and the codeS. - The next hop becomes 192.168.2.2.
When OSPF recovers, the OSPF route returns and the static route disappears again from the table.
The main gotcha: a route only floats up when the primary is withdrawn
The router installs the backup only when the better route is gone from the routing table. This produces several failure modes.
| Failure | What happens | Why |
|---|---|---|
| Primary link goes down (interface down) | Backup installs quickly | The interface state change removes the OSPF route and any static route that used it |
| Link stays up but the far end is dead (for example a switch in between) | Backup never installs until OSPF dead timer expires | The route stays until the neighbor is declared down. The default OSPF dead interval is 40 seconds on broadcast links |
| Upstream fails beyond the next hop, with a static primary | Backup never installs | The static route's next hop is still reachable, so the route stays in the table |
| Backup next hop is unreachable | Backup installs but traffic is dropped | A static route with a next hop is installed only if the next hop resolves, but a resolved next hop does not prove the path works |
The third row matters most. If the primary is also static, a plain static route does not check whether the destination is reachable. A floating static route behind a static primary will not take over when the failure is farther away.
Tracking the primary
On Cisco IOS you can tie a static route to an IP SLA probe so that it is removed when the probe fails. This is the standard way to make a static primary fail over.
! Cisco IOS: probe the far side every 5 seconds
ip sla 10
icmp-echo 10.2.0.1 source-interface GigabitEthernet0/0
frequency 5
ip sla schedule 10 life forever start-time now
track 10 ip sla 10 reachability
! Primary static route is installed only while track 10 is up
ip route 10.2.0.0 255.255.0.0 192.168.1.2 track 10
! Floating backup
ip route 10.2.0.0 255.255.0.0 192.168.2.2 200When the probe fails, track 10 goes down, the router removes the primary, and the AD 200 route installs.
Choosing the AD value
The AD must be higher than the route you are backing up. It must be lower than any source you want the backup to beat.
| Backing up | Default AD of primary | Safe floating AD |
|---|---|---|
| OSPF | 110 | 111 or higher, commonly 200 |
| RIP | 120 | 121 or higher, commonly 200 |
| EIGRP internal | 90 | 91 or higher, commonly 200 |
| eBGP | 20 | 21 or higher, commonly 200 |
| Static route | 1 | 2 or higher, commonly 5 or 200 |
Check whether the network changes AD values. If someone raises the OSPF distance to 210 with the distance command, a floating route at 200 becomes the preferred route and silently takes over. Document the AD values you rely on.
Edge cases
- Different prefix lengths. The floating route must have the same prefix and mask as the primary. If the backup is a /8 and the primary is a /16, longest-prefix match picks the /16 while it exists, but the two do not compete on AD. They do fail over, but only because the shorter prefix covers the destination. A less specific backup also carries traffic that no other route claims.
- Floating default route.
ip route 0.0.0.0 0.0.0.0 192.168.2.2 200backs up a default route learned dynamically or configured with a lower AD. - Asymmetric return traffic. After failover, outbound packets use the backup, but the remote side may still send replies down the old path. Configure the remote router with a matching floating route.
- Flapping. If the primary link bounces, the table switches back and forth. Active sessions can break on each switch, especially with NAT, so the backup path may need to hold state independently.
- Bandwidth and policy. The backup is often slower or metered. Failover can congest it, so consider a QoS policy on that link.
- Preempt behavior. Return to the primary is automatic. There is no hold-down by default, so a short flap on the primary moves traffic back and forth.
Summary
A floating static route is an ordinary static route given a higher AD than the route you want to prefer. The router hides it while the preferred route exists and installs it when that route is withdrawn. It works well behind a dynamic protocol, because the protocol withdraws the route when it loses a neighbor. Behind a static primary, add tracking, or the backup never activates for remote failures.
Exercise
Router R1 learns 10.2.0.0/16 from OSPF (AD 110). You configure ip route 10.2.0.0 255.255.0.0 192.168.2.2 90. What happens, and what command value would make the route a backup?
Show answer
The static route has AD 90, which is lower than 110, so the router installs it and hides the OSPF route. It is not a backup. Use an AD above 110 and below 255, for example ip route 10.2.0.0 255.255.0.0 192.168.2.2 200.
Exercise
The primary route to 10.2.0.0/16 is a plain static route to 192.168.1.2 (AD 1), and a floating static route with AD 200 uses 192.168.2.2. The router at 192.168.1.2 stays up, but its upstream link fails. Does the backup activate? How would you fix it?
Show answer
No. The next hop 192.168.1.2 is still reachable, so the AD 1 route stays in the table. Fix it by tracking the primary with an IP SLA probe, as in ip route 10.2.0.0 255.255.0.0 192.168.1.2 track 10, so the router removes the route when the probe to the far side fails. Alternatively, run a dynamic routing protocol on the primary path.