Implementing Static Routes

This module describes how to implement static routes.

Static routes are user-defined routes that cause packets moving between a source and a destination to take a specified path. Static routes can be important if the Cisco IOS XR software cannot build a route to a particular destination. They are useful for specifying a gateway of last resort to which all unroutable packets are sent.


Note


For more information about static routes on the Cisco IOS XR software and complete descriptions of the static routes commands listed in this module, see the Related Documents section of this module. To locate documentation for other commands that might appear while performing a configuration task, search online in the Cisco ASR 9000 Series Aggregation Services Router Commands Master List.


Feature History for Implementing Static Routes

Release

Modification

Release 3.7.2

This feature was introduced.

Release 4.0.1

The Dynamic ECMP Support for IGP Prefixes feature was added.

Release 4.2.1

The Enhanced Object Tracking for IP Static feature was added.

Prerequisites for Implementing Static Routes

You must be in a user group associated with a task group that includes the proper task IDs. The command reference guides include the task IDs required for each command. If you suspect user group assignment is preventing you from using a command, contact your AAA administrator for assistance.

Restrictions for Implementing Static Routes

These restrictions apply while implementing Static Routes:

  • Static routing to an indirect next hop, (any prefix learnt through the RIB and may be more specific over the AIB), that is part of a local subnet requires configuring static routes in the global table indicating the egress interfaces as next hop. To avoid forward drop, configure static routes in the global table indicating the next-hop IP address to be the next hop.

  • Generally, a route is learnt from the AIB in the global table and is installed in the FIB. However, this behavior will not be replicated to leaked prefixes. Because the AIB from the global table is not present in the VRF, the leaked FIB entry takes reference from the RIB rather than the same view as the global table, which also relies on the AIB. This could lead to inconsistencies in forwarding behavior.

  • When you configure static route under VRF for multiple outgoing interfaces, ensure to configure fully specified static routes. For more information see, Fully Specified Static Routes.

Information About Implementing Static Routes

To implement static routes you need to understand the following concepts:

Static Route Functional Overview

Networking devices forward packets using route information that is either manually configured or dynamically learned using a routing protocol. Static routes are manually configured and define an explicit path between two networking devices. Unlike a dynamic routing protocol, static routes are not automatically updated and must be manually reconfigured if the network topology changes. The benefits of using static routes include security and resource efficiency. Static routes use less bandwidth than dynamic routing protocols, and no CPU cycles are used to calculate and communicate routes. The main disadvantage to using static routes is the lack of automatic reconfiguration if the network topology changes.

Static routes can be redistributed into dynamic routing protocols, but routes generated by dynamic routing protocols cannot be redistributed into the static routing table. No algorithm exists to prevent the configuration of routing loops that use static routes.

Static routes are useful for smaller networks with only one path to an outside network and to provide security for a larger network for certain types of traffic or links to other networks that need more control. In general, most networks use dynamic routing protocols to communicate between networking devices but may have one or two static routes configured for special cases.

Default Administrative Distance

Static routes have a default administrative distance of 1. A low number indicates a preferred route. By default, static routes are preferred to routes learned by routing protocols. Therefore, you can configure an administrative distance with a static route if you want the static route to be overridden by dynamic routes. For example, you could have routes installed by the Open Shortest Path First (OSPF) protocol with an administrative distance of 120. To have a static route that would be overridden by an OSPF dynamic route, specify an administrative distance greater than 120.

Directly Connected Routes

The routing table considers the static routes that point to an interface as “directly connected.” Directly connected networks are advertised by IGP routing protocols if a corresponding interface command is contained under the router configuration stanza of that protocol.

In directly attached static routes, only the output interface is specified. The destination is assumed to be directly attached to this interface, so the packet destination is used as the next hop address. The following example shows how to specify that all destinations with address prefix 2001:0DB8::/32 are directly reachable through interface GigabitEthernet 0/5/0/0:


  RP/0/RSP0/CPU0:router(config)# router static
  RP/0/RSP0/CPU0:router(config-static)# address-family ipv6 unicast 
  RP/0/RSP0/CPU0:router(config-static-afi)# 2001:0DB8::/32 gigabitethernet 0/5/0/0

Directly attached static routes are candidates for insertion in the routing table only if they refer to a valid interface; that is, an interface that is both up and has IPv4 or IPv6 enabled on it.

