< Home

Configuring an IPv4 Static Route

You can configure a static outbound interface or next-hop address and priority for the IPv4 packet to the destination address to accurately control the IPv4 route selection.

Context

When configuring an IPv4 static route, you need to learn the following information:

  • Destination address and mask

    In the ip route-static command, the IPv4 destination address is in dotted decimal notation. The mask can be in dotted decimal notation or can be represented by the mask length, namely, the number of consecutive "1"s in the mask.

  • Outbound interface and next hop address

    When configuring a static route, you can specify either interface-type interface-number or nexthop-address. Whether to specify the outbound interface or the next hop address depends on the actual situation.

    Actually, all routing entries must specify the next hop addresses. When sending a packet, the router first searches the matched route in the routing table according to the destination address. The link layer can find the corresponding link layer address and forward the packet only when the next hop address is specified.

    When specifying the outbound interface, note the following:

    • For Point-to-Point (P2P) interfaces, if the outbound interface is specified, it indicates that the next hop address is specified. The address of the peer interface connected to this interface is the next hop address.
    • NBMA interface supports Point-to-Multipoint (P2MP) networks. In this case, you need to configure IP routes and set up the reroute table on the link layer, namely, the mapping between IP addresses and link layer addresses. In this case, the next hop IP address needs to be configured.
    • When configuring static routes, you are recommended not to specify the Ethernet interface as the outbound interface. The Ethernet interface is a broadcast interface. In this case, multiple next hops occur and a unique next hop cannot be determined. To specify a broadcast interface such as an Ethernet interface or an NBMA interface as the outbound interface, you need to specify the next hop address of this interface.
  • Other attributes

    You can set different preferences for the static routes. This enables you to apply the RM policy flexibly. For example, when configuring multiple routes to the same destination address, you can set the same preference for these routes to implement load balancing. You can also set different preferences to implement routing redundancy.

    While configuring a static route by using the ip route-static command, if you set the destination address and the mask to all "0"s (0.0.0.0 0.0.0.0), it indicates that a default route is configured.

Procedure

  1. In the user view, run:

    system-view

    The system view is displayed.

  2. Run:
    • ip route-static ip-address { mask | mask-length } { nexthop-address | interface-type interface-number [ nexthop-address ] } [ preference preference | tag tag ] * [ track { bfd-session bfd-name | ip-link link-name | nqa admin-name test-name } | permanent ] [ description text ]
    • ip route-static ip-address { mask | mask-length } interface-type interface-number [ nexthop-address ] [ preference preference | tag tag ] * ldp-sync [ description text ]
    • ip route-static ip-address { mask | mask-length } vpn-instance vpn-instance-name nexthop-address [ preference preference | tag tag ] * [ track { bfd-session bfd-name | ip-link link-name | nqa admin-name test-name } | permanent ] [ description text ]
    • ip route-static ip-address { mask | mask-length } vpn-instance vpn-instance-name nexthop-address [ recursive-lookup host-route ] [ preference preference | tag tag ] * [ inherit-cost | permanent ] [ description text ]
    • ip route-static ip-address { mask | mask-length } nexthop-address [ recursive-lookup host-route ] [ preference preference | tag tag ] * [ inherit-cost | permanent ] [ description text ]

    The vpn-instance vpn-instance-name value can be a common VPN name or the VPN instance automatically generated when a virtual system is created.

    When you configure a static route for a virtual system, must be bound to the VPN instance with the same name as the virtual system.

    By default, no static route is configured.

  3. Run:

    ip route-static default-preference preference

    The default preference is set for the static route.

    By default, the preference of the static route is 60.

    When a static route is configured, the default preference is used if no preference is explicitly specified. The new default preference is valid for only the added static routes.

  4. Optional: Run:

    firewall reverse-route load-balance enable

    The load balancing function for IPv4 reverse routes is enabled.

    By default, the load balancing function for IPv4 reverse routes is disabled.

    After equal-cost routes are configured, sticky load balancing is enabled by default. If forward traffic is uneven, load unbalance occurs on reverse traffic. As a result, some interfaces may be overloaded. For scenarios where persistent connections exist and the traffic volume is large, or where a large number of GRE packets exist (GRE packets centralize at the inbound interface), you need to enable the load balancing function for reverse routes to allocate reverse traffic to interfaces in load balancing mode as configured by the firewall load-balance { flow [ hash { destination-ip | destination-port | source-ip | source-port } * ] | packet } command.

  5. Run:

    firewall ipsec load-balance enable

    The load balancing function for ESP packets is enabled.

    By default, the load balancing function for ESP packets is disabled.

    After the firewall reverse-route load-balance enable command is run, if the firewall ipsec load-balance enable command is not run, hash is performed on ESP packets based only on destination IP addresses, which may result in load unbalancing. After the firewall ipsec load-balance enable command is run, hash can be performed on ESP packets based on source and destination IP addresses, achieving load balancing.

Copyright © Huawei Technologies Co., Ltd.
Copyright © Huawei Technologies Co., Ltd.
Next topic >