ip route-static

Function

The ip route-static command configures an IPv4 unicast static route.

The undo ip route-static command deletes an IPv4 unicast static route.

By default, no IPv4 unicast static routes are configured in the system.

Format

ip route-static ip-address { mask | mask-length } nexthop-address [ recursive-lookup host-route ] [ preference preference | tag tag ] * [ bfd enable | track { bfd-session cfg-name | nqa admin-name test-name | efm-state { efm-interface-name | efm-interface-type efm-interface-number } } | permanent ] [ no-advertise | no-install ] [ inter-protocol-ecmp ] [ description text ]

ip route-static ip-address { mask | mask-length } nexthop-address [ recursive-lookup host-route ] [ preference preference | tag tag ] * inherit-cost [ no-advertise | no-install ] [ inter-protocol-ecmp ] [ description text ]

ip route-static ip-address { mask | mask-length } { interface-name | interface-type interface-number } [ nexthop-address | dhcp ] [ preference preference | tag tag ] * [ bfd enable | track { bfd-session cfg-name | nqa admin-name test-name | efm-state { efm-interface-name | efm-interface-type efm-interface-number } } | permanent ] [ no-advertise | no-install ] [ inter-protocol-ecmp ] [ description text ]

undo ip route-static ip-address { mask | mask-length } vpn-instance vpn-instance-name nexthop-address [ inherit-cost ]

undo ip route-static ip-address { mask | mask-length } nexthop-address inherit-cost

undo ip route-static ip-address { mask | mask-length } vpn-instance vpn-instance-name

Parameters

Parameter Description Value
ip-address

Specifies a destination IP address.

The value is in dotted decimal notation.

mask

Specifies a mask for an IP address.

The value is in dotted decimal notation.

mask-length

Specifies the mask length. A 32-bit mask is represented by consecutive 1s, and the mask in dotted decimal notation can be replaced by the mask length.

The value is an integer ranging from 0 to 32.

nexthop-address

Specifies the next hop IP address of a route.

The value is in dotted decimal notation.

recursive-lookup

Recursive route lookup policy.

-

host-route

Recurses the static route to a 32-bit host route.

-

preference preference

Specifies a priority for the static route.

The value is an integer that ranges from 1 to 255. The default value is 60. A smaller value indicates a higher priority.

tag tag

Specifies a tag value for the static route. The tag can be used by a routing policy. For example, the tag can be used during route import.

The value is an integer ranging from 1 to 4294967295. The default value is <b>0</b>.

bfd

Associates a dynamic BFD session with the static route to fast detect faults.

-

enable

Associates a dynamic BFD session with the static route to fast detect faults.

-

track

Specify a track object.

-

bfd-session cfg-name

Associates a static BFD session with the static route to fast detect faults.

The undo ip route-static [ track bfd-session ] all command with track bfd-session cfg-name specified dissociates the static route from the current BFD session only without deleting the static route.

The value is a string of 1 to 64 case-sensitive characters, spaces not supported.

nqa admin-name

Associates a static route with an NQA test instance to fast detect faults. The system determines whether to activate a static route based on the link test result of NQA. This helps control static route advertisement and correctly forward the traffic from the remote end.

Currently, only ICMP and TCP NQA test instances can be bound to static routes to implement fast fault detection.

The value is a string of 1 to 32 case-sensitive characters.

test-name

Associates the static route with an NQA test instance to fast detect faults so that the system determines whether to activate the static route based on the NQA link detection result to control route advertisement and guide remote traffic.

Currently, only ICMP NQA test instances can be bound to static routes to implement fast fault detection.

The value is a string of 1 to 32 case-sensitive characters.

efm-state efm-interface-type

Specifies the interface whose EFM OAM status needs to be detected.

After track efm-state is configured, the system responds to the interface Up/Down event that is triggered by the change of EFM OAM extension status, and determines whether to activate static routes. In this manner, route advertisement can be controlled, and the traffic from the remote end can be correctly forwarded. Currently, this parameter can be used only on IPv4 networks, because IPv6 networks do not provide EFM OAM extension for static routes.

The interfaces to be detected through track efm-state must be Ethernet interfaces or GE interfaces.

-

efm-interface-number

Specifies the interface whose EFM OAM status needs to be detected.