Recursive Static Routes

In a recursive static route, only the next hop is specified. The output interface is derived from the next hop. The following example shows how to specify that all destinations with address prefix 2001:0DB8::/32 are reachable through the host with address 2001:0DB8:3000::1:


  RP/0/RSP0/CPU0:router(config)# router static
  RP/0/RSP0/CPU0:router(config-static)# address-family ipv6 unicast 
  RP/0/RSP0/CPU0:router(config-static-afi)# 2001:0DB8::/32 2001:0DB8:3000::1

A recursive static route is valid (that is, it is a candidate for insertion in the routing table) only when the specified next hop resolves, either directly or indirectly, to a valid output interface, provided the route does not self-recurse, and the recursion depth does not exceed the maximum IPv6 forwarding recursion depth.

A route self-recurses if it is itself used to resolve its own next hop. If a static route becomes self-recursive, RIB sends a notification to static routes to withdraw the recursive route.

Assuming a BGP route 2001:0DB8:3000::0/16 with next hop of 2001:0DB8::0104, the following static route would not be inserted into the IPv6 RIB because the BGP route next hop resolves through the static route and the static route resolves through the BGP route making it self-recursive:


  RP/0/RSP0/CPU0:router(config)# router static
  RP/0/RSP0/CPU0:router(config-static)# address-family ipv6 unicast 
  RP/0/RSP0/CPU0:router(config-static-afi)# 001:0DB8::/32 2001:0DB8:3000::1

This static route is not inserted into the IPv6 routing table because it is self-recursive. The next hop of the static route, 2001:0DB8:3000:1, resolves through the BGP route 2001:0DB8:3000:0/16, which is itself a recursive route (that is, it only specifies a next hop). The next hop of the BGP route, 2001:0DB8::0104, resolves through the static route. Therefore, the static route would be used to resolve its own next hop.

It is not normally useful to manually configure a self-recursive static route, although it is not prohibited. However, a recursive static route that has been inserted in the routing table may become self-recursive as a result of some transient change in the network learned through a dynamic routing protocol. If this occurs, the fact that the static route has become self-recursive will be detected and it will be removed from the routing table, although not from the configuration. A subsequent network change may cause the static route to no longer be self-recursive, in which case it is re-inserted in the routing table.

Fully Specified Static Routes

In a fully specified static route, both the output interface and next hop are specified. This form of static route is used when the output interface is multiaccess and it is necessary to explicitly identify the next hop. The next hop must be directly attached to the specified output interface. The following example shows a definition of a fully specified static route:


RP/0/RSP0/CPU0:router(config)# router static
RP/0/RSP0/CPU0:router(config-static)# address-family ipv6 unicast 
RP/0/RSP0/CPU0:router(config-static-afi)# 2001:0DB8::/32 Gigethernet0/0/0/0 2001:0DB8:3000::1

A fully specified route is valid (that is, a candidate for insertion into the routing table) when the specified interface, IPv4 or IPv6, is enabled and up.

Floating Static Routes

Floating static routes are static routes that are used to back up dynamic routes learned through configured routing protocols. A floating static route is configured with a higher administrative distance than the dynamic routing protocol it is backing up. As a result, the dynamic route learned through the routing protocol is always preferred to the floating static route. If the dynamic route learned through the routing protocol is lost, the floating static route is used in its place. The following example shows how to define a floating static route:


  RP/0/RSP0/CPU0:router(config)# router static
  RP/0/RSP0/CPU0:router(config-static)# address-family ipv6 unicast 
  RP/0/RSP0/CPU0:router(config-static-afi)# 2001:0DB8::/32 2001:0DB8:3000::1 210

Any of the three types of static routes can be used as a floating static route. A floating static route must be configured with an administrative distance that is greater than the administrative distance of the dynamic routing protocol because routes with smaller administrative distances are preferred.


Note


By default, static routes have smaller administrative distances than dynamic routes, so static routes are preferred to dynamic routes.


Default VRF

A static route is always associated with a VPN routing and forwarding (VRF) instance. The VRF can be the default VRF or a specified VRF. Specifying a VRF, using the vrf vrf-name command, allows you to enter VRF configuration mode for a specific VRF where you can configure a static route. If a VRF is not specified, a default VRF static route is configured.

