ip route

Use this command to add or remove a static IP route.

Syntax

ip route {prefix mask | prefix/prefix-length} {ip-address [recursive] | interface interface-name | vlan vlan-id | vrf egress-vrf | blackhole | reject | probe {default | probe-name}} [distance] [tag tag-id]
no ip route {prefix mask | prefix/prefix-length} {ip-address [recursive] | interface interface-name| vlan vlan-id | vrf egress-vrf | blackhole | reject | probe {default | probe-name}} [distance] [tag tag-id]

Parameters

prefix Specifies a destination IP address prefix.
mask Specifies a destination prefix mask.
prefix/prefix-length Specifies a destination IP address in prefix/prefix-length format.
ip-address Specifies a next-hop router IP address.
interface interface-name Specifies the next-hop interface.
vlan vlan-id Specifies the next-hop VLAN. Valid values are 1 - 4094.
vrf egress-vrf Specifies the egress VRF router that will determine the next hop for the route (S-, K-Series).
blackhole Specifies that packets destined for this route‘s subnet are silently dropped. An ICMP network unreachable message is not sent to the packet source.
reject Specifies that packets destined for this route‘s subnet are dropped, and an ICMP network unreachable message is sent to the packet source.
recursive (Optional) Specifies that the next-hop interface is determined by route lookup.
probe default | probe-name Specifies either a default or named probe to be configured for this static route.
distance (Optional) Specifies an administrative distance metric for this route. Valid values are 1 (default) to 255. Routes with lower values receive higher preference in route selection.
tag tag-id (Optional) Specifies an OSPF tag ID for this route. Valid values are 1 - 4294967295.

Defaults

  • If distance is not specified, the default value of 1 will be applied.
  • If an OSPF tag ID is not specified, no OSPF tag is associated with the route.
  • If recursive is not specified, see usage section below.

Mode

Configuration command mode.

Usage

This command is used to configure static routes. The route will forward IP traffic depending upon the IP forwarding setting of the routing interface. Routing interfaces are set for IP forwarding by default. To configure a static route as a non-forwarding IP route, set IP forwarding for the routing interface to non-forwarding using the no ip forwarding command in interface configuration mode.

On the S- and K-Series, use the vrf egress-vrf parameter to point to the egress VRF router that will perform the next-hop lookup for this static route. Using the vrf egress-vrf parameter is more dynamic than configuring a standard static route, in that it determines the next hop based upon a route table lookup. A standard static route specifies a single next hop. Should that next hop be unavailable, the subnet is no longer reachable. A standard static route can be configured to reach the next hop that is a member of a different VRF using the syntax: ip route destination-prefix/length next-hop-address interface next-hop-interface. Because the vrf egress-vrf parameter provides greater flexibility in determining the next hop, it is recommended that you use the vrf egress-vrf parameter.

Note

Note

The default VRF router is referred to as the global router. Named VRF routers within a device configured using the set router vrf create command are referred to as non-global VRF routers. Static routes are supported between both the global router and any non-global VRF router and between any two non-global VRF routers (S-, K-Series).

If you only enter the prefix/length and the IP address of the nexthop router and do not specify the optional recursive parameter, a search is performed of all configured subnets for a subnet containing the next?hop. If found, the static route will be anchored to that interface, else it will become a recursive route.

When configuring a probe for the static route using the probe option, the probe session is created on the nexthop address. When the probe session goes down, the static route is disabled. When the probe session comes up, the static route is enabled.

See ipv6 route for IPv6 static route configuration command information.

The “no” form of this command removes the static IP route.

Examples

This example shows how to set IP address 10.1.2.3 as the next hop gateway to destination address 10.0.0.0.:

System(rw-router-config)->ip route 10.0.0.0 255.0.0.0 10.1.2.3

This example shows how to set VLAN 100 as the next hop interface to destination address 10.0.0.0:

System(rw-router-config)->ip route 10.0.0.0 255.0.0.0 vlan 100

This S- and K-Series example shows how to configure, in the VRF Alpha-Group context, the VRF Internet-Access to perform the next hop lookup to destination address 134.141.95.100/24:

System(su)->router Alpha-Group
System(su-*ha-Group)->configure
System(su-*ha-Group-config)->ip route 134.141.95.100/24 vrf Internet-Access