Static Route Configuration Layer 3
Static Route Configuration Layer 3
This chapter provides an overview of the functions, purposes, and use cases of
static routes, and explains how they can be configured.
Definition
A static route is a route that, in most cases, the network administrator manually
configures to allow network traffic to reach a target destination.
Purpose
Static routes are used in different ways on different types of network.
● On simple networks, static routes can be used alone, without the need for
dynamic routes.
● On complex networks, static routes can be used alongside dynamic routes to
improve network performance and ensure bandwidth is available for
important applications.
● Static routes associated with VPN instances are used to manage VPN routes.
2.2 Principles
● If NQA detects a fault in the link, the system sets the static route to inactive.
The route becomes unavailable and is deleted from the IP routing table.
● If NQA finds that the link recovers, the system sets the static route to active.
The route becomes available and is added to the IP routing table.
For details about NQA, see "NQA Configuration - Principles" in the Configuration
Guide - Network Management and Monitoring.
NOTE
When a static route is associated with an NQA test instance, only ICMP test instances are
used to test whether there are reachable routes between the source and destination.
Each static route can be associated with only one NQA test instance.
Applications
On the network shown in Figure 2-1, each access switch provides access services
for 10 users, and a total of 100 users are connected to the network. Because
dynamic routing protocols are unavailable for communication between RouterB
and users, static routes are configured on RouterB. For network stability, RouterC,
functioning as the backup for RouterB, is configured with static routes to the same
destination. RouterA, RouterB, and RouterC run a dynamic routing protocol to
learn routes from each other. RouterB and RouterC import static routes using a
dynamic routing protocol and have different costs for these static routes. After the
configuration is complete, RouterA can use the dynamic routing protocol to learn
routes destined for users from RouterB and RouterC. RouterA uses the link related
to the static route with a lower cost as the active link and the other link as the
standby link.
NQA for static routes is configured on RouterB. NQA tests are performed to check
the active link of RouterB → SwitchA → SwitchC (SwitchD). If the active link fails,
the corresponding static route is deleted from the routing table, and traffic diverts
to the standby link of RouterC → SwitchB → SwitchC (SwitchD). If both links work
properly, traffic travels along the active link.
IP Network
RouterA
RouterB RouterC
SwitchA SwitchB
......
SwitchC SwitchD
...... ......
After permanent advertisement of static routes is configured, the static routes that
cannot be advertised are still preferred and are added to the routing table in the
following cases:
NOTICE
A device enabled with this feature always stores static routes in its IP routing
table, regardless of whether the static routes are reachable. If a path is
unreachable, the corresponding static route may become a blackhole route.
Applications
In Figure 2-2, BR1, BR2, and BR3 belong to ISP1, ISP2, and ISP3 respectively.
Between BR1 and BR2 are two links, Link A and Link B. ISP1, however, requires
that service traffic be forwarded to ISP2 over Link A without traveling through
ISP3.
ISP2
BR2
10.1.1.2/24
LinkA
BR1
ISP1
LinkB BR3
ISP3
2.3 Applications
Preference=60
Preference=60
RouteA RouteC
RouteD
As shown in Figure 2-3, there are two static routes with the same preference from
RouterA to RouterC. The two routes are stored in the routing table and used to
forward data.
Route Backup
To implement route backup, specify different preferences for multiple routes to the
same destination.
Preference=60
Preference=100
RouteA RouteC
RouteD
As shown in Figure 2-4, there are two static routes with different preferences from
RouterA to RouterC. Static route B with next hop RouterB has a higher preference.
The link that static route B belongs to functions as the active link. Static route D
with next hop RouterD has a lower preference. The link that static route D belongs
to functions as the standby link.
● In normal situations, static route B is activated, and the active link forwards
data. Static route D is not shown in the routing table.
● If a fault occurs on the active link, static route B is deleted from the routing
table. Static route D is activated, and the standby link forwards data.
● When the active link restores, static route B is activated again, and the active
link forwards data. Static route D is deleted from the routing table and
functions as the backup route. Static route D is also called a floating static
route.
2 4
RouteB
1 5
RouteA RouteC
– If any device on
the network does
not support BFD,
BFD detection
cannot be
implemented.
– If either end of the
link is a Layer 2
device, dynamic
routing protocols
cannot be
configured and
therefore IGP
convergence
cannot be
implemented.
NQA for static routes
only requires one end
of the interconnected
devices to support
NQA and can be used
even if there are
Layer 2 devices. The
preceding problems
are solved. When a
link is faulty, an NQA
test instance can
immediately detect
the link change and
delete the static route
associated with the
NQA test instance
from the IP routing
table, affecting traffic
forwarding.
License Support
Static Route is a basic feature of a router and is not under license control.
Pre-configuration Tasks
Before configuring IPv4 static routes, complete the following task:
Configuration Procedures
You can perform the following configuration tasks (excluding the task of Checking
the Configuration) in any sequence as required.
Context
When creating static routes, you can specify both the outbound interface and next
hop. Alternatively, you can specify only the outbound interface or next hop based
on the outbound interface type.
● Specify the outbound interface for P2P interfaces.
● Specify the next hop for non broadcast multiple access (NBMA) interfaces.
● Specify the next hop for broadcast interfaces (for example, Ethernet
interfaces) and virtual template interfaces.
If you specify the same preference for static routes to the same destination, you
can implement load balancing among these routes. If you specify different
preferences for static routes, you can implement route backup among the routes.
If the destination IP address and mask are set to all 0s, an IPv4 static default route
is configured. By default, no IPv4 static default route is configured.
Procedure
Step 1 Run:
system-view
Or:
ip route-static ip-address { mask | mask-length } interface-type interface-number [ nexthop-address ]
[ preference preference | tag tag ] * ldp-sync [ description text ]
Or:
ip route-static destination-address { mask | mask-length } interface-type interface-number dhcp
[ preference preference | tag tag ] * [ track nqa admin-name test-name ] [ description text ]
Or:
ip route-static vpn-instance vpn-source-name destination-address { mask | mask-length } interface-
type interface-number dhcp [ preference preference | tag tag ] * [ track nqa admin-name test-
name ] [ description text ]
An IPv4 static route is configured in a VPN instance.
● Run any of the following commands:
– ip route-static vpn-instance vpn-source-name destination-address
{ mask | mask-length } { nexthop-address [ public ] | interface-type
interface-number [ nexthop-address ] | vpn-instance vpn-destination-
name nexthop-address } [ preference preference | tag tag ] *
[ description text ]
– ip route-static vpn-instance vpn-source-name destination-address { mask | mask-length }
interface-type interface-number [ nexthop-address ] [ preference preference | tag tag ] * ldp-
sync [ description text ]
----End
Procedure
Step 1 Run:
system-view
NOTE
After the default preference is reconfigured, the new default preference is valid only for
new IPv4 static routes.
----End
Procedure
Step 1 Run:
system-view
----End
Procedure
Step 1 Run:
system-view
----End
Context
By default, a static route can still be selected by the router even though the BFD
session associated with it is in the AdminDown state, but not by non-Huawei
devices. As a result, the router cannot interwork with non-Huawei devices.
To address this problem, run the ip route-static track bfd-session admindown
invalid command to configure the router not to select the static route if the BFD
session associated with it is in the AdminDown state.
Procedure
Step 1 Run:
system-view
The router has been configured not to select the static route if the BFD session
associated with it is in the AdminDown state.
By default, a static route can still be selected by the router even though the BFD
session associated with it is in the AdminDown state.
----End
Procedure
Step 1 Run:
system-view
Static routes have been prevented from being iterated to the black-hole route.
By default, static routes can be iterated to a black-hole route.
----End
Background
NOTE
Procedure
Step 1 Run:
system-view
The advanced ACL creates an advanced ACL and enters the ACL view.
Step 3 Run:
rule
ip route-static
----End
Pre-configuration Tasks
Before configuring static BFD for IPv4 static routes, complete the following tasks:
● Configuring link layer parameters and IP addresses for interfaces to ensure
network-layer communication between neighbor nodes
● Configuring BFD sessions
For details, see "BFD Configuration" in the Huawei AR Series Access Routers -
Configuration Guide - Reliability.
Procedure
Step 1 Run:
system-view
NOTE
Before binding a static route to a BFD session, ensure that the BFD session and the static
route reside on the same link.
Step 3 Run:
bfd
Step 4 Run:
bfd session nonexistent-config-check enable
To check whether an associated BFD session is deleted, run the bfd session
nonexistent-config-check enable command. After a static route is associated
with a static BFD session, deleting the static BFD session causes the association to
become invalid. After a device is enabled to check whether an associated BFD
session is deleted, the device checks whether the BFD session is associated when
deleting a BFD session.
----End
Pre-configuration Tasks
Before associating IPv4 static routes with NQA, complete the following task:
● Configuring link layer parameters for interfaces to ensure that the link layer
protocol on the interfaces is Up
Procedure
Step 1 Configure an NQA ICMP test instance.
1. Run:
system-view
An NQA test instance is created, and the view of the test instance is displayed.
3. Run:
test-type icmp
NOTE
When a static route is associated with an NQA test instance, only ICMP test instances
are used to test whether there are reachable routes between the source and
destination.
4. Run:
destination-address ipv4 ip-address
In an NQA test instance, you can specify an NQA server by running the
destination-address command to configure a destination address for the
NQA test instance.
5. (Optional) Run:
frequency interval
The number of probes to be sent each time is set for the NQA test instance.
By sending probes multiple times in an NQA test instance, you can accurately
estimate network quality based on the collected statistics.
7. Run:
start
1. Run:
ip route-static ip-address { mask | mask-length } { nexthop-address | interface-type interface-number
[ nexthop-address ] } [ preference preference | tag tag ] * track nqa admin-name test-name
[ description text ]
NOTE
The destination address of an NQA test instance cannot be the destination address of
an associated static route.
If the static route associated with an NQA test instance is associated with another
NQA test instance, the static route is disassociated from the first NQA test instance.
----End
Pre-configuration Tasks
Before configuring IPv6 static routes, complete the following task:
● Configuring link layer parameters and IPv6 addresses for interfaces to ensure
network-layer communication between neighbor nodes
Configuration Procedures
You can perform the following configuration tasks (excluding the task of Checking
the Configuration) in any sequence as required.
Context
When creating IPv6 static routes, you can specify both the outbound interface and
next hop. Alternatively, you can specify only the outbound interface or next hop
based on the outbound interface type.
● Specify the outbound interface for P2P interfaces.
Procedure
Step 1 Run:
system-view
----End
Procedure
Step 1 Run:
system-view
After the default preference is reconfigured, the new default preference is valid
only for new IPv6 static routes.
----End
Procedure
● Run the display ipv6 routing-table command to check brief information
about the IPv6 routing table.
● Run the display ipv6 routing-table verbose command to check detailed
information about the IPv6 routing table.
----End
Networking Requirements
Hosts on different network segments are connected using several Routers. Each
two hosts on different network segments can communicate with each other
without using dynamic routing protocols.
PC2
192.168.2.2/24
GE3/0/0
192.168.2.1/24
GE1/0/0 GE2/0/0
192.168.4.2/30 192.168.4.5/30
RouterB
RouterA RouterC
GE1/0/0 GE1/0/0
192.168.4.1/30 192.168.4.6/30
GE2/0/0 GE2/0/0
192.168.1.1/24 192.168.3.1/24
PC1 PC3
192.168.1.2/24 192.168.3.2/24
Configuration Roadmap
The configuration roadmap is as follows:
1. Configure IPv4 addresses for interfaces so that directly-connected interfaces
can communicate with each other.
2. Configure the default IPv4 gateway on each host, and configure IPv4 static
routes and default routes on each Router so that hosts on different network
segments can communicate with each other.
Procedure
Step 1 Configure IP addresses for interfaces on each Router.
# Configure an IP address for each interface on RouterA. The configurations of
RouterB and RouterC are similar to the configuration of RouterA, and are not
mentioned here.
<Huawei> system-view
[Huawei] sysname RouterA
[RouterA] interface gigabitethernet 1/0/0
[RouterA-GigabitEthernet1/0/0] ip address 192.168.4.1 30
[RouterA-GigabitEthernet1/0/0] quit
[RouterA] interface gigabitethernet 2/0/0
[RouterA-GigabitEthernet2/0/0] ip address 192.168.1.1 24
----End
Configuration Files
● Configuration file of RouterA
#
sysname RouterA
#
interface GigabitEthernet2/0/0
ip address 192.168.1.1 255.255.255.0
#
interface GigabitEthernet1/0/0
ip address 192.168.4.1 255.255.255.252
#
ip route-static 0.0.0.0 0.0.0.0 192.168.4.2
#
return
interface GigabitEthernet1/0/0
ip address 192.168.4.6 255.255.255.252
#
ip route-static 0.0.0.0 0.0.0.0 192.168.4.5
#
return
GE0/0/0
2::1/64
GE1/0/0 GE2/0/0
10::2/64 20::1/64
RouterB
GE1/0/0 GE1/0/0
10::1/64 20::2/64
RouterA RouterC
GE2/0/0 GE2/0/0
1::1/64 3::1/64
PC1 PC3
1::2/64 3::2/64
Configuration Roadmap
The configuration roadmap is as follows:
1. Configure IPv6 addresses for interfaces so that devices can communicate with
each other.
2. Configure the IPv6 default gateway on each host, and configure IPv6 static
routes and default routes on each Router so that hosts on different network
segments can communicate with each other.
Procedure
Step 1 Configure IPv6 addresses for interfaces on each Router.
<Huawei> system-view
[Huawei] sysname RouterA
[RouterA] ipv6
[RouterA] interface gigabitethernet 1/0/0
[RouterA-GigabitEthernet1/0/0] ipv6 enable
[RouterA-GigabitEthernet1/0/0] ipv6 address 10::1/64
[RouterA-GigabitEthernet1/0/0] quit
[RouterA] interface gigabitethernet 2/0/0
[RouterA-GigabitEthernet2/0/0] ipv6 enable
[RouterA-GigabitEthernet2/0/0] ipv6 address 1::1/64
Destination : :: PrefixLength : 0
NextHop : 10::2 Preference : 60
Cost :0 Protocol : Static
RelayNextHop : :: TunnelID : 0x0
Interface : GigabitEthernet1/0/0 Flags :D
----End
Configuration Files
● Configuration file of RouterA
#
sysname RouterA
#
ipv6
#
interface GigabitEthernet1/0/0
ipv6 enable
ipv6 address 10::1/64
#
interface GigabitEthernet2/0/0
ipv6 enable
ipv6 address 1::1/64
#
ipv6 route-static :: 0 GigabitEthernet1/0/0 10::2
#
return
Figure 2-9 Networking diagram of configuring static BFD for IPv4 static routes
GE1/0/0 GE1/0/0 GE2/0/0
1.1.1.1/24 1.1.1.2/24 2.2.2.2/24
Internet
Configuration Roadmap
The configuration roadmap is as follows:
Procedure
Step 1 Configure IP addresses for interfaces on each Router.
<Huawei> system-view
[Huawei] sysname RouterA
[RouterA] interface gigabitethernet 1/0/0
[RouterA-GigabitEthernet1/0/0] ip address 1.1.1.1 24
[RouterA-GigabitEthernet1/0/0] quit
# Check the IP routing table of RouterA. The command output shows that the
static route exists in the routing table.
[RouterA] display ip routing-table
Route Flags: R - relay, D - download to fib
------------------------------------------------------------------------------
Routing Tables: Public
Destinations : 3 Routes : 3
Destination/Mask Proto Pre Cost Flags NextHop Interface
0.0.0.0/0 Static 60 0 RD 1.1.1.2 GigabitEthernet1/0/0
1.1.1.0/24 Direct 0 0 D 1.1.1.1 GigabitEthernet1/0/0
1.1.1.1/32 Direct 0 0 D 127.0.0.1 GigabitEthernet1/0/0
1.1.1.255/32 Direct 0 0 D 127.0.0.1 GigabitEthernet1/0/0
127.0.0.0/8 Direct 0 0 D 127.0.0.1 InLoopBack0
127.0.0.1/32 Direct 0 0 D 127.0.0.1 InLoopBack0
127.255.255.255/32 Direct 0 0 D 127.0.0.1 InLoopBack0
255.255.255.255/32 Direct 0 0 D 127.0.0.1 InLoopBack0
# Check the IP routing table of RouterA. The command output shows that default
route 0.0.0.0/0 does not exist. This is because the default static route is bound to a
BFD session. When BFD detects a link fault, BFD rapidly notifies that the bound
static route becomes unavailable. If the static route is not bound to a BFD session,
the default route 0.0.0.0/0 will always exist in IP routing table; however, this may
cause traffic loss.
[RouterA] display ip routing-table
Route Flags: R - relay, D - download to fib
------------------------------------------------------------------------------
Routing Tables: Public
Destinations : 2 Routes : 2
Destination/Mask Proto Pre Cost Flags NextHop Interface
1.1.1.0/24 Direct 0 0 D 1.1.1.1 GigabitEthernet1/0/0
1.1.1.1/32 Direct 0 0 D 127.0.0.1 GigabitEthernet1/0/0
1.1.1.255/32 Direct 0 0 D 127.0.0.1 GigabitEthernet1/0/0
127.0.0.0/8 Direct 0 0 D 127.0.0.1 InLoopBack0
127.0.0.1/32 Direct 0 0 D 127.0.0.1 InLoopBack0
127.255.255.255/32 Direct 0 0 D 127.0.0.1 InLoopBack0
255.255.255.255/32 Direct 0 0 D 127.0.0.1 InLoopBack0
----End
Configuration Files
● Configuration file of RouterA
#
sysname RouterA
#
bfd
#
interface GigabitEthernet1/0/0
ip address 1.1.1.1 255.255.255.0
#
bfd aa bind peer-ip 1.1.1.2
discriminator local 10
discriminator remote 20
commit
#
ip route-static 0.0.0.0 0.0.0.0 1.1.1.2 track bfd-session aa
#
return
● Configuration file of RouterB
sysname RouterB
#
bfd
#
interface GigabitEthernet1/0/0
ip address 1.1.1.2 255.255.255.0
#
interface GigabitEthernet2/0/0
ip address 2.2.2.2 255.255.255.0
#
bfd bb bind peer-ip 1.1.1.1
discriminator local 20
discriminator remote 10
commit
#
return
Figure 2-10 Networking diagram of configuring NQA for IPv4 static routes
RouterA
GE1/0/0 GE2/0/0
172.16.3.1/24 172.16.4.1/24
GE2/0/0 GE2/0/0
172.16.3.2/24 172.16.4.2/24
RouterB RouterC
/0 /0
GE1/0/0 GE 3 4 GE1/0/0
1 3/0 GE .1/2
172.16.1.1/24 72 / 0 . 6 172.16.2.1/24
.16 .16
.5. 1 72 V
1/2 17 L
4 2.1 ANI
6.5 F20
VLANIF10 .2/
0 24 VLANIF10
172.16.1.2/24 IF2 2/24 172.16.2.2/24
L AN 6.6.
V 2.1 ......
VALNIF30 17 VLANIF30
172.16.7.1/24 SwitchA SwitchB 172.16.8.1/24
...... ......
Primary link
Backup link
Configuration Roadmap
To improve link reliability, a link detection mechanism needs to be deployed on
the device to detect the link status in real time and then the detected link status is
associated with the route status. Access switches do not support BFD. You can
associate IPv4 static routes with NQA to meet this link reliability requirement. The
configuration roadmap is as follows:
1. On RouterA, RouterB, and RouterC, configure IP addresses for interfaces and
configure static routes to Client1 (Client1 is used to represent users). Two
static routes must be configured on RouterA, and the static route with next
hop RouterB must have a higher priority than the static route with next hop
RouterC so that packets sent from RouterA to Client1 can be transmitted
according to the two primary and backup static routes.
2. Configure an ICMP NQA test instance on the primary link from RouterA to
SwitchA and associate the static route of which the next hop is RouterB with
the ICMP NQA test instance to fast detect link faults for service switching.
NOTE
When a static route is associated with an NQA test instance, only ICMP test instances are
used to test whether there are reachable routes between the source and destination.
Procedure
Step 1 Configure IP addresses on Routers.
# Configure IP addresses for interfaces on RouterA.
<Huawei> system-view
[Huawei] sysname RouterA
[RouterA] interface gigabitEthernet 1/0/0
[RouterA-GigabitEthernet1/0/0] ip address 172.16.3.1 24
[RouterA-GigabitEthernet1/0/0] quit
[RouterA] interface gigabitEthernet 2/0/0
[RouterA-GigabitEthernet2/0/0] ip address 172.16.4.1 24
[RouterA-GigabitEthernet2/0/0] quit
Step 3 Configure an NQA test instance on RouterA to test the link between RouterA and
SwitchA.
[RouterA] nqa test-instance aa bb
[RouterA-nqa-aa-bb] test-type icmp
NOTE
If a link becomes faulty, the NQA test instance detects this fault and then the static routes
associated with the NQA test instance become Down. After the link recovers, the NQA test
instance attempts to send ICMP test packets over the static routes. Because these static
routes are still Down, the NQA test instance still fails to detect link connectivity. Traffic fails
to be forwarded. The nexthop ipv4 ip-address command configures a next hop address for
the NQA test packets, which ensures that the packets are forwarded when the link recovers
from the fault, and the static routes associated with the NQA test instance are Up.
Step 4 On RouterA, associate the static route of which the next hop is RouterB with the
NQA test instance.
[RouterA] ip route-static 172.16.7.0 255.255.255.0 172.16.3.2 track nqa aa bb
# Run the display nqa results command on RouterA to check the NQA test
results. In this example, information "Lost packet ratio: 0 %" is displayed,
indicating that the link works properly.
[RouterA] display nqa results test-instance aa bb
# Check the routing table on RouterA. The routing table contains a static route
with the next hop 172.16.3.2.
[RouterA] display ip routing-table
Route Flags: R - relay, D - download to fib
------------------------------------------------------------------------------
Routing Tables: Public
Destinations : 11 Routes : 11
The routing table contains a route destined for 172.16.7.0/24 with next hop
172.16.3.2. Therefore, traffic travels along the primary link.
# Shut down GE1/0/0 on RouterB to simulate a link fault.
[RouterB] interface GigabitEthernet 1/0/0
[RouterB-GigabitEthernet1/0/0] shutdown
[RouterB-GigabitEthernet1/0/0] quit
# Check the NQA test results. Information "Lost packet ratio: 100 %" is displayed,
indicating that the link fails.
[RouterA] display nqa results test-instance aa bb
The command output shows that the next hop of the route to destination network
segment 172.16.7.0/24 is 172.16.4.2. After NQA detects that primary link fails,
NQA notifies RouterA that the static route to 172.16.7.0/24 becomes unavailable.
Packets are then switched to the backup link for forwarding.
----End
Configuration Files
● Configuration file of RouterA
#
sysname RouterA
#
interface GigabitEthernet1/0/0
ip address 172.16.3.1 255.255.255.0
#
interface GigabitEthernet2/0/0
ip address 172.16.4.1 255.255.255.0
#
ip route-static 172.16.7.0 255.255.255.0 172.16.3.2 track nqa aa bb
ip route-static 172.16.7.0 255.255.255.0 172.16.4.2 preference 100
#
nqa test-instance aa bb
test-type icmp
destination-address ipv4 172.16.1.2
frequency 5
probe-count 1
start now
#
return
2.12 FAQ
This section provides the questions you may encounter during configuration and
their answers.
2.12.1 Is the Static Route Affected If the BFD for the Static
Route is in AdminDown State?
The static route is not affected. The static route is invalid only when the BFD
detects a link fault.