IPv4 and IPv6 Static VRF Routes

An IPv4 or IPv6 static VRF route is the same as a static route configured for the default VRF. The IPv4 and IPV6 address families are supported in each VRF.

Dynamic ECMP

The dynamic ECMP (equal-cost multi-path) for IGP (Interior Gateway Protocol) prefixes feature supports dynamic selection of ECMP paths ranging from 1 to 64 IGP paths. ECMP for non-recursive prefixes is dynamic. ASR 9000 Enhanced Ethernet Line Card supports 64 ECMP paths for IGP prefixes.

This feature enables loadbalancing support in hardware among egress links.


Note


8-32 ECMP paths are available for BGP recursive prefixes. The ASR 9000 Enhanced Ethernet Line Card supports 32 ECMP paths for BGP prefixes and the ASR 9000 Ethernet Line Card supports 8 ECMP paths for BGP prefixes.

How to Implement Static Routes

This section contains the following procedures:

Configure Static Route

Static routes are entirely user configurable and can point to a next-hop interface, next-hop IP address, or both. In the software, if an interface was specified, then the static route is installed in the Routing Information Base (RIB) if the interface is reachable. If an interface was not specified, the route is installed if the next-hop address is reachable. The only exception to this configuration is when a static route is configured with the permanent attribute, in which case it is installed in RIB regardless of reachability.

This task explains how to configure a static route.

SUMMARY STEPS

  1. configure
  2. router static
  3. vrf vrf-name
  4. address-family { ipv4 | ipv6 } { unicast | multicast }
  5. prefix mask [vrf vrf-name ] { ip-address | interface-type interface-instance } [ distance ] [ description text ] [ tag tag ] [ permanent ]
  6. Use the commit or end command.

DETAILED STEPS


Step 1

configure

Example:


RP/0/RSP0/CPU0:router# configure

Enters global configuration mode.

Step 2

router static

Example:


RP/0/RSP0/CPU0:router(config)# router static 

Enters static route configuration mode.

Step 3

vrf vrf-name

Example:


RP/0/RSP0/CPU0:router(config-static)# vrf vrf_A

(Optional) Enters VRF configuration mode.

If a VRF is not specified, the static route is configured under the default VRF.

Step 4

address-family { ipv4 | ipv6 } { unicast | multicast }

Example:


RP/0/RSP0/CPU0:router(config-static-vrf)# address-family ipv4 unicast 

Enters address family mode.

Step 5

prefix mask [vrf vrf-name ] { ip-address | interface-type interface-instance } [ distance ] [ description text ] [ tag tag ] [ permanent ]

Example:


RP/0/RSP0/CPU0:router(config-static-vrf-afi)# 10.0.0.0/8 172.20.16.6 110

Configures an administrative distance of 110.

  • This example shows how to route packets for network 10.0.0.0 through to a next hop at 172.20.16.6 if dynamic information with administrative distance less than 110 is not available.

Step 6

Use the commit or end command.

commit —Saves the configuration changes and remains within the configuration session.

end —Prompts user to take one of these actions:
  • Yes — Saves configuration changes and exits the configuration session.

  • No —Exits the configuration session without committing the configuration changes.

  • Cancel —Remains in the configuration session, without committing the configuration changes.


A default static route is often used in simple router topologies. In the following example, a route is configured with an administrative distance of 110.


  configure
   router static
    address-family ipv4 unicast 
    0.0.0.0/0 2.6.0.1 110
    end

Configure Floating Static Route

This task explains how to configure a floating static route.

SUMMARY STEPS

  1. configure
  2. router static
  3. vrf vrf-name
  4. address-family { ipv4 | ipv6 } { unicast | multicast }
  5. prefix mask [vrf vrf-name ] { ip-address | interface-type interface-instance } [ distance ] [ description text ] [ tag tag ] [ permanent ]
  6. Use the commit or end command.

DETAILED STEPS


Step 1

configure

Example:


RP/0/RSP0/CPU0:router# configure

Enters global configuration mode.

Step 2

router static

Example:


RP/0/RSP0/CPU0:router(config)# router static 

Enters static route configuration mode.

Step 3

vrf vrf-name

Example:


RP/0/RSP0/CPU0:router(config-static)# vrf vrf_A

