Courseiva
RoutingGlobal Config

ip route [network] [mask] [next-hop]

Configures a static route in the routing table to forward traffic to a specific destination network via a next-hop IP address or exit interface.

Definition: ip route [network] [mask] [next-hop] is a Cisco IOS global config command. Configures a static route in the routing table to forward traffic to a specific destination network via a next-hop IP address or exit interface.

Overview

The `ip route` command is a fundamental tool in Cisco IOS for configuring static routes, which manually direct traffic to a specific destination network via a next-hop IP address or an exit interface. Static routes are essential in networks where dynamic routing protocols are not desired or feasible, such as in small networks, stub networks, or for providing default routes. They offer precise control over routing paths and are often used for security, traffic engineering, or as a fallback when dynamic routing fails.

Unlike dynamic routing protocols (e.g., OSPF, EIGRP) that automatically learn and adapt to network changes, static routes remain unchanged until manually modified, making them predictable but less resilient. Network engineers reach for `ip route` when they need a simple, deterministic path to a remote network, such as connecting a branch office to a central site via a single WAN link, or when configuring a default route to an ISP. The command operates in global configuration mode and directly modifies the running configuration, which can be saved to startup configuration with `copy running-config startup-config`.

It requires privileged EXEC access (enable mode) to enter global config. A key IOS behavior is that static routes are immediately added to the routing table if the next-hop is reachable; if the next-hop becomes unreachable, the route is removed from the routing table but remains in the configuration. Static routes can also be configured with an administrative distance to act as floating static routes, providing backup paths.

Understanding `ip route` is foundational for CCNA and CCNP candidates, as it appears in troubleshooting scenarios, redistribution, and policy-based routing contexts.

Syntax·Global Config
ip route [network] [mask] [next-hop]

When to Use This Command

  • Connecting a branch office to a central headquarters over a WAN link with a static default route.
  • Providing a backup route with a higher administrative distance for floating static routes.
  • Directing traffic to a specific server or network segment that is not reachable via dynamic routing.
  • Configuring a static route to a stub network that has only one path to the rest of the network.

Parameters

ParameterSyntaxDescription
networkA.B.C.DThe destination network IP address (e.g., 192.168.1.0). This is the network you want to reach. Common mistakes include using a host address instead of a network address, or forgetting to include the subnet mask.
maskA.B.C.DThe subnet mask for the destination network (e.g., 255.255.255.0). It defines the network portion of the address. A common error is using an incorrect mask that does not match the actual network design.
next-hopA.B.C.DThe IP address of the next-hop router (e.g., 10.0.0.1) or the exit interface (e.g., GigabitEthernet0/0). This is where packets for the destination network are forwarded. If using an interface, the router will perform ARP for the destination IP; if using an IP, the router must have a route to that next-hop. A common mistake is using an unreachable next-hop address.

Command Examples

Basic Static Route to a Remote Network

ip route 192.168.2.0 255.255.255.0 10.0.0.2

This command adds a static route to network 192.168.2.0/24 via next-hop 10.0.0.2. No output is displayed if successful; the route is added to the routing table.

Floating Static Route with Higher Administrative Distance

ip route 0.0.0.0 0.0.0.0 10.0.0.3 200

This configures a default route via 10.0.0.3 with an administrative distance of 200, making it a backup route. It will only be used if routes with lower AD (e.g., from OSPF) are unavailable.

Understanding the Output

The 'ip route' command does not produce output upon successful configuration. To verify, use 'show ip route' or 'show ip route static'. In 'show ip route', static routes appear with code 'S'.

The output shows the destination network, mask, next-hop, administrative distance, and metric. For example: 'S 192.168.2.0/24 [1/0] via 10.0.0.2'. The [1/0] indicates AD=1 and metric=0.

A valid route shows the next-hop reachable; if the next-hop is down, the route may not appear or be marked as 'subnetted' but inactive. Watch for routes with high AD that may be overridden by dynamic protocols.

Configuration Scenarios

Configure a default static route to an ISP

A small office router needs to send all internet-bound traffic to an ISP gateway. The router has a single WAN connection to the ISP.

Topology

R1(Gi0/0)---203.0.113.0/30---(Gi0/0)ISP

Steps

  1. 1.Step 1: Enter privileged EXEC mode: Router> enable
  2. 2.Step 2: Enter global configuration mode: Router# configure terminal
  3. 3.Step 3: Configure the default route: Router(config)# ip route 0.0.0.0 0.0.0.0 203.0.113.2
  4. 4.Step 4: Exit configuration mode: Router(config)# end
  5. 5.Step 5: Verify the route: Router# show ip route
Configuration
! Configure default static route
Router(config)# ip route 0.0.0.0 0.0.0.0 203.0.113.2

Verify: Use `show ip route` to see the static route. Expected output includes a line: S* 0.0.0.0/0 [1/0] via 203.0.113.2

Watch out: Forgetting to specify the next-hop IP; using an interface name without a next-hop can cause ARP issues if the destination is not directly connected.

Configure a floating static route for backup

A branch router has a primary OSPF link to headquarters and a backup DSL link. The backup static route should only be used if the OSPF route fails.

Topology

R1(Gi0/0)---10.0.0.0/30---(Gi0/0)R2 (primary OSPF) R1(Gi0/1)---192.168.1.0/30---(Gi0/0)R3 (backup DSL)

