2 Static Routing Practice
Learn how to configure, select, verify, and troubleshoot IPv4 static routes on Cisco IOS and IOS XE, including default and backup routes.
Purpose of static routes
Cisco IOS and IOS XE static routes are manually configured paths to destination networks. They are useful in simple, stable topologies or when a particular route is needed as a backup. A route is useful only if its can be resolved and reached.
Configure an IPv4
The general IPv4 command uses a destination network, subnet mask, next-hop IP address, and an optional :
For example, to reach 192.168.20.0/24 through the neighboring router at 10.0.12.2, enter:
A route can specify an outgoing interface, a next-hop address, or both. On Ethernet links, specifying the next-hop address helps the router forward packets to the intended neighboring router.
A next-hop-only route is a : the router must already have a route that resolves the next-hop address to an outgoing interface. If the cannot be resolved, the cannot be installed.
To remove a route, enter the same command with no at the start:
Configure a
A is used when the routing table has no more-specific matching route. In IPv4, both the destination and mask are zero:
This sends otherwise-unmatched traffic to the 198.51.100.1. Use a reachable through a working interface. Configuring a does not by itself cause the router to advertise it to a dynamic routing protocol; appropriate protocol configuration is also required for advertisement.
Set up a backup route
A provides a backup path by using a higher than the preferred route to the same destination. A lower is preferred. On Cisco IOS and IOS XE, a regular has a default of 1, while OSPF has a default of 110.
For two static paths to 192.168.20.0/24, the primary can use the default value and the backup can use a higher value:
The route through 10.0.12.2 is preferred while valid. If it is removed from the routing table, the route through 10.0.13.2 can be installed. To back up an OSPF route, the needs an higher than 110; 120 is one example:
The backup works only when the primary route actually disappears. If the primary remains resolvable through another route, the primary may remain installed even if its intended physical path has failed. Confirm how next-hop reachability behaves in the network, and use a suitable tracking mechanism when detecting a path failure beyond interface or next-hop loss is required.
Understand route selection
Route choice involves two separate decisions.
When routes for the same destination prefix come from different sources, the router normally installs the one with the lowest . For example, a default with 1 wins over an OSPF route with 110 for the same prefix, unless the is configured with a higher value.
When forwarding a packet, the router applies : it uses the most specific matching installed prefix. A /24 route is more specific than a /16 route, and both are more specific than the /0. does not make a less-specific route override a more-specific match.
For example, with routes for 192.168.0.0/16, 192.168.20.0/24, and 0.0.0.0/0 installed:
A packet for
192.168.20.25uses the/24route.A packet for
192.168.30.25uses the/16route.A packet for
203.0.113.25uses the , if one is installed.
Cisco displays route values in [/metric] format.
Verify routes and forwarding
Use these commands in privileged EXEC mode:
In show ip route, S marks a and O marks an OSPF route. An entry such as S 192.168.20.0/24 [1/0] via 10.0.12.2 indicates a with 1. Check that the expected route is present, which it uses, and whether the gateway of last resort is set.
A successful ping to a tests basic reachability to that neighbor. A successful ping to a remote host tests more of the end-to-end path, though a failed ping alone does not prove there is a routing error.
Troubleshoot common route problems
Check these common causes when a route or forwarding behavior is unexpected:
Wrong destination mask: The route may match too many or too few addresses. Compare the destination prefix and subnet mask with the intended network.
Wrong or unreachable : Verify the next-hop address, interface status, and whether the router has a route to the . A must resolve to an outgoing interface.
Missing return route: The forward path may work even when the remote router has no route back to the source network. Verify routing in both directions.
Backup not higher: If the backup value is equal to or lower than the primary route's value, the intended preference may not occur. Compare values for routes to the same prefix.
mistaken for a specific route: A is used only when no more-specific installed route matches. Check whether a more-specific route directs traffic elsewhere.
Primary path failure not detected: A may remain installed if its can still be resolved through another path. Check the route table and actual next-hop resolution, not only the status of the expected interface.
Configured route absent from the table: Confirm the command in the running configuration, then check next-hop reachability, interface state, and competing routes. An of 255 makes a route ineligible for installation.
Apply route selection and backup behavior
Given these installed routes:
The forwarding choice for each destination is:
192.168.20.25uses192.168.20.0/24via10.0.13.2, because it is the longest match.192.168.30.25uses192.168.0.0/16via10.0.12.2.203.0.113.25uses the via198.51.100.1.
To configure a primary route to 192.168.40.0/24 through 10.0.12.2 and a backup through 10.0.13.2, use:
Verify that the primary is installed, then determine whether the backup is installed only after the primary is removed or no longer valid.