(Optional) Enters VRF configuration mode.

If a VRF is not specified, the static route is configured under the default VRF.

Step 4

address-family { ipv4 | ipv6 } { unicast | multicast }

Example:


RP/0/RSP0/CPU0:router(config-static-vrf)# address-family ipv6 unicast 

Enters address family mode.

Step 5

prefix mask [vrf vrf-name ] { ip-address | interface-type interface-instance } [ distance ] [ description text ] [ tag tag ] [ permanent ]

Example:


RP/0/RSP0/CPU0:router(config-static-vrf-afi)# 2001:0DB8::/32 2001:0DB8:3000::1 201

Configures an administrative distance of 201.

Step 6

Use the commit or end command.

commit —Saves the configuration changes and remains within the configuration session.

end —Prompts user to take one of these actions:
  • Yes — Saves configuration changes and exits the configuration session.

  • No —Exits the configuration session without committing the configuration changes.

  • Cancel —Remains in the configuration session, without committing the configuration changes.


A floating static route is often used to provide a backup path if connectivity fails. In the following example, a route is configured with an administrative distance of 201.


  configure
   router static
    address-family ipv6 unicast 
    2001:0DB8::/32 2001:0DB8:3000::1 201
    end

Configure Static Routes Between PE-CE Routers

This task explains how to configure static routing between PE-CE routers.


Note


VRF fallback is not supported with IPv6 VPN Provider Edge (6VPE).


SUMMARY STEPS

  1. configure
  2. router static
  3. vrf vrf-name
  4. address-family { ipv4 | ipv6 } { unicast | multicast }
  5. prefix mask [vrf vrf-name ] { ip-address | interface-type interface- path-id } [ distance ] [ description text ] [ tag tag ] [ permanent ]
  6. Use the commit or end command.

DETAILED STEPS


Step 1

configure

Example:


RP/0/RSP0/CPU0:router# configure

Enters global configuration mode.

Step 2

router static

Example:


RP/0/RSP0/CPU0:router(config)# router static 

Enters static route configuration mode.

Step 3

vrf vrf-name

Example:


RP/0/RSP0/CPU0:router(config-static)# vrf vrf_A

(Optional) Enters VRF configuration mode.

If a VRF is not specified, the static route is configured under the default VRF.

Step 4

address-family { ipv4 | ipv6 } { unicast | multicast }

Example:


RP/0/RSP0/CPU0:router(config-static-vrf)# address-family ipv6 unicast 

Enters address family mode.

Step 5

prefix mask [vrf vrf-name ] { ip-address | interface-type interface- path-id } [ distance ] [ description text ] [ tag tag ] [ permanent ]

Example:


RP/0/RSP0/CPU0:router(config-static-vrf-afi)# 2001:0DB8::/32 2001:0DB8:3000::1 201

Configures an administrative distance of 201.

Step 6

Use the commit or end command.

commit —Saves the configuration changes and remains within the configuration session.

end —Prompts user to take one of these actions:
  • Yes — Saves configuration changes and exits the configuration session.

  • No —Exits the configuration session without committing the configuration changes.

  • Cancel —Remains in the configuration session, without committing the configuration changes.


In the following example, a static route between PE and CE routers is configured, and a VRF is associated with the static route:


  configure
   router static
    vrf vrf_A
    address-family ipv4 unicast 
    0.0.0.0/0 2.6.0.2 120
    end

Change Maximum Number of Allowable Static Routes

This task explains how to change the maximum number of allowable static routes.

Before you begin


Note


The number of static routes that can be configured on a router for a given address family is limited by default to 4000. The limit can be raised or lowered using the maximum path command. Note that if you use the maximum path command to reduce the configured maximum allowed number of static routes for a given address family below the number of static routes currently configured, the change is rejected. In addition, understand the following behavior: If you commit a batch of routes that would, when grouped, push the number of static routes configured above the maximum allowed, the first n routes in the batch are accepted. The number previously configured is accepted, and the remainder are rejected. The n argument is the difference between the maximum number allowed and number previously configured.


SUMMARY STEPS

  1. configure
  2. router static
  3. maximum path { ipv4 | ipv6 } value
  4. Use the commit or end command.

DETAILED STEPS


Step 1

configure

Example:


RP/0/RSP0/CPU0:router# configure

Enters global configuration mode.

