Configuring Static Routing

This chapter contains the following sections:

Finding Feature Information

Your software release might not support all the features documented in this module. For the latest caveats and feature information, see the Bug Search Tool at https://tools.cisco.com/bugsearch/ and the release notes for your software release. To find information about the features documented in this module, and to see a list of the releases in which each feature is supported, see the "New and Changed Information"chapter or the Feature History table in this chapter.

Information About Static Routing

Routers forward packets using either route information from route table entries that you manually configure or the route information that is calculated using dynamic routing algorithms.

Static routes, which define explicit paths between two routers, cannot be automatically updated; you must manually reconfigure static routes when network changes occur. Static routes use less bandwidth than dynamic routes. No CPU cycles are used to calculate and analyze routing updates.

You can supplement dynamic routes with static routes where appropriate. You can redistribute static routes into dynamic routing algorithms but you cannot redistribute routing information calculated by dynamic routing algorithms into the static routing table.

You should use static routes in environments where network traffic is predictable and where the network design is simple. You should not use static routes in large, constantly changing networks because static routes cannot react to network changes. Most networks use dynamic routes to communicate between routers but might have one or two static routes configured for special cases. Static routes are also useful for specifying a gateway of last resort (a default router to which all unroutable packets are sent).

Administrative Distance

An administrative distance is the metric used by routers to choose the best path when there are two or more routes to the same destination from two different routing protocols. An administrative distance guides the selection of one routing protocol (or static route) over another, when more than one protocol adds the same route to the unicast routing table. Each routing protocol is prioritized in order of most to least reliable using an administrative distance value.

Static routes have a default administrative distance of 1. A router prefers a static route to a dynamic route because the router considers a route with a low number to be the shortest. If you want a dynamic route to override a static route, you can specify an administrative distance for the static route. For example, if you have two dynamic routes with an administrative distance of 120, you would specify an administrative distance that is greater than 120 for the static route if you want the dynamic route to override the static route.

Directly Connected Static Routes

You must specify only the output interface (the interface on which all packets are sent to the destination network) in a directly connected static route. The router assumes the destination is directly attached to the output interface and the packet destination is used as the next-hop address. The next hop can be an interface, only for point-to-point interfaces. For broadcast interfaces, the next hop must be an IPv4or IPv6 address.

Fully Specified Static Routes

You must specify either the output interface (the interface on which all packets are sent to the destination network) or the next-hop address in a fully specified static route. You can use a fully specified static route when the output interface is a multi-access interface and you need to identify the next-hop address. The next-hop address must be directly attached to the specified output interface.

Floating Static Routes

A floating static route is a static route that the router uses to back up a dynamic route. You must configure a floating static route with a higher administrative distance than the dynamic route that it backs up. In this instance, the router prefers a dynamic route to a floating static route. You can use a floating static route as a replacement if the dynamic route is lost.


Note


By default, a router prefers a static route to a dynamic route because a static route has a smaller administrative distance than a dynamic route.


Remote Next-Hops for Static Routes

You can specify the next-hop address of a neighboring router which is not directly connected to the router for static routes with remote (non-directly attached) next-hops. If a static route has remote next-hops during data-forwarding, the next-hops are recursively used in the unicast routing table to identify the corresponding directly attached next-hop(s) that have reachability to the remote next-hops.

Reliable Static Routing Backup Using Object Tracking Deployment

You can configure Cisco NX-OS to initiate a backup connection from an alternative port if the circuit to the primary gateway is interrupted. You can ensure reliable deployment backups in the case of certain catastrophic events, such as an Internet circuit failure or peer device failure.

Reliable static routing backup using object tracking can determine the state of the primary connection without having to enable a dynamic routing protocol. It also provides a reliable backup solution that can be used for critical circuits that must not go down without automatically engaging a backup circuit.

