Problem
You want to use a static route only when the dynamic route is not available.
Solution
The router will use a floating static route for a particular network prefix only if that same route is not available from the dynamic routing protocol. You can accomplish this by setting the administrative distance of the static route to a value greater than the administrative distance of the dynamic routing protocol:
Router#configure terminal Enter configuration commands, one per line. End with CNTL/Z. Router(config)#ip route 10.0.0.0 255.0.0.0 172.16.1.1 190 Router(config)#end Router#
You can use the floating static to trigger a dialer interface as follows:
Router#configure terminal Enter configuration commands, one per line. End with CNTL/Z. Router(config)#ip route 0.0.0.0 0.0.0.0 Dialer1 190 Router(config)#end Router#
Discussion
The static routes that we discussed in the previous section all had relatively low administrative distance values. If the router has two routes to the same destination but with different distances, it will always choose the one with the lower distance value. This concept also includes the routes that come from other sources, such as dynamic routing protocols.
Every routing protocol has an administrative distance that indicates how much the router trusts the information it receives by this method. Table 5-3 shows the default values for these administrative distances. Recipe 5.7 demonstrates how to change these values when they are not appropriate for your network. However, for the current example the default values are sufficient.
Routing protocol or source | Administrative distance |
---|---|
Connected interface | 0 |
Static route | 1 |
EIGRP summary route | 5 |
External BGP | 20 |
Internal EIGRP | 90 |
IGRP | 100 |
OSPF | 110 |
IS-IS | 115 |
RIP | 120 |
EGP | 140 |
ODR | 160 |
External EIGRP | 170 |
Internal BGP | 200 |
Unknown | 255 |
A floating static route is simply one that has an administrative distance value greater than that of the dynamic routing protocol being used. For example, any route that is learned via OSPF will have an administrative distance value is 110 by default. This administrative distance applies to all routes learned by this method regardless of what metric they may have within that protocol.
In the case of static routes, you can directly set the administrative distance for any given static route when you define the route. If the static route's distance value is greater than 110, then any OSPF route that includes this destination is considered better. If OSPF has a route for this destination, the router will use it.
The router will install the floating static route if it doesn't have a similar route from the dynamic routing protocol. Bear in mind, though, that the router will always use the route that has the most precise (longest netmask) match. For example, if the router has learned a route for 10.35.15.0/24 from OSPF, and also has a static route for 10.35.15.0/27, it will use the static route even if it has a higher administrative distance. The administrative distance is used only to decide between competing routes of the same mask length.
Floating static routes are often used to trigger automated backup mechanisms when the routing protocol fails. In this case, you could configure a floating static default route, 0.0.0.0/0, which would point to the dialer interface:
Router(config)#ip route 0.0.0.0 0.0.0.0 Dialer1 190
If the router loses contact with the rest of the network because of a circuit failure, then all of the dynamic routes will drop out of the routing table. The router will then install the floating static route, which will trigger the dial backup connection. We discuss dial backup scenarios in more detail in Chapter 13.
See Also
Recipe 5.4; Recipe 5.7; Chapter 13
Router Configuration and File Management
Router Management
User Access and Privilege Levels
TACACS+
IP Routing
RIP
EIGRP
OSPF
BGP
Frame Relay
Handling Queuing and Congestion
Tunnels and VPNs
Dial Backup
NTP and Time
DLSw
Router Interfaces and Media
Simple Network Management Protocol
Logging
Access-Lists
DHCP
NAT
First Hop Redundancy Protocols
IP Multicast
IP Mobility
IPv6
MPLS
Security
Appendix 1. External Software Packages
Appendix 2. IP Precedence, TOS, and DSCP Classifications
Index