Step 2

router static

Example:


RP/0/RSP0/CPU0:router(config)# router static

Enters static route configuration mode.

Step 3

maximum path { ipv4 | ipv6 } value

Example:


RP/0/RSP0/CPU0:router(config-static)# maximum path ipv4 10000

Changes the maximum number of allowable static routes.

  • Specify IPv4 or IPv6 address prefixes.

  • Specify the maximum number of static routes for the given address family. The range is from 1 to 140000.

  • This example sets the maximum number of static IPv4 routes to 10000.

Step 4

Use the commit or end command.

commit —Saves the configuration changes and remains within the configuration session.

end —Prompts user to take one of these actions:
  • Yes — Saves configuration changes and exits the configuration session.

  • No —Exits the configuration session without committing the configuration changes.

  • Cancel —Remains in the configuration session, without committing the configuration changes.


Configuring a static route to point at interface null 0 may be used for discarding traffic to a particular prefix. For example, if it is required to discard all traffic to prefix 2001:0DB8:42:1/64, the following static route would be defined:


  configure 
   router static
    address-family ipv6 unicast 
    2001:0DB8:42:1::/64 null 0 
    end
  

Associate VRF with a Static Route

This task explains how to associate a VRF with a static route.

SUMMARY STEPS

  1. configure
  2. router static
  3. vrf vrf-name
  4. address-family { ipv4 | ipv6 } { unicast | multicast }
  5. prefix mask [vrf vrf-name ] {next-hop ip-address | interface-name } {path-id } [ distance ] [ description text ] [ tag tag ] [ permanent ]
  6. Use the commit or end command.

DETAILED STEPS


Step 1

configure

Example:


RP/0/RSP0/CPU0:router# configure

Enters global configuration mode.

Step 2

router static

Example:

RP/0/RSP0
/CPU0:router(config)# router static 

Enters static route configuration mode.

Step 3

vrf vrf-name

Example:


RP/0/RSP0/CPU0:router(config-static)# vrf vrf_A

Enters VRF configuration mode.

Step 4

address-family { ipv4 | ipv6 } { unicast | multicast }

Example:


RP/0/RSP0/CPU0:router(config-static-vrf)# address-family ipv6 unicast 

Enters address family mode.

Step 5

prefix mask [vrf vrf-name ] {next-hop ip-address | interface-name } {path-id } [ distance ] [ description text ] [ tag tag ] [ permanent ]

Example:


RP/0/RSP0/CPU0:router(config-static-vrf-afi)# 2001:0DB8::/32 2001:0DB8:3000::1 201

Configures an administrative distance of 201.

Step 6

Use the commit or end command.

commit —Saves the configuration changes and remains within the configuration session.

end —Prompts user to take one of these actions:
  • Yes — Saves configuration changes and exits the configuration session.

  • No —Exits the configuration session without committing the configuration changes.

  • Cancel —Remains in the configuration session, without committing the configuration changes.


Configuration Examples

This section provides the following configuration examples:

Configuring Traffic Discard: Example

Configuring a static route to point at interface null 0 may be used for discarding traffic to a particular prefix. For example, if it is required to discard all traffic to prefix 2001:0DB8:42:1/64, the following static route would be defined:


  configure 
   router static
    address-family ipv6 unicast 
    2001:0DB8:42:1::/64 null 0 
    end
  

Configuring a Fixed Default Route: Example

A default static route is often used in simple router topologies. In the following example, a route is configured with an administrative distance of 110.


  configure
   router static
    address-family ipv4 unicast 
    0.0.0.0/0 2.6.0.1 110
    end

Configuring a Floating Static Route: Example

A floating static route is often used to provide a backup path if connectivity fails. In the following example, a route is configured with an administrative distance of 201.


  configure
   router static
    address-family ipv6 unicast 
    2001:0DB8::/32 2001:0DB8:3000::1 201
    end

Configure Native UCMP for Static Routing

In a network where traffic is load balanced on two or more links, configuring equal metrics on the links would create Equal Cost Multipath (ECMP) next hops. Because the bandwidth of the links is not taken into consideration while load balancing, the higher bandwidth links are underutilized. To avoid this problem, you can configure Unequal Cost Multipath (UCMP), either locally (local UCMP), or natively (native UCMP) so that the higher bandwidth links carry traffic in proportion to the capacity of the links. UCMP supports IPv4 and IPv6 static VRF routes.