In a typical scenario, the primary interface of the remote router forwards traffic from the remote LAN to the main office. If the router loses the connection to the main office, the status of the tracked object changes from up to down. When this change occurs, the router removes the routing table entry for the primary interface and installs the preconfigured floating static route on the secondary interface. The router’s secondary interface then forwards traffic to the preconfigured destination. The backup circuit can be configured to use the Internet. When the state of the tracked object changes from down to up, the router reinstalls the routing table entry for the primary interface and removes the floating static route for the secondary interface.

IP Service Level Agreements

This feature uses IP service level agreements (IP SLAs), a network monitoring feature set, to generate ICMP pings to monitor the state of the connection to the primary gateway. An IP SLA is configured to ping a target, such as a publicly routable IP address or a target inside the corporate network. The pings are routed from the primary interface only. A track object is created to monitor the status of the IP SLA configuration. The track object informs the client, the static route, if a state change occurs. The preconfigured floating static route on the secondary interface is installed when the state changes from up to down.


Note


User Datagram Protocol (UDP) echo, or any other protocol supported by IP SLAs, can be used instead of ICMP pings.


For more information on IP SLAs, see the Cisco Nexus 7000 Series NX-OS IP SLAs Configuration Guide.

BFD

This feature supports bidirectional forwarding detection (BFD). BFD is a detection protocol designed to provide fast forwarding-path failure detection times. BFD provides subsecond failure detection between two adjacent devices and can be less CPU-intensive than protocol hello messages because some of the BFD load can be distributed onto the data plane on supported modules. See the , for more information.

Virtualization Support

Static routes support virtual routing and forwarding (VRF) instances. VRFs exist within virtual device contexts (VDCs). By default, Cisco NX-OS places you in the default VDC and default VRF unless you specifically configure another VDC and VRF. For more information, see the Cisco Nexus 7000 Series NX-OS Virtual Device Context Configuration Guide.

Prerequisites for Static Routing

If the next-hop address for a static route is unreachable, the static route will not be added to the unicast routing table.

Guidelines and Limitations for Static Routing

  • You can specify an interface as the next-hop address for a static route only for point-to-point interfaces such as generic routing encapsulation (GRE) tunnels.

  • Starting from Cisco NX-OS Release 8.2(4), static IPv6 route with next-hop as the VxLAN route is supported.

  • The forward referencing of static routes is not supported for track objects.

  • Starting from Cisco NX-OS Release 8.4(1), IPv6 static routes with next-hops that are learnt over a VXLAN tunnel can be added to the Unicast Routing Information Base (URIB). This feature was supported on IPv4 since Cisco NX-OS Release 4.0(1).

  • If you are familiar with the Cisco IOS CLI, be aware that the Cisco NX-OS commands for this feature might differ from the Cisco IOS commands that you would use.

Default Settings for Static Routing Parameters

Default Static Routing Parameters

Parameters Default

Administrative distance

1

RIP feature

Disabled

Configuring Static Routing

Configuring a Static Route for IPv4

Before you begin

Confirm that you are in the correct VDC. To change the VDC, use the switchto vdc command.

SUMMARY STEPS

  1. switch# configure terminal
  2. switch(config)# ip route {ip-prefix | ip-addr/ip-mask} {[next-hop | nh-prefix] | [interface next-hop | nh-prefix]} [tag tag-value] [pref]
  3. (Optional) switch(config)# copy running-config startup-config
  4. (Optional) switch(config)# show ip static-route

DETAILED STEPS

  Command or Action Purpose

Step 1

switch# configure terminal

Enters global configuration mode.

Step 2

switch(config)# ip route {ip-prefix | ip-addr/ip-mask} {[next-hop | nh-prefix] | [interface next-hop | nh-prefix]} [tag tag-value] [pref]

Configures a static route and the interface for this static route. Use ? to display a list of supported interfaces. You can specify a null interface by using null 0. You can optionally configure the next-hop address. The preference value sets the administrative distance. The range is from 1 to 255. The default is 1.

Step 3

(Optional) switch(config)# copy running-config startup-config

(Optional)

Saves the change persistently through reboots and restarts by copying the running configuration to the startup configuration.

Step 4

(Optional) switch(config)# show ip static-route

(Optional)

