Study FAQ
How do you configure and verify default, network, and host static routes in Cisco IOS XE?
Also asked as 2
- What are examples of IPv4 and IPv6 default, network, and host static routes on Cisco IOS XE?
- How can I set and check three different static route prefix lengths on Cisco IOS XE?
Answer
Use ip route with a destination and dotted-decimal mask for IPv4, and ipv6 route with an address and prefix length for IPv6. The destination prefix determines how much of the address must match. A default route uses length zero, a network route names a subnet, and a host route has length 32 for IPv4 or 128 for IPv6.
These Cisco IOS XE 17.15.x examples assume a Catalyst 9300 with routing enabled, ipv6 unicast-routing enabled for IPv6, operational Layer 3 interfaces for both address families, and the given next hops reachable on the lab transit links. With those prerequisites in place, enter the routes in global configuration mode using addresses that match your lab topology.
ip route 0.0.0.0 0.0.0.0 192.0.2.1
ip route 198.51.100.0 255.255.255.0 192.0.2.1
ip route 203.0.113.9 255.255.255.255 192.0.2.1
ipv6 route ::/0 2001:db8:1::1
ipv6 route 2001:db8:2::/64 2001:db8:1::1
ipv6 route 2001:db8:3::9/128 2001:db8:1::1
On Ethernet, specify the next-hop address. An interface-only IPv4 route can cause the router to try to resolve every covered destination as on-link. An adjacent IPv6 link-local next hop also requires the exit interface, for example ipv6 route 2001:db8:2::/64 GigabitEthernet1/0/1 fe80::1. Verify the installed choice for a test destination with show ip route 203.0.113.9 or show ipv6 route 2001:db8:3::9, then confirm the next hop and end-to-end reachability from the intended source. IOS, IOS XE, and Packet Tracer images can differ in supported command forms and interface names.
References
Full explanation
Routing Tables, Forwarding Decisions, and Static Routes
Study guide · 200-301
Read the full explanation