Local UCMP: All static routes are configured with the same link metrics. The static IGP calculates the load metric based on the bandwidth of the links and load balances the traffic across the links. However, local UCMP does not consider bandwidth while load balancing across links that are closer to the destination (multiple hops away).

Native UCMP: Static routes over higher bandwidth links are configured with lower link metrics so that they are preferred to routes over lower bandwidth links. The static IGP calculates the load metric based on the bandwidth of the links and determines the percentage of traffic going out of the higher and lower bandwidth links. By matching the configured link metrics with end-to-end available bandwidth, native UCMP is able to effectively load balance traffic across links that are closer to the destination (multiple hops away).

Configuration Example

Consider the topology in the following figure. For load balancing traffic out of Router A1, if local UCMP is used, then both 10G and 100G links will have equal link metrics. The static IGP decides to send more traffic out of the 100G link because of the higher load metric. However, for load balancing traffic out of Router A2, local UCMP works only on links to Routers C1 and C2. For load balancing traffic from Router C1 to Router A1 and Router C2 to Router A1, native UCMP is preferred. As a result, local UCMP is used only on single hop destinations, and native UCMP is used for multi-hop destinations.

Figure 1. Unequal Cost Multipath for Static Routing


To configure UCMP for static routing, use the following steps:

  1. Enter the global configuration mode.

    RP/0/0/CPU0:Router# configure
  2. Enter the static routing mode.

    RP/0/0/CPU0:Router(config)# router static
  3. Configure UCMP with load metric for IPv4 or IPv6 address family.

    RP/0/0/CPU0:Router(config-static)# address-family ipv4 unicast
    RP/0/0/CPU0:Router(config-static-afi)# 10.10.10.1/32 GigabitEthernet 0/0/0/1 metric 10
    

    In this example, we have configured UCMP for IPv4 address family. To configure UCMP for IPv6 address family, use the following sample configuration.

    RP/0/0/CPU0:Router(config-static)# address-family ipv6 unicast 
    RP/0/0/CPU0:Router(config-static-afi)# 10:10::1/64 GigabitEthernet 0/0/0/1 metric 10
  4. Exit the static configuration mode and commit your configuration.

    RP/0/0/CPU0:Router(config-static-afi)# exit
    RP/0/0/CPU0:Router(config-static)# exit
    RP/0/0/CPU0:Router(config)# commit
    Fri Feb 19 06:16:33.164 IST
    RP/0/0/CPU0:Feb 19 06:16:34.273 : ipv4_static[1044]: %ROUTING-IP_STATIC-4-CONFIG_NEXTHOP_ETHER_INTERFACE : 
    Route for 10.10.10.1 is configured via ethernet interface 

    Repeat this procedure on all routers that need to be configured with UCMP.

Configuring a Static Route Between PE-CE Routers: Example

In the following example, a static route between PE and CE routers is configured, and a VRF is associated with the static route:


  configure
   router static
    vrf vrf_A
    address-family ipv4 unicast 
    0.0.0.0/0 2.6.0.2 120
    end

Additional References

The following sections provide references related to implementing Static Routes.

Related Documents

Related Topic

Document Title

Static routes commands: complete command syntax, command modes, command history, defaults, usage guidelines, and examples

Static Routing Commands in Routing Command Reference for Cisco ASR 9000 Series Routers

MPLS Layer 3 VPN configuration: configuration concepts, task, and examples

MPLS Configuration Guide for Cisco ASR 9000 Series Routers

Standards

Standards

Title

No new or modified standards are supported by this feature, and support for existing standards has not been modified by this feature.

NA

MIBs

MIBs

MIBs Link

All

To locate and download MIBs using Cisco IOS XR software, use the Cisco MIB Locator tool found at the following URL and choose a platform under the Cisco Access Products menu.

RFCs

RFCs

Title

No new or modified RFCs are supported by this feature, and support for existing RFCs has not been modified by this feature.

NA

Technical Assistance

Description

Link

The Cisco Technical Support website contains thousands of pages of searchable technical content, including links to products, technologies, solutions, technical tips, and tools. Registered Cisco.com users can log in from this page to access more content.

http://www.cisco.com/techsupport