Displays information about static routes.

Configuration Example

Configuring a Static Route for a null interface.

switch# configure terminal
switch(config)# ip static-route 1.1.1.1/32 null 0
switch(config)# copy running-config startup-config

Use the no ip static-route command to remove the static route.

Configuring a Static Route for IPv6

Before you begin

Confirm that you are in the correct VDC. To change the VDC, use the switchto vdc command.

SUMMARY STEPS

  1. switch# configure terminal
  2. switch(config)# ipv6 route ip6-prefix {nh-prefix | link-local-nh-prefix} | {nh-prefix [interface] | link-local-nh-prefix [interface]} [name nexthop-name] [tag tag-value] [pref]
  3. (Optional) switch(config)# copy running-config startup-config
  4. (Optional) switch(config)# show ipv6 static-route

DETAILED STEPS

  Command or Action Purpose

Step 1

switch# configure terminal

Enters global configuration mode.

Step 2

switch(config)# ipv6 route ip6-prefix {nh-prefix | link-local-nh-prefix} | {nh-prefix [interface] | link-local-nh-prefix [interface]} [name nexthop-name] [tag tag-value] [pref]

Configures a static route and the interface for this static route. Use ? to display a list of supported interfaces. You can specify a null interface by using null 0. You can optionally configure the next-hop address. The preference value sets the administrative distance. The range is from 1 to 255. The default is 1.

Step 3

(Optional) switch(config)# copy running-config startup-config

(Optional)

Saves the change persistently through reboots and restarts by copying the running configuration to the startup configuration.

Step 4

(Optional) switch(config)# show ipv6 static-route

(Optional)

Displays information about static routes.

Example

The following example configures a static route for IPv6:

switch# configure terminal
switch(config)# ipv6 route 2001:0DB8::/48 6::6 null 0

Configuring a Static Route over a VLAN

You can configure a static route without next hop support over a VLAN, also known as a switch virtual switch (SVI).

Before you begin

Ensure that the access port is part of the VLAN.

SUMMARY STEPS

  1. switch# configure terminal
  2. switch(config)# feature interface-vlan
  3. switch(config)# interface vlan vlan-id
  4. switch(config-if)# ip address ip-addr/length
  5. switch(config-if)# ip route ip-addr/length vlan-id
  6. (Optional) switch(config-if)# ip route ip-addr/length vlan-id next-hop-ip-address
  7. (Optional) switch(config-if)# show ip route
  8. (Optional) switch(config)# copy running-config startup-config

DETAILED STEPS

  Command or Action Purpose

Step 1

switch# configure terminal

Enters global configuration mode.

Step 2

switch(config)# feature interface-vlan

Enables VLAN interface mode.

Step 3

switch(config)# interface vlan vlan-id

Creates a switch virtual inteface (SVI) and enters interface configuration mode.

The range for the vlan-id argument is from 1 to 4094, except for the VLANs reserved for the internal switch.

Step 4

switch(config-if)# ip address ip-addr/length

Configures an IP address for the VLAN.

Step 5

switch(config-if)# ip route ip-addr/length vlan-id

Adds an interface static route without a next hop on the SVI.

The IP address is the address that is configured on the interface that is connected to the switch.

Step 6

(Optional) switch(config-if)# ip route ip-addr/length vlan-id next-hop-ip-address

(Optional)

Configures explicit next hop address when you set up a /32 static route over an interface VLAN.

The IP address is the address that is configured on the interface that is connected to the switch.

Step 7

(Optional) switch(config-if)# show ip route

(Optional)

Displays routes from the Unicast Route Information Base (URIB).

Step 8

(Optional) switch(config)# copy running-config startup-config

(Optional)

Saves the change persistently through reboots and restarts by copying the running configuration to the startup configuration.

Example

This example shows how to configure a static route without a next hop over an SVI:

switch# configure terminal
switch(config)# feature interface-vlan
swicth(config)# interface vlan 10
switch(config-if)# ip address 192.0.2.1/8
switch(config-if)# ip route 209.165.200.224/27 vlan 10 <===209,165.200.224 is the IP
address of the interface that is configured on the interface that is directly connected to
the switch.
switch(config-if)# copy running-config startup-config

