ip route

Adds a static route to the IP routing table.

Syntax

ip route dest-ip-addr [ next-hop-vrf next-vrf-name ] next-hop-address [ metric ] [ distance distance ] [ tag tag-number ] [ name name-value ]
ip route dest-ip-addr { ethernet slot/port | port-channel number | ve ve-number } [ metric ] [ distance distance ] [ tag tag-number ] [ name name-value ]
ip route dest-ip-addr null 0 [ metric ] [ distance distance ] [ tag tag-number ] [ name name-value ]
ip route next-hop-recursion
no ip route dest-ip-addr [ next-hop-vrf next-vrf-name ] next-hop-address
no ip route dest-ip-addr { ethernet slot/port | ve ve-number }
no ip route dest-ip-addr null 0
no ip route next-hop-recursion

Parameters

next-hop-vrf vrf-name
Specifies the name of the non-default VRF to be used for as the next-hop gateway.
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).
next-hop-addr
Specifies the IPv4 address of the next hop.
ethernet slot / port
Specifies the destination Ethernet port.
next-hop-vrf next-vrf-name
VRF name of the next hop.
port-channel number
Specifies a port-channel interface.
ve vlan-id
Specifies the outgoing interface type as VE.
null 0
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, an SLX-OS device prefers lower administrative distances over higher ones. Valid values range from 1 through 254. The default is 1.
tag tag-number
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.
next-hop-recursion
Specifies that if the next hop for a static route is reachable, then that route is added to the routing table.
name name-value
Specifies the name to be assigned to this IP route. This field can be used to assign a meaningful, human readable description to this route configuration. Maximum length 127 characters.

Modes

Global configuration mode

VRF configuration mode

Usage Guidelines

The no form of the command followed by the route identifier removes a static route.

If you do not want to specify a next-hop IP address, you can instead specify a physical or virtual interface on the SLX-OS 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 an SLX-OS 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.

For a default route, use the following as the destination IP address 0.0.0.0/0.

You can create a null route for traffic for traffic that should not be forwarded. To create a null route, use the key phrase null 0 as the next hop.

Examples

The following example configures a static route to 10.95.7.0 addresses, 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 to next-hop IP address 10.24.4.1.

device(config)# ip route 0.0.0.0/0 10.24.4.1 
 

The following example configures a static route with an Ethernet interface as the destination, and assigns a name to it.

device(config)# ip route 192.128.2.69/24 ethernet 4/1 name route-sj-01
 

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/24 null 0
 

The following example configures non-recursive lookup in the default VRF.

device(config)# ip route next-hop-recursion
 

The following example configures non-recursive lookup in a non-default VRF named red.

device(config)# vrf red
device(config-vrf-red)# address-family ipv4 unicast
device(config-vrf-red-ipv4-unicast)# ip route next-hop-recursion