After track efm-state is configured, the system responds to the interface Up/Down event that is triggered by the change of EFM OAM extension status, and determines whether to activate static routes. In this manner, route advertisement can be controlled, and the traffic from the remote end can be correctly forwarded. Currently, this parameter can be used only on IPv4 networks, because IPv6 networks do not provide EFM OAM extension for static routes.

The interfaces to be detected through track efm-state must be Ethernet interfaces or GE interfaces.

-

permanent

Configures permanent advertisement of the static route.

-

no-advertise

Prevents the static route from being advertised.

In network maintenance scenarios, static routes are required to verify services. If you do not want these static routes to be imported by other protocols, specify no-advertise to prevent these static routes from being advertised.

no-advertise takes effect only when it is configured for all the active static routes with the same destination address and mask.

-

no-install

Prevents the static route from being delivered to the FIB. If multiple static routes with the same prefix and mask length are configured using the command repeatedly, all the static routes can be delivered to the FIB as long as no-install is not specified in the command when configuring one of the static routes.

The no-install and no-advertise parameters are mutually exclusive.

-

inter-protocol-ecmp

Enables inter-protocol load balancing among static routes and the routes of dynamic routing protocols.

If a static route is the optimal or suboptimal route and the optimal and suboptimal routes share the same priority, the static route and the routes of dynamic routing protocols can participate in inter-protocol load balancing.

If inter-protocol load balancing among static routes and the routes of dynamic routing protocols is enabled for any static route in the routing table, the other static routes in the routing table that have the same prefix as that of this static route can also participate in inter-protocol load balancing with the routes of dynamic routing protocols.

Intra-protocol and inter-process load balancing and inter-protocol load balancing are mutually exclusive. If you configure them both, the former takes effect.

Inter-protocol load balancing does not take effect in the following cases:

  • Among routes imported using the import-rib command and other routes.
  • Among black-hole routes and non-black-hole routes.
  • Among Vlink routes and non-Vlink routes.

-

description text

Specifies the description of the static route.

To check the configured description, run the display this or display current-configuration command in the system view.

The description parameter cannot be followed by other parameters, such as bfd and preference. Otherwise, the configuration will be used only as the description. For example, if ip route-static 1.1.1.1 255.255.255.255 NULL0 description aa preference 10 is run, aa preference 10 is used as the description.

The value is a string of 1 to 150 characters, spaces supported.

inherit-cost

Enables the static route to inherit the cost of recursive routes.

If you have specified an outbound interface for a static route, you can no longer specify inherit-cost for the static route.

In a scenario in which an L2VPN accesses an L3VPN, the direct-route track pw-state command can be configured to control the cost of a direct route to reduce downstream traffic loss during the traffic switchback after the primary PW recovers.

The CSG is connected to a number of base stations. These base stations usually use logical IP addresses to communicate with AGGs. As a result, packets cannot be forwarded over direct routes between base stations and AGGs. In addition, AGGs do not have routes to the logical IP addresses of stations. In this situation, static routes must be configured on AGGs. As network administrators usually configure consecutive logical IP addresses for base stations based on IP address planning, you need to configure static routes to specific base stations on AGGs. If the static routes are not associated with the PW status, some downstream traffic may be lost during the traffic switchback after the primary PW recovers.

To solve this problem, associate static routes with the PW status. If you do not specify outbound interfaces when configuring static routes, the static routes will recurse to direct routes. In this situation, specify inherit-cost so that the static routes can inherit the costs of recursive routes. Because the costs of direct routes are determined by the PW status, this configuration can associate static routes with the PW status, which reduces traffic loss during the traffic switchback.

interface-type

Specifies the type of the outbound interface of the static route.

-

interface-number

Specifies the number of the outbound interface of the static route.

The value is a string of 1 to 63 case-sensitive characters, spaces not supported.

dhcp

Sets the IP address of a DHCP gateway as the next hop of the static route.

-

vpn-instance vpn-instance-name

Specifies the name of a VPN instance. If the name of a VPN instance is specified, a router searches the routing table of the VPN instance for an outbound interface of the static route based on the next hop IP address specified by the nexthop-address parameter. If the nexthop-address parameter is not configured, that is, the Next-Table function is configured, the router searches the routing table of the VPN instance for a forwarding path if it fails to find one in the public network forwarding table.