Note


When you set up a /32 static route over an interface VLAN, you have to configure an explicit next hop by using the ip route ip-addr/length vlan-id next-hop-ip-address command.


This example shows how to configure an explicit next hop when you set up a /32 static route over an interface VLAN:

switch# configure terminal
switch(config)# feature interface-vlan
swicth(config)# interface vlan 10
switch(config-if)# ip address 209.165.202.128/27
switch(config-if)# ip route 209.165.202.130/32 vlan 10 209.165.202.130
switch(config-if)# copy running-config startup-config

What to do next

Use the no ip static-route command to remove the static route.

Configuring Reliable Static Routing Backup Using Object Tracking

You can configure Cisco NX-OS to use Internet Control Message Protocol (ICMP) pings to identify when a connection goes down and initiate a backup connection from any alternative port.

Before you begin

  • Configure both a primary interface and a backup interface to used for reliable static routing backup.

  • Configure an IP SLA with policy-based routing object tracking to be used for reliable static routing backup.

  • Configure a routing policy for static routing to be used for reliable static routing backup.

  • Create a track object to be associated with the static route using the track object-id interface command

  • Ensure that you are in the correct VDC (or use the switchto vdc command).


Note


If you attempt to configure a static route associated with a track object before you create the track object, the static route command is not accepted by the switch.


SUMMARY STEPS

  1. switch# configure terminal
  2. switch(config)# {ip | ipv6} route ip-prefix ip-mask ip-addr track object-number
  3. switch(config)# show {ip | ipv6} static-route track-table
  4. switch(config)# show track track-number
  5. switch(config)# {ip | ipv6} route network-number network-mask {ip-address | interface} [distance] [name name]

DETAILED STEPS

  Command or Action Purpose

Step 1

switch# configure terminal

Enters global configuration mode.

Step 2

switch(config)# {ip | ipv6} route ip-prefix ip-mask ip-addr track object-number

Configures a static route associated with the track object. The object-number argument specifies that the static route is installed only if the configured track object is up.

Step 3

switch(config)# show {ip | ipv6} static-route track-table

Displays information about the IPv4 or IPv6 static-route track table.

Step 4

switch(config)# show track track-number

Displays information about a specific tracked object.

Step 5

switch(config)# {ip | ipv6} route network-number network-mask {ip-address | interface} [distance] [name name]

Configures a floating IPv4 or IPv6 static route on the secondary interface.

The network prefix and mask length must be the same as the static route previously configured for the primary interface associated with a track object. The floating static route should have a higher value of preference than the route associated with the track object.

Configuring Virtualization for IPv4

Before you begin

Confirm that you are in the correct VDC. To change the VDC, use the switchto vdc command.

SUMMARY STEPS

  1. switch# configure terminal
  2. switch(config)# vrf context vrf-name
  3. switch(config-vrf)# ip route {ip-prefix | ip-addr ip-mask} {next-hop | nh-prefix | interface [sub-intf-separtor sub-intf-num ] next-hop } [tag tag-value] [pref]
  4. (Optional) switch(config-vrf)# copy running-config startup-config
  5. (Optional) switch(config-vrf)# show ip static-route vrf vrf-name

DETAILED STEPS

  Command or Action Purpose

Step 1

switch# configure terminal

Enters global configuration mode.

Step 2

switch(config)# vrf context vrf-name

Creates a VRF and enters VRF configuration mode.

Step 3

switch(config-vrf)# ip route {ip-prefix | ip-addr ip-mask} {next-hop | nh-prefix | interface [sub-intf-separtor sub-intf-num ] next-hop } [tag tag-value] [pref]

Configures a static route and the interface for this static route. Use ? to display a list of supported interfaces. You can specify a null interface by using null 0. You can optionally configure the next-hop address. The preference value sets the administrative distance. The range is from 1 to 255. The default is 1.

Step 4

