ip route

Adds a static route to the IP routing tables.

Syntax

ip route [ vrf vrf-name ] dest-ip-addr next-hop-addr [ metric ] [ distance distance ] [ tag tag ] [ name string ]
ip route [ vrf vrf-name ] dest-ip-addr { ethernet unit/slot/port | ve number | tunnel tunnel-id } [ metric ] [ name string ]
ip route [ vrf vrf-name ] dest-ip-addr null0 [ name string ]
no ip route [ vrf vrf-name ] dest-ip-addr next-hop-addr [ metric ] [ distance distance ] [ tag tag ] [ name string ]
no ip route [ vrf vrf-name ] dest-ip-addr { ethernet unit/slot/port | ve number | tunnel tunnel-id } [ metric ] [ name string ]
no ip route [ vrf vrf-name ] dest-ip-addr null0 [ name string ]

Parameters

vrf vrf-name
Specifies the VRF associated with the destination IPv4 address.
dest-ip-addr
Specifies the destination IPv4 address and mask in the format A.B.C.D/L (where "L" is the prefix-length of the mask) or A.B.C.D P.Q.R.S (where "PQ.R.S" is the mask value).
next-hop-addr
Specifies the IPv4 address of the next hop.
ethernet unit/slot/port
Specifies the destination Ethernet port.
ve vlan-id
Specifies the outgoing interface type as VE.
tunnel tunnel-id
Specifies the outgoing interface type as tunnel.
null0
Configures the Layer 3 switch to drop IP packets to a specific network or host address by configuring a "null" (sometimes called "null0") static route for the address.
metric
Specifies the cost metric of the route. Valid values range from 1 through 16. The default is 1.
distance distance
Specifies the administrative distance of the route. When comparing otherwise equal routes to a destination, a device prefers lower administrative distances over higher ones. Valid values range from 1 through 255. The default is 1. The value 255 makes the route unusable.
tag tag
Specifies the tag value of the route to use for route filtering with a route map. Valid values range from 0 through 4294967295. The default is 0.
name string
Specifies the static route name.The maximum length of the name is 128 bytes.

Modes

Global configuration mode

Usage Guidelines

The no form of the command followed by the route identifier removes a static route. If the static route includes a name, you must enter the no form of the command twice (once to remove the name and the second time to remove the route from the routing table).

For a default route, enter 0.0.0.0/0 as the destination IP address followed by the next-hop IP address. Physical or virtual interfaces cannot be used as next-hops for a default route.

If you do not want to specify a next-hop IP address, you can instead specify a port or interface number on the device. If you specify an Ethernet port, the device forwards packets destined for the static route’s destination network to the specified interface. Conceptually, this feature makes the destination network like a directly connected network, associated with a device interface.

The port or virtual interface you use for the static route’s next hop must have at least one IP address configured on it. The address does not need to be in the same subnet as the destination network.

ICX 7150 devices do not support tunnels or VRFs.

When a tunnel is configured as the next hop for a static route, the tunnel must already be configured if the destination is a non-default VRF. In contrast, a tunnel can be designated as the next hop in the default VRF before it is configured. The default VRF is used when no VRF is specified in the command.

Examples

The following example configures a static route to 10.95.7.0, using 10.95.6.157 as the next-hop gateway.

device(config)# ip route 10.95.7.0/24 10.95.6.157
 

The following example configures a default route through next-hop IP address 10.2.12.1.

device(config)# ip route 0.0.0.0/0 10.2.12.1
 

The following example configures a static route with an Ethernet interface as the destination.

device(config)# ip route 192.128.2.69 255.255.255.0 ethernet 1/4/1
 

The following example configures a null static route to drop packets destined for network 10.157.22.x.

device(config)# ip route 10.157.22.0 255.255.255.0 null0
 
The following example configures tunnel 1 as the next hop gateway. The tunnel is configured in the default VRF.
device(config)# ip route 56.1.1.0/24 tunnel 1
The following example configures tunnel 5 as the next hop gateway in a non-default VRF, as long as the tunnel already exists.
device(config)# ip route vrf 1 56.1.5.0/24 tunnel 5