The value is a string of 1 to 31 case-sensitive characters, which do not contain spaces. The VPN instance name cannot be _public_. The character string can contain spaces if it is enclosed with double quotation marks (").

Views

System view

Default Level

2: Configuration level

Task Name and Operations

Task Name Operations
route-base write

Usage Guidelines

Usage Scenario

On a simple network, static routes alone can ensure that the network runs properly. If thedevicecannot run dynamic routing protocols to generate routes to the destination, configure static routes on the Router.

Prerequisites

BFD must have been enabled when you bind a static route to a BFD session.

An NQA test instance must have been created when you bind it to a static route.

EFM must have been enabled when you associate EFM OAM with a static route.

The function that allows static routes to recurse to ARP Vlink direct routes must have been enabled globally using the ip route recursive-lookup arp vlink-direct-route protocol static command when you enable a device to recurse a static route only to an ARP Vlink route.

Precautions

When configuring unicast static routes, note the following rules:

  • Only public routes can be used for tunnel recursion.
  • When deleting a route, you can specify preference, tag, or description. The parameters, however, are not displayed in the command line help.
  • When both the destination IP address and the mask are 0.0.0.0, the configured route is a default route. If no matching route is available in the routing table, the default route is used for packet forwarding.
  • Setting different priorities can implement different RM policies. For example, if the same priority is configured for multiple routes to the same destination, load balancing can be implemented. If different priorities are configured for multiple routes to the same destination, route backup can be implemented.
  • An outbound interface, a next hop address, or both of them can be configured for a static route. Actually, each routing entry requires a next hop address. Before sending a packet, a device needs to search its routing table for the route matching the destination address in the packet based on the longest match rule. The device can find the associated link layer address to forward the packet only when the next hop address of the packet is available. When specifying an outbound interface, note the following:
    • For a Point-to-Point (P2P) interface, if the outbound interface is specified, the next hop address is the address of the remote interface connected to the outbound interface.
    • Non-Broadcast Multiple-Access (NBMA) interfaces are applicable to Point-to-Multipoint networks. Therefore, IP routes and the mappings between IP addresses and link layer addresses are required. In this case, you need to configure next hop addresses.
  • The following routes are black-hole routes:
    • Static routes with null0 as the outbound interface
    • Static routes that recurse to black-hole routes
  • If the outbound interface and next-hop IP address configured for a static route do not reside on the same network segment, traffic may fail to be forwarded.
  • If the IP address of the outbound interface configured for a static route is changed and the new IP address resides on a network segment different from that of the static route's next-hop IP address, traffic may fail to be forwarded.
  • If the undo ip route-static all command is run, all static route configurations on the public network are deleted. Therefore, exercise caution when running the command.
  • After the static route configuration is saved and the device is restarted in CFG mode, the configuration sequence in the configuration file may be different from that before the restart.

Example

# Configure an IPv4 static route, set the next hop address to 10.11.0.1, and configure the static route to inherit the cost of recursive routes.
<HUAWEI> system-view
[~HUAWEI] ip route-static 1.1.1.1 32 10.11.0.1 inherit-cost
# Associate the IPv4 static route 1.1.1.1/32 with an NQA test instance.
<HUAWEI> system-view
[~HUAWEI] nqa test-instance admin test
[*HUAWEI-nqa-admin-test] test-type icmp
[*HUAWEI-nqa-admin-test] destination-address ipv4 1.1.1.2
[*HUAWEI-nqa-admin-test] frequency 10
[*HUAWEI-nqa-admin-test] start now
[*HUAWEI-nqa-admin-test] quit
[*HUAWEI] ip route-static 1.1.1.1 32 2.2.2.2 track nqa admin test
# Set the next hop address of the default IPv4 route to 10.2.0.4.
<HUAWEI> system-view
[~HUAWEI] ip route-static 0.0.0.0 0.0.0.0 10.2.0.4
# Configure an IPv4 static route and set the next hop address to 10.11.0.1.
<HUAWEI> system-view
[~HUAWEI] ip route-static 1.1.1.1 32 10.11.0.1
Copyright © Huawei Technologies Co., Ltd.
Copyright © Huawei Technologies Co., Ltd.
< Previous topic Next topic >