Steps

  1. 1.Step 1: Enter global configuration mode: Router# configure terminal
  2. 2.Step 2: Configure the floating static route with administrative distance 150: Router(config)# ip route 10.0.0.0 255.255.255.0 192.168.1.2 150
  3. 3.Step 3: Exit and verify: Router(config)# end
  4. 4.Step 4: Check routing table: Router# show ip route 10.0.0.0
Configuration
! Floating static route with AD 150
Router(config)# ip route 10.0.0.0 255.255.255.0 192.168.1.2 150

Verify: When OSPF is up, the route shows with AD 110. When OSPF fails, the static route appears with AD 150. Use `show ip route 10.0.0.0` to see which route is active.

Watch out: Setting the administrative distance too low (e.g., 1) could override the dynamic route unintentionally. Ensure the AD is higher than the dynamic protocol's default.

Troubleshooting with This Command

When troubleshooting static routes, the primary command is `show ip route [network]` to verify if the route is present and active. A healthy static route appears with an 'S' prefix and a next-hop IP that is reachable. If the route is missing, check the configuration with `show running-config | include ip route`.

Common symptoms include: 'S' route present but not used (e.g., due to a more specific route), or the route is in the config but not in the routing table (next-hop unreachable). Focus on the '[1/0]' values: the first number is administrative distance (default 1 for static), the second is metric (0 for static). If the next-hop is unreachable, the route will not appear in the routing table.

Use `ping` to test reachability to the next-hop. Also, `traceroute` can confirm the path taken. A step-by-step diagnostic flow: 1) Verify the static route is configured: `show running-config | section ip route`. 2) Check if the route is in the routing table: `show ip route [network]`. 3) If missing, ping the next-hop: `ping [next-hop]`. 4) If ping fails, check interface status and IP connectivity. 5) If ping succeeds, verify that the subnet mask matches the destination network. 6) Use `debug ip routing` to see route installation events (caution: can be CPU-intensive).

Correlate with `show ip interface brief` to ensure interfaces are up. For floating static routes, compare administrative distances: `show ip route [network]` will show the active route. Also, check for routing loops with `traceroute`.

Remember that static routes do not adapt to topology changes, so if a link fails, the route remains in config but is removed from the routing table until the next-hop becomes reachable again.

CCNA Exam Tips

1.

Remember that static routes have an administrative distance of 1 by default, which is lower than most dynamic protocols (e.g., OSPF AD=110).

2.

Floating static routes use a higher AD (e.g., 200) to act as backups; they only appear in the routing table when the primary route fails.

3.

The next-hop must be directly connected; otherwise, the route will not be installed (the router must have a route to the next-hop).

4.

You can specify an exit interface instead of a next-hop (e.g., 'ip route 0.0.0.0 0.0.0.0 serial0/0/0') for point-to-point links.

Common Mistakes

Using an incorrect subnet mask (e.g., 255.255.255.0 instead of 255.255.0.0) leading to incomplete routing.

Specifying a next-hop that is not directly connected, causing the route to be rejected or not installed.

Forgetting to add a default route (0.0.0.0 0.0.0.0) for internet-bound traffic, resulting in dropped packets.

ip route [network] [mask] [next-hop] vs ip default-gateway [ip]

The 'ip route' and 'ip default-gateway' commands are commonly confused because both specify a next-hop for traffic destined to remote networks. However, 'ip route' is used for static routing on routers or layer 3 switches with IP routing enabled, while 'ip default-gateway' is intended for layer 2 switches that do not run IP routing and need a gateway for management traffic only.

Aspectip route [network] [mask] [next-hop]ip default-gateway [ip]
ScopeLayer 3 routing; all IP trafficManagement traffic only (e.g., Telnet, SNMP)
Routing requirementIP routing must be enabled ('ip routing')IP routing must be disabled ('no ip routing')
Configuration modeGlobal configurationGlobal configuration
PersistenceSaved in running/startup configSaved in running/startup config
PrecedenceOverrides 'ip default-gateway' if IP routing is onIgnored if IP routing is enabled
Typical useStatic routing on routers and multilayer switchesLayer 2 switch management access

Use 'ip route [network] [mask] [next-hop]' when the device is a router or a switch with IP routing enabled and you need to manually add a route (including a default route) to the routing table.

Use 'ip default-gateway [ip]' when the device is a layer 2 switch without IP routing and you need to specify a gateway for remote management (e.g., SSH, HTTP, SNMP).

Platform Notes

In IOS-XE (e.g., Catalyst 9000 switches), the `ip route` command syntax is identical to classic IOS, but the output of `show ip route` may include additional fields like 'U' for per-user static route. On NX-OS (e.g., Nexus switches), the equivalent command is `ip route [network] [mask] [next-hop]` but note that NX-OS uses a different default administrative distance for static routes (1 vs IOS's 1, same). However, NX-OS requires the `ip routing` feature to be enabled first.

On ASA firewalls, static routes are configured with `route [interface] [network] [mask] [gateway] [distance]` (e.g., `route outside 0.0.0.0 0.0.0.0 203.0.113.2 1`). IOS-XR uses a similar syntax but in XR config mode: `router static` then `address-family ipv4 unicast` then `0.0.0.0/0 203.0.113.2`. Between IOS versions, the command has remained stable from 12.x through 16.x, but newer versions support VRF-aware static routes with `ip route vrf [vrf-name]`.

Always check the specific platform documentation for any nuances.

Related Commands

Practice for the CCNA 200-301

Test your knowledge with practice questions covering all CCNA 200-301 exam domains.

Practice CCNA 200-301 Questions