Static routing (unicast, multicast)
A static route is typed by hand, and the command holds three decisions: what you route, where you point it, and how much you want it believed. Point it at an interface, a next hop, or both: directly attached, recursive, or fully specified. Each form decides what can take the route out of the table, and a distance higher than the protocol's makes a floating static that waits.
By Arif, founder of Daveth · Updated
The full 6 min walkthrough is in Daveth Pro (Network). See what the plan opens
What this page answers
What is the difference between a recursive and a fully specified static route?
A recursive static route names only the next hop, and the output interface is derived from it. A fully specified route names both. A directly attached route names only the interface and treats the destination as on it. Read it in “Where you point, and what takes a route out”
How do you configure a static route on Cisco IOS?
ip route prefix mask, then an address or an interface, then optionally a distance. The distance decides how much the route is believed against other sources for the same prefix. Read it in “One command, three decisions”
The tills that couldn't take cards
Saturday, 8:40, twenty minutes before the first lift. At a ski resort's base lodge, the ticket tills print lift passes, which come from a server in the valley, but every card payment fails. Nobody has touched the lodge router, LODGE-R1, and every one of its interfaces is up.
Plain words first. A static route is a route somebody typed by hand, instead of one a routing protocol such as OSPF learned. The next hop is the neighboring router the traffic is handed to. The administrative distance, from 1.2.a, is the number a router uses to choose between two sources for the same route: lower wins. And the gateway of last resort is where traffic goes when no other route matches it.
So here is the question this lesson answers. Why type a route by hand when a protocol can learn it, and what does a hand-typed route actually notice when something breaks?
One command, three decisions
Static unicast routes are user-defined routes that cause packets moving between a source and a destination to take a specified path. Static routes can be important if the router cannot build a route to a particular destination and are useful for specifying a gateway of last resort to which all unroutable packets are sent.
Here is the command. Count the decisions in it: what you are routing, where you point it, and how much you want it believed.
ip route prefix mask {address | interface} [distance]
From elsewhere: the static route example. The names, numbers and addresses come from elsewhere, not from this scenario.
Device(config)# ip route prefix mask gigabitethernet 1/0/4
The third decision is the distance. Look at the defaults, from the same list 1.2.a used:
Connected interface--0 Static route--1 Open Shortest Path First--110
Now LODGE-R1. OSPF learns the valley, 10.20.0.0/16 and 2001:db8:20::/48, from VALLEY-R1 over the fibre. A static default route sends everything else to VALLEY-R1 as well. And a second static route points the valley at VALLEY-R2 over the microwave radio, at distance 200. Before you read the table, decide which of the two static routes you expect it to hold.
Configuration: LODGE-R1's static routes, in the forms these commands take.
LODGE-R1# configure terminal LODGE-R1(config)# ip route 0.0.0.0 0.0.0.0 10.0.12.1 LODGE-R1(config)# ip route 10.20.0.0 255.255.0.0 10.0.13.2 200 LODGE-R1(config)# ipv6 route ::/0 2001:db8:12::1 LODGE-R1(config)# ipv6 route 2001:db8:20::/48 GigabitEthernet1/0/2 2001:db8:13::2 200 LODGE-R1(config)# end
Computed from the state: the IPv4 static routes, and the gateway of last resort. No command prints it in this form.
static route AD in the table 0.0.0.0/0 via 10.0.12.1 1 yes, out Gi1/0/1 10.20.0.0/16 via 10.0.13.2 200 no: OSPF at 110 wins gateway of last resort 10.0.12.1, out Gi1/0/1
Read the second row: no, OSPF at 110 wins. The radio route sits in the configuration doing nothing, which is exactly what it was written to do. Why does the IPv6 radio route name an interface as well as a next hop? That is the second decision.
Computed from the state: the IPv6 static routes. No command prints it in this form.
static route AD in the table ::/0 via 2001:db8:12::1 1 yes, out Gi1/0/1 2001:db8:20::/48 via Gi1/0/2 2001:db8:13::2 200 no: OSPF at 110 wins
Where you point, and what takes a route out
The IPv6 page names three ways to point a static route. Which one does the lodge's IPv6 radio route use?
In directly attached static routes, only the output interface is specified. The destination is assumed to be directly attached to this interface, so the packet destination is used as the next-hop address. In a recursive static route, only the next hop is specified. The output interface is derived from the next hop. In a fully specified static route, both the output interface and the next hop are specified. This form of static route is used when the output interface is a multi-access one and it is necessary to explicitly identify the next hop. The next hop must be directly attached to the specified output interface.
Gi1/0/2 is an Ethernet port, and the lodge's team treats every Ethernet port as one that could carry more than one router. So their IPv6 radio route names the interface and the next hop together, the form the page gives for a multi-access interface.
Now the part that decides the 8:40 problem. When does a static route leave the routing table?
The switch retains static routes until you remove them. When an interface goes down, all static routes through that interface are removed from the IP routing table. When the software can no longer find a valid next hop for the address specified as the forwarding router's address in a static route, the static route is also removed from the IP routing table.
Notice the two different things in those sentences. The configuration keeps a static route until you remove it. The routing table drops it in the two cases the page names: its interface goes down, or its next hop can no longer be found. The IPv6 page says the same, form by form:
Directly attached static routes are candidates for insertion in the IPv6 routing table only if they refer to a valid IPv6 interface; that is, an interface that is both up and has IPv6 enabled on it. A recursive static route is valid (that is, it is a candidate for insertion in the IPv6 routing table) only when the specified next hop resolves, either directly or indirectly, to a valid IPv6 output interface, provided the route does not self-recurse, and the recursion depth does not exceed the maximum IPv6 forwarding recursion depth. A fully specified route is valid (that is, a candidate for insertion into the IPv6 routing table) when the specified IPv6 interface is IPv6-enabled and up. By default, a recursive IPv6 static route will not resolve using the default route (::/0).
Look at what is missing from every one of those rules. Not one of them asks whether traffic sent that way arrives.
One more consequence of pointing at an interface:
Static routes that point to an interface are advertised through RIP, IGRP, and other dynamic routing protocols, whether or not static redistribute router configuration commands were specified for those routing protocols. These static routes are advertised because static routes that point to an interface are considered in the routing table to be connected and hence lose their static nature. However, if you define a static route to an interface that is not one of the networks defined in a network command, no dynamic routing protocols advertise the route unless a redistribute static command is specified for these protocols.
So an interface static can appear in a neighbor's table with no redistribution configured, but only for an interface inside a network command. Redistribution as a design is 1.2.h.
A fibre cut past the switch
Back to 8:40. A snow groomer has cut the fibre between the provider's switch, FIBRE-SW, and VALLEY-R1. FIBRE-SW still has power, so LODGE-R1's Gi1/0/1 stays up. OSPF stops learning the valley over the fibre. LODGE-R1's configuration has not changed.
Before you read on, decide what happens to the static default route.
Computed from the state: the IPv4 static routes after the fibre cut. No command prints it in this form.
static route AD in the table 0.0.0.0/0 via 10.0.12.1 1 yes, out Gi1/0/1 10.20.0.0/16 via 10.0.13.2 200 yes, out Gi1/0/2 gateway of last resort 10.0.12.1, out Gi1/0/1
Read the first row: yes, out Gi1/0/1. By this course's reading, a next hop is found while a route in the table covers it, and 10.0.12.1 sits inside the fibre subnet that Gi1/0/1 is still connected to. Neither removal rule has fired. The second row did its job: the radio route replaced OSPF's valley route once that route was lost.
By this course's reading, valley traffic uses the valley route whenever one is in the table, and card payments, bound for the internet, have only the default. So where does each kind of traffic go?
Computed from the state, where the tills' traffic leaves LODGE-R1, and whether it arrives. No command prints it in this form.
traffic route used out arrives card payments, IPv4 0.0.0.0/0 static Gi1/0/1 no: the fibre beyond FIBRE-SW is cut card payments, IPv6 ::/0 static Gi1/0/1 no: the fibre beyond FIBRE-SW is cut lift passes, IPv4 10.20.0.0/16 static Gi1/0/2 yes lift passes, IPv6 2001:db8:20::/48 static Gi1/0/2 yes
Look at the card payment rows. They leave by Gi1/0/1, into a fibre that no longer reaches the valley. The lift pass rows leave by the radio and arrive. That is the whole 8:40 mystery.
Nothing here is malfunctioning, and that is the uncomfortable part. You wrote the route down. The router is doing what you wrote, at full speed, with no complaints. Static routing is extremely obedient, and obedience includes carrying on with an instruction that stopped being true at 8:40 this morning.
Typing a route asserts that a path exists. It does not check. Nobody at the far end signed anything, nothing tests whether the destination is reachable, and the route will sit in that table looking exactly as healthy as it did yesterday for as long as its local interface stays up.
Unlike a dynamic routing protocol, static routes are not automatically updated and must be manually reconfigured if the network topology changes.
What if FIBRE-SW had lost power instead, and taken Gi1/0/1 down with it?
Computed from the state: the IPv4 static routes if Gi1/0/1 were down. No command prints it in this form.
static route AD in the table 0.0.0.0/0 via 10.0.12.1 1 no: next hop not found 10.20.0.0/16 via 10.0.13.2 200 yes, out Gi1/0/2 gateway of last resort none
Look back at the reading after the fibre cut: there, the default stayed. Here it is gone, and so is the gateway of last resort. Card payments still fail, but this time the table tells the truth about it.
Which is worth stating as a rule, because it decides how much you can trust what you are reading: a static route is withdrawn when the router itself can see something has gone, and not when the path has gone. A failure near you is visible. The same failure three hops away is not, and the table looks identical either way.
Losing on purpose
First, how the radio route stayed out of the way all morning.
However, you can override static routes with dynamic routing information by assigning administrative distance values. If you want a static route to be overridden by information from a dynamic routing protocol, set the administrative distance of the static route higher than that of the dynamic protocol.
Floating static routes are static routes that are used to back up dynamic routes learned through configured routing protocols. A floating static route is configured with a higher administrative distance than the dynamic routing protocol it is backing up. As a result, the dynamic route learned through the routing protocol is always used in preference to the floating static route. If the dynamic route learned through the routing protocol is lost, the floating static route will be used in its place. A floating static route must be configured with an administrative distance that is greater than the administrative distance of the dynamic routing protocol, because routes with smaller administrative distances are preferred. Any of the three types of IPv6 static routes can be used as a floating static route.
Think about what that asks you to type. A route, carefully written, with a bigger number, so your own route loses whenever OSPF has anything to say. A bad score is the whole design.
From elsewhere: the floating static route example. The names, numbers and addresses come from elsewhere, not from this scenario.
Device(config)# ipv6 route 2001:DB8::/32 serial 2/0 201
If the GigabitEthernet0/0/0 interface fails, or if route 2001:DB8:1:1/32 is no longer learned via IS-IS (indicating loss of connectivity elsewhere in the network), traffic is routed via the backup ISDN interface.
Notice both triggers in that example: the interface fails, or the dynamic route is no longer learned. Both are about the route being backed up. The lodge's radio route backs up OSPF's valley route, and nothing else.
At 8:50 the on-call engineer adds a second default route over the radio, at distance 250. Will card payments move to the radio?
Configuration: LODGE-R1 with a floating default, in the forms these commands take.
LODGE-R1# configure terminal LODGE-R1(config)# ip route 0.0.0.0 0.0.0.0 10.0.13.2 250 LODGE-R1(config)# ipv6 route ::/0 2001:db8:13::2 250 LODGE-R1(config)# end
Computed from the state: the IPv4 static routes with the floating default. No command prints it in this form.
static route AD in the table 0.0.0.0/0 via 10.0.12.1 1 yes, out Gi1/0/1 10.20.0.0/16 via 10.0.13.2 200 yes, out Gi1/0/2 0.0.0.0/0 via 10.0.13.2 250 no: static at 1 wins gateway of last resort 10.0.12.1, out Gi1/0/1
Read the last route row: no, static at 1 wins. The default it was meant to back up was never lost, because the fibre default still meets both conditions. A floating static only floats when the route above it leaves the table.
At 9:05 the engineer tries something else. Both defaults go, and a new one points at VALLEY-R1's address inside the valley, 10.20.0.1, and 2001:db8:20::1 for IPv6. That next hop is found through whichever valley route is in the table. Before the reading, work out which interface the new default leaves by.
Continue the lesson
The whole lesson, with its drawings and its questions. The rest of this section and 5 more after it.

