What are the different ways to write a static route on IOS, and which one should you use on Ethernet?
Show the answer
Say this first
Next hop only, exit interface only, or both (fully specified). On Ethernet use a next hop or, better, both. Exit interface only on a multi-access link makes the router ARP for every destination and depend on proxy ARP. On a point-to-point link such as a serial, PPP or tunnel interface, exit interface only is fine because there is only one possible neighbor.
Go deeper
The three forms
ip route 192.0.2.0 255.255.255.0 10.0.12.2
ip route 192.0.2.0 255.255.255.0 GigabitEthernet0/0/1
ip route 192.0.2.0 255.255.255.0 GigabitEthernet0/0/1 10.0.12.2| Form | How it resolves | Watch out for |
|---|---|---|
| Next hop | recursive lookup of 10.0.12.2 | can resolve through another route, even the default |
| Exit interface | treated as directly connected | ARP per destination on Ethernet |
| Fully specified | uses that interface and that neighbor | none; best on Ethernet |
Useful options at the end of the line
ip route 0.0.0.0 0.0.0.0 198.51.100.1 250 name BACKUP-LTE
ip route 0.0.0.0 0.0.0.0 203.0.113.1 track 1 name ISP1
ip route 10.99.0.0 255.255.0.0 10.0.12.2 tag 500- A number is the AD (floating static).
trackties the route to an IP SLA or interface tracking object.tagmarks the route for route-maps during redistribution.nameis a comment that shows up in the config.permanentkeeps the route even when the interface goes down. Use it rarely.
When the route leaves the table
A static is installed only while its next hop resolves and its interface is up. Fully specified routes leave the table as soon as their interface goes down. Next hop only routes can survive by resolving the next hop through some other route, which is a common surprise.
They will ask next
What do you get on IPv6?
The same three forms with
ipv6 route. If the next hop is a link-local address you must also give the interface, because link-local addresses are only unique per link.
Traps
- Pointing a default route at an Ethernet interface with no next hop. It works in a lab and hurts in production.