(Optional) switch(config-vrf)# copy running-config startup-config

(Optional)

Saves the change persistently through reboots and restarts by copying the running configuration to the startup configuration.

Step 5

(Optional) switch(config-vrf)# show ip static-route vrf vrf-name

(Optional)

Displays information on static routes.

Example

The following example configures VRF for IPv4.

switch # configure terminal
switch(config)# vrf context StaticVrf
switch(config-vrf)# ip route 192.0.2.0/8 ethernet 1/2 10.0.0.2
switch(config-vrf)# show running-config startup-config

Configuring Virtualization for IPv6

Before you begin

Confirm that you are in the correct VDC. To change the VDC, use the switchto vdc command.

SUMMARY STEPS

  1. switch# configure terminal
  2. switch(config)# vrf context vrf-name
  3. switch(config-vrf)# ipv6 route ip6-prefix {nh-prefix | link-local-nh-prefix } | {next-hop | link-local-net-hop | interface [sub-intf-separtor sub-intf-num] next-hop } [name nexthop-name] [tag tag-value] [pref]
  4. (Optional) switch(config-vrf)# copy running-config startup-config
  5. (Optional) switch(config-vrf)# show ipv6 static-route vrf vrf-name

DETAILED STEPS

  Command or Action Purpose

Step 1

switch# configure terminal

Enters global configuration mode.

Step 2

switch(config)# vrf context vrf-name

Creates a VRF and enters VRF configuration mode.

Step 3

switch(config-vrf)# ipv6 route ip6-prefix {nh-prefix | link-local-nh-prefix } | {next-hop | link-local-net-hop | interface [sub-intf-separtor sub-intf-num] next-hop } [name nexthop-name] [tag tag-value] [pref]

Configures a static route and the interface for this static route. Use ? to display a list of supported interfaces. You can specify a null interface by using null 0. You can optionally configure the next-hop address. The preference value sets the administrative distance. The range is from 1 to 255. The default is 1.

Step 4

(Optional) switch(config-vrf)# copy running-config startup-config

(Optional)

Saves the change persistently through reboots and restarts by copying the running configuration to the startup configuration.

Step 5

(Optional) switch(config-vrf)# show ipv6 static-route vrf vrf-name

(Optional)

Displays information on static routes.

Example

The following example configures virtualization for IPv6:

switch # configure terminal
switch(config)# vrf context StaticVrf
switch(config-vrf)# ipv6 route 2001:0DB8::/48 6::6 ethernet 2/1 2b11::2f01:4c
switch(config-vrf)# copy running-config startup-config

Verifying the Static Routing Configuration

Use one of the following commands to verify the configuration:

Command

Purpose

show {ip | ipv6} static-route

Displays the configured static routes.

show ipv6 static-route vrf vrf-name

Displays static route information for each VRF.

show {ip | ipv6} static-route track-table

Displays information about the IPv4 or IPv6 static-route track table.

show track track-number

Displays information about a specific tracked object.

Related Documents for Static Routing

Related Topic

Document Title

Static Routing CLI

Cisco Nexus 7000 Series NX-OS Unicast Routing Command Reference

VDCs

Cisco Nexus 7000 Series NX-OS Virtual Device Context Configuration Guide

Feature History for Static Routing

This table includes only the updates for those releases that have resulted in additions or changes to the feature.

Feature Name

Releases

Feature Information

Static IPv6 Route

8.2(4)

Added support for static IPv6 route with next-hop as the VxLAN route.

Static Route over VLAN

6.2(2a)

This feature was introduced.

Reliable static routing backup using object tracking

6.2(2)

This feature was introduced.

Static routing

6.0(1)

Updated for F2 Series modules.

Layer 3 routing using a mixed chassis

5.1(1)

This feature was introduced.

Static routing

5.1(1)

Added the name option to the ip route command.

BFD

5.0(2)

Added support for BFD. See the Cisco Nexus 7000 Series NX-OS Interfaces Configuration Guide, for more information.

Static routing

4.0(1)

This feature was introduced.