ip route [prefix] [mask] [next-hop]
Configures a static route in the routing table on Cisco NX-OS devices.
Overview
The 'ip route' command is used to manually add a static route to the routing table on Cisco NX-OS devices. Static routing is a fundamental networking concept where the network administrator explicitly defines paths for IP packets. Unlike dynamic routing protocols (e.g., OSPF, EIGRP), static routes do not automatically adapt to network changes, making them suitable for simple or stable network topologies, stub networks, or when precise control over routing is required. On Cisco NX-OS (Nexus), the command syntax is similar to Cisco IOS but includes additional options such as 'track' for conditional routing and 'name' for descriptive labeling. Static routes are often used for default routes (0.0.0.0/0) to provide internet connectivity, for point-to-point links, or as backup routes with higher administrative distance. In troubleshooting workflows, verifying static routes with 'show ip route static' helps identify misconfigurations or unreachable next-hops. NX-OS also supports floating static routes by adjusting the administrative distance, allowing dynamic routes to be preferred over static ones. Understanding the command's parameters and behavior is crucial for network engineers managing Nexus switches in data center environments.
ip route {prefix} {mask} {next-hop | interface} [name {route-name}] [tag {tag-value}] [pref {preference}] [track {track-object-number}]When to Use This Command
- Directing traffic to a specific next-hop for a remote network when dynamic routing is not desired.
- Creating a default route (0.0.0.0/0) to an upstream router or firewall.
- Providing a backup static route with a higher administrative distance for redundancy.
- Pointing to a specific interface for directly connected stub networks.
Parameters
| Parameter | Syntax | Description |
|---|---|---|
| prefix | A.B.C.D | The destination network IP address in dotted-decimal notation. This is the network you want to reach. |
| mask | A.B.C.D | The subnet mask for the destination network in dotted-decimal format (e.g., 255.255.255.0). Must match the prefix length. |
| next-hop | A.B.C.D | The IP address of the next-hop router to which packets are forwarded. Required unless an interface is specified. |
| interface | interface-type slot/port | The outgoing interface for the route. Used instead of next-hop for point-to-point links or when the next-hop is not directly connected. |
| name | WORD | An optional descriptive name for the route (up to 80 characters). Helps identify the route in show commands. |
| tag | tag-value | An optional tag value (1-4294967295) that can be used for route filtering or redistribution. |
| pref | preference | The administrative distance (1-255). Default is 1. Higher values make the route less preferred. Used for floating static routes. |
| track | track-object-number | The track object number (1-512) that must be in an 'up' state for the route to be installed. Used with IP SLA or other tracking mechanisms. |
Command Examples
Basic Static Route
ip route 10.1.1.0 255.255.255.0 192.168.1.1Adds a static route to network 10.1.1.0/24 via next-hop 192.168.1.1. No output is displayed on success.
Default Route with Preference
ip route 0.0.0.0 0.0.0.0 10.0.0.1 pref 2Creates a default route via 10.0.0.1 with administrative distance 2, making it preferred over routes with default distance (1).
Static Route with Track Object
ip route 172.16.0.0 255.255.0.0 10.0.0.2 track 1Installs a static route to 172.16.0.0/16 via 10.0.0.2 only if tracked object 1 is up (e.g., IP SLA reachability).
Static Route via Interface
ip route 10.2.2.0 255.255.255.0 ethernet 1/1Routes traffic for 10.2.2.0/24 out of interface Ethernet1/1. Useful for point-to-point links.
Understanding the Output
The 'ip route' command does not produce immediate output upon successful configuration. To verify static routes, use 'show ip route static' or 'show ip route'. The 'show ip route static' output lists all configured static routes with their next-hop, interface, administrative distance, and route name if set. Each entry shows the prefix, mask, next-hop IP, and optionally the interface. A healthy static route appears with a valid next-hop and interface in an up/up state. Problem values include next-hop being unreachable or interface down, causing the route to be hidden from the routing table. The 'show ip route' command displays the routing table; static routes are marked with 'S'. If a static route is not installed, it will not appear in the routing table, indicating a problem such as next-hop unreachability or administrative distance conflict.
Configuration Scenarios
Default Route to Upstream Router
A Nexus switch needs internet access via an upstream router at 10.0.0.1.
Topology
Nexus (Vlan100) --- .1 10.0.0.0/30 .2 --- Router (Internet)Steps
- 1.Enter global configuration mode.
- 2.Configure the default route with the next-hop IP.
! Configure default route ip route 0.0.0.0 0.0.0.0 10.0.0.1
Verify: Use 'show ip route 0.0.0.0/0' to verify the default route is installed.
Watch out: Ensure the next-hop IP is reachable (directly connected). If not, the route will not be installed.
Floating Static Route for Backup
A Nexus switch uses OSPF as primary routing, but a static route with higher distance provides backup to 10.1.1.0/24 via 192.168.1.1.
Topology
Nexus --- OSPF --- Primary Path
Nexus --- 192.168.1.1 --- Backup PathSteps
- 1.Enter global configuration mode.
- 2.Configure the static route with a higher administrative distance (e.g., 200).
! Configure floating static route ip route 10.1.1.0 255.255.255.0 192.168.1.1 pref 200
Verify: Use 'show ip route 10.1.1.0/24' to see the route; it will only appear if OSPF route is removed.
Watch out: The administrative distance must be higher than the dynamic protocol's distance (OSPF default 110).
Troubleshooting with This Command
When troubleshooting static routes on Cisco NX-OS, start by verifying the route is present in the routing table using 'show ip route static' or 'show ip route | include S'. If the route is missing, check the next-hop reachability with 'ping' or 'show ip arp'. Ensure the next-hop IP is directly connected or reachable via another route. If using the 'track' option, verify the track object status with 'show track'. Common issues include incorrect subnet mask, wrong next-hop IP, or interface being down. Use 'show ip interface brief' to check interface status. If a static route appears but traffic is not forwarded, check for routing loops or ACLs blocking traffic. On NX-OS, static routes can also be affected by VRF contexts; ensure you are in the correct VRF. Use 'show ip route vrf <vrf-name>' if applicable. For floating static routes, confirm the administrative distance is higher than the dynamic route's distance. If the route is not installed, use 'debug ip routing' to see route installation events (caution: may impact performance). Finally, verify the route's next-hop is not the same as the destination (recursive routing) unless intended.
CCNA Exam Tips
Remember that static routes have an administrative distance of 1 by default on NX-OS, but can be changed with the 'pref' keyword.
The 'track' option is often tested in CCNP; it allows conditional route installation based on object reachability.
On NX-OS, static routes can be configured with a route name using the 'name' keyword for easier identification in show commands.
Common Mistakes
Forgetting to specify the mask in dotted-decimal format (e.g., 255.255.255.0) instead of CIDR notation.
Using an incorrect next-hop IP that is not reachable, causing the route to not be installed.
Omitting the 'pref' keyword when trying to set administrative distance, resulting in default distance being used.
Platform Notes
On Cisco NX-OS, the 'ip route' command is similar to Cisco IOS but with some differences. NX-OS supports the 'name' and 'tag' parameters for route identification and filtering, which are not available in IOS. The 'pref' keyword is used instead of 'distance' in IOS. NX-OS also supports the 'track' option for conditional routing, which is also available in IOS but with slightly different syntax. In NX-OS, static routes can be configured per VRF using 'ip route vrf <vrf-name>'. The command is not saved to running-config automatically; you must use 'copy running-config startup-config' to persist. On Nexus 9000 series, static routes support ECMP if multiple next-hops are configured for the same prefix. Unlike IOS, NX-OS does not support the 'permanent' keyword; static routes are always removed if the next-hop becomes unreachable. For interface-based static routes, NX-OS requires the interface to be in an up/up state for the route to be installed. Version differences: earlier NX-OS versions may not support the 'name' parameter; check documentation for your specific release.
Practice for the CCNA 200-301
Test your knowledge with hundreds of CCNA practice questions covering all exam domains.
Practice CCNA Questions