Implementing Static Routes
Implementing 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 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.
References for Static Routes, on page 7 provides additional conceptual information on static routes.
This module describes how to implement static routes.
• Restrictions for Implementing Static Routes, on page 1
• Configure Static Route, on page 1
• Floating Static Routes , on page 3
• Change Maximum Number of Allowable Static Routes, on page 5
• Default VRF, on page 6
• References for Static Routes, on page 7
• IPv4 Multicast Static Routes, on page 9
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/RP0/CPU0:router# configure
Enters mode.
Step 5 prefix mask [vrf vrf-name ] { ip-address | interface-type interface-instance } [ distance ] [ description text ] [ tag
tag ] [ permanent ]
Example:
• 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.
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
Note By default, static routes have smaller administrative distances than dynamic routes, so static routes are preferred
to dynamic routes.
SUMMARY STEPS
1. configure
2. router static
3. vrf vrf-name
4. address-family { ipv4 | ipv6 } { unicast | multicast }
DETAILED STEPS
Step 1 configure
Example:
RP/0/RP0/CPU0:router# configure
Enters mode.
Step 5 prefix mask [vrf vrf-name ] { ip-address | interface-type interface-instance } [ distance ] [ description text ] [ tag
tag ] [ permanent ]
Example:
• 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
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/RP0/CPU0:router# configure
Enters mode.
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
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.
Note 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.
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.
Note By default, static routes have smaller administrative distances than dynamic routes, so static routes are preferred
to dynamic routes.
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.
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:
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.
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. This feature enables loadbalancing support in hardware among egress links.
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.
This feature enables loadbalancing support in hardware among egress links.
between them is the solution. In the figure below, each unicast router (UR) supports unicast packets only;
each multicast router (MR) supports multicast packets.
Figure 1: Tunnel for Multicast Packets
In the figure, the source delivers multicast packets to destination by using MR 1 and MR 2. MR 2 accepts the
multicast packet only if it predicts it can reach source over the tunnel. If this situation is true, when the
destination sends unicast packets to the source, MR 2 sends them over the tunnel. The check that MR2 can
reach the source over the tunnel is a Reverse Path Forwarding (RPF) check, and the static mroute allows the
check to be successful when the interface, on which the multicast packet arrives, is not the unicast path back
to the source. Sending the packet over the tunnel could be slower than natively sending it through UR 2, UR
1, and MR 1.
A multicast static route allows you to use the configuration in the above figure by configuring a static multicast
source. The system uses the configuration information instead of the unicast routing table to route the traffic.
Therefore, multicast packets can use the tunnel without having the unicast packets use the tunnel. Static
mroutes are local to the router they are configured on and not advertised or redistributed in any way to any
other router.
/* Configures the IPv4 address-family for the unicast topology with a destination prefix.
*/
Router(config-static)# address-family ipv4 unicast
Router(config-static-afi)# 10.1.1.0/24 198.51.100.1
Router(config-static-afi)# 223.255.254.254/32 203.0.113.1
Router(config-static-afi)# exit
/* Configures the IPv4 address-family for the multicast topology with a destination prefix.
*/
Router(config-static)# address-family ipv4 multicast
Router(config-static-afi)# 198.51.100.20/32 209.165.201.0
Router(config-static-afi)# 192.0.2.10/32 209.165.201.0
Router(config-static-afi)# exit
/* Enable the address family IPv4 and IPv6 multicast on the next hop interface. */
Router(config)# interface TenGigE 0/0/0/12
Router(config-if)# address-family ipv4 multicast
Router(config-if)# address-family ipv6 multicast
Running Configuration
router static
address-family ipv4 unicast
10.1.1.0/24 198.51.100.1
223.255.254.254/32 203.0.113.1
!
address-family ipv4 multicast
198.51.100.20/32 209.165.201.0
192.0.2.10/32 209.165.201.0
!
interface TenGigE 0/0/0/12
address-family ipv4 multicast
address-family ipv6 multicast
Verification
Verify the IPv4 multicast routes.
show route ipv4 multicast