Configuring basic IP routing
IP routing directs IP packet forwarding on routers based on a routing table.
Routing table
A RIB contains the global routing information and related information, including route recursion, route redistribution, and route extension information. The router selects optimal routes from the routing table and puts them into the FIB table, and it uses the FIB table to forward packets. For more information about the FIB table, see Layer 3—IP Services Configuration Guide.
Table 1
categorizes routes by different criteria.
Table 1 Route categories
Criterion Categories
Destination
•
Network route—The destination is a network. The subnet mask is less than 32 bits.
•
Host route—The destination is a host. The subnet mask is 32 bits.
Whether the destination is directly connected
•
•
Direct route—The destination is directly connected.
Indirect route—The destination is indirectly connected.
Origin
•
Direct route—A direct route is discovered by the data link protocol on an interface, and is also called an "interface route."
•
Static route—A static route is manually configured by an administrator.
•
Dynamic route—A dynamic route is dynamically discovered by a routing protocol.
To view brief information about a routing table, use the display ip routing-table command:
<Sysname> display ip routing-table
Destinations : 19 Routes : 19
Destination/Mask Proto Pre Cost NextHop Interface
0.0.0.0/32 Direct 0 0 127.0.0.1 InLoop0
1.1.1.0/24 Direct 0 0 1.1.1.1 Vlan1
1.1.1.0/32 Direct 0 0 1.1.1.1 Vlan1
1.1.1.1/32 Direct 0 0 127.0.0.1 InLoop0
1.1.1.255/32 Direct 0 0 1.1.1.1 Vlan1
2.2.2.0/24 Static 60 0 12.2.2.2 Vlan2
80.1.1.0/24 OSPF 10 2 80.1.1.1 Vlan3
...
A route entry includes the following key items:
•
Destination—IP address of the destination host or network.
• Mask—Mask length of the IP address.
• Pre—Preference of the route. Among routes to the same destination, the route with the highest preference is optimal.
1
• Cost—If multiple routes to a destination have the same preference, the one with the smallest cost is the optimal route.
•
NextHop—Next hop.
• Interface—Output interface.
Dynamic routing protocols
Static routes work well in small, stable networks. They are easy to configure and require fewer system resources. However, in networks where topology changes occur frequently, a typical practice is to configure a dynamic routing protocol. Compared with static routing, a dynamic routing protocol is complicated to configure, requires more router resources, and consumes more network resources.
Dynamic routing protocols dynamically collect and report reachability information to adapt to topology changes. They are suitable for large networks.
Route preference
Routing protocols, including static and direct routing, each by default have a preference. If they find multiple routes to the same destination, the router selects the route with the highest preference as the optimal route.
The preference of a direct route is always 0 and cannot be changed. You can configure a preference for each static route and each dynamic routing protocol. The following table lists the route types and default preferences. The smaller the value, the higher the preference.
Table 2 Route types and default route preferences
Route type
Direct route
Preference
0
Multicast static route 1
OSPF 10
Unicast static route
OSPF ASE
OSPF NSSA
60
150
150
IBGP 255
EBGP 255
Unknown (route from an untrusted source) 256
Load sharing
A routing protocol might find multiple optimal equal-cost routes to the same destination. You can use these routes to implement equal-cost multi-path (ECMP) load sharing.
Static routing, IPv6 static routing, OSPF, OSPFv3, BGP, and IPv6 BGP support ECMP load sharing.
2
Route backup
Route backup can improve network availability. Among multiple routes to the same destination, the route with the highest priority is the primary route and others are secondary routes.
The router forwards matching packets through the primary route. When the primary route fails, the route with the highest preference among the secondary routes is selected to forward packets. When the primary route recovers, the router uses it to forward packets.
Route recursion
To use a route that has an indirectly connected next hop, a router must perform route recursion to find the output interface to reach the next hop.
The RIB records and saves route recursion information, including brief information about related routes, recursive paths, and recursion depth.
Route redistribution
Route redistribution enables routing protocols to learn routing information from each other. A dynamic routing protocol can redistribute routes from other routing protocols, including direct and static routing.
For more information, see the respective chapters on those routing protocols in this configuration guide.
The RIB records redistribution relationships of routing protocols.
Extension attribute redistribution
Extension attribute redistribution enables routing protocols to learn route extension attributes from each other, including BGP extended community attributes, OSPF area IDs, route types, and router IDs.
The RIB records extended attributes of each routing protocol and redistribution relationships of different routing protocol extended attributes.
Configuring the maximum lifetime for routes and labels in the RIB
Perform this task to prevent routes of a certain protocol from being aged out due to slow protocol convergence resulting from a large number of route entries or long GR period.
The configuration takes effect at the next protocol or RIB process switchover.
To configure the maximum lifetime for routes and labels in the RIB (IPv4):
Step Command
1. Enter system view. system-view
2. Enter RIB view.
3. Create a RIB IPv4 address family and enter RIB IPv4 address family view. rib address-family ipv4
Remarks
N/A
N/A
By default, no RIB IPv4 address family is created.
3
Step Command
4. Configure the maximum lifetime for IPv4 routes and labels in the RIB. protocol protocol lifetime seconds
Remarks
By default, the maximum lifetime for routes and labels in the RIB is 480 seconds.
To configure the maximum route lifetime for routes and labels in the RIB (IPv6):
Step Command
5. Enter system view. system-view
6. Enter RIB view.
7. Create a RIB IPv6 address family and enter RIB IPv6 address family view.
8. Configure the maximum lifetime for IPv6 routes and labels in the RIB. rib address-family ipv6 protocol protocol lifetime seconds
Remarks
N/A
N/A
By default, no RIB IPv6 address family is created.
By default, the maximum lifetime for routes and labels in the RIB is 480 seconds.
Configuring the maximum lifetime for routes in the
FIB
When GR is disabled, FIB entries must be retained for some time after a protocol process switchover or
RIB process switchover. When GR is enabled, FIB entries must be removed immediately after a protocol or RIB process switchover to avoid routing issues. Perform this task to meet such requirements.
To configure the maximum lifetime for routes in the FIB (IPv4):
Step Command
1. Enter system view. system-view
2. Enter RIB view. rib
3. Create a RIB IPv4 address family and enter its view. address-family ipv4
4. Configure the maximum lifetime for IPv4 routes in the
FIB. fib lifetime seconds
To configure the maximum lifetime for routes in the FIB (IPv6):
Step Command
1. Enter system view. system-view
2. Enter RIB view. rib
3. Create a RIB IPv6 address family and enter its view. address-family ipv6
4. Configure the maximum lifetime for IPv6 routes in the
FIB. fib lifetime seconds
Remarks
N/A
N/A
By default, no RIB IPv4 address family is created.
By default, the maximum lifetime for routes in the FIB is
600 seconds.
Remarks
N/A
N/A
By default, no RIB IPv6 address family is created.
By default, the maximum lifetime for routes in the FIB is
600 seconds.
4
Configuring the maximum number of ECMP routes
This configuration takes effect at next reboot. Make sure the reboot does not impact your network.
To configure the maximum number of ECMP routes:
Step Command
1. Enter system view. system-view
2. Configure the maximum number of ECMP routes. max-ecmp-num number
Remarks
N/A
By default, the maximum number of ECMP routes is 8.
Enabling the enhanced ECMP mode
In the default ECMP mode, when one or multiple ECMP routes fail, the device reallocates all traffic to the remaining routes.
The enhanced ECMP mode enables the device to reallocate only the traffic of the failed routes to the remaining routes, ensuring forwarding continuity.
This configuration takes effect at next reboot. Make sure the reboot does not impact your network.
To enable the enhanced ECMP mode:
Step Command
1. Enter system view. system-view
2. Enable the enhanced ECMP mode. ecmp mode enhanced
Remarks
N/A
By default, the enhanced
ECMP mode is disabled.
Enabling support for IPv6 routes with prefixes longer than 64 bits
Do not configure the switch-routing-mode ipv6-128 command and the switch-mode 4 command at the same time.
This configuration takes effect at next reboot. Make sure the reboot does not impact your network.
To enable support for IPv6 routes with prefixes longer than 64 bits:
Step Command
3. Enter system view. system-view
4. Enable support for IPv6 routes with prefixes longer than 64 bits. switch-routing-mode ipv6-128
Remarks
N/A
By default, the device does not support IPv6 routes with prefixes longer than 64 bits.
This command is available only in Release 2407P01 and later.
5
Displaying and maintaining a routing table
Execute display commands in any view and reset commands in user view.
Task Command
Display the ECMP mode.
Display routing table information.
Display information about routes permitted by an IPv4 basic ACL .
Display information about routes to a specific destination address.
Display information about routes to a range of destination addresses.
Display information about routes permitted by an IP prefix list.
Display information about routes installed by a protocol.
Display IPv4 route statistics.
Display the maximum number of ECMP routes.
Display route attribute information in the RIB.
Display RIB GR state information. display ecmp mode display ip routing-table [ vpn-instance vpn-instance-name ]
[ verbose ] display ip routing-table [ vpn-instance vpn-instance-name ] acl
acl-number [ verbose ] display ip routing-table [ vpn-instance vpn-instance-name ]
ip-address [ mask | mask-length ] [ longer-match ] [ verbose ] display ip routing-table [ vpn-instance vpn-instance-name ]
ip-address1 to ip-address2 [ verbose ] display ip routing-table [ vpn-instance vpn-instance-name ] prefix-list
prefix-list-name [ verbose ] display ip routing-table [ vpn-instance vpn-instance-name ] protocol
protocol [ inactive | verbose ] display ip routing-table [ vpn-instance vpn-instance-name ] statistics display max-ecmp-num display rib attribute [ attribute-id ]
Display next hop information in the
RIB. display rib graceful-restart display rib nib [ self-originated ] [ nib-id ] [ verbose ] display rib nib protocol protocol-name [ verbose ]
Display next hop information for direct routes. display route-direct nib [ nib-id ] [ verbose ]
Clear IPv4 route statistics.
Display IPv6 routing table information.
Display information about routes to an
IPv6 destination address.
Display information about routes permitted by an IPv6 basic ACL.
Display information about routes to a range of IPv6 destination addresses.
Display information about routes permitted by an IPv6 prefix list.
Display information about routes installed by an IPv6 protocol. reset ip routing-table statistics protocol [ vpn-instance
vpn-instance-name ] { protocol | all } display ipv6 routing-table [ vpn-instance vpn-instance-name ]
[ verbose ] display ipv6 routing-table [ vpn-instance vpn-instance-name ]
ipv6-address [ prefix-length ] [ longer-match ] [ verbose ] display ipv6 routing-table [ vpn-instance vpn-instance-name ] acl
acl6-number [ verbose ] display ipv6 routing-table [ vpn-instance vpn-instance-name ]
ipv6-address1 to ipv6-address2 [ verbose ] display ipv6 routing-table [ vpn-instance vpn-instance-name ] prefix-list prefix-list-name [ verbose ] display ipv6 routing-table [ vpn-instance vpn-instance-name ] protocol protocol [ inactive | verbose ]
6
Task Command
Display IPv6 route statistics. display ipv6 routing-table [ vpn-instance vpn-instance-name ] statistics
Display route attribute information in the IPv6 RIB. display ipv6 rib attribute [ attribute-id ]
Display IPv6 RIB GR state information. display ipv6 rib graceful-restart
Display next hop information in the
IPv6 RIB. display ipv6 rib nib [ self-originated ] [ nib-id ] [ verbose ] display ipv6 rib nib protocol protocol-name [ verbose ]
Display next hop information for IPv6 direct routes. display ipv6 route-direct nib [ nib-id ] [ verbose ]
Clear IPv6 route statistics. reset ipv6 routing-table statistics protocol [ vpn-instance
vpn-instance-name ] { protocol | all }
7