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.
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
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:
|
- |
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 ("). |
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:
<HUAWEI> system-view [~HUAWEI] ip route-static 1.1.1.1 32 10.11.0.1 inherit-cost
<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
<HUAWEI> system-view [~HUAWEI] ip route-static 0.0.0.0 0.0.0.0 10.2.0.4
<HUAWEI> system-view [~HUAWEI] ip route-static 1.1.1.1 32 10.11.0.1