apply preference

Function

The apply preference command sets a priority for routes.

The undo apply preference command cancels the configuration.

By default, no priority is set for routes.

Format

apply preference preference

undo apply preference

Parameters

Parameter Description Value
preference

Specifies the route priority. Devices need to be shared and selected when multiple routing protocols run on the device; therefore, a default priority needs to be specified for each routing protocol. When different protocols discover multiple routes to the same destination, the route discovered by the protocol with a higher priority is selected to forward IP packets. The smaller the priority value, the higher the priority.

The value is an integer ranging from 1 to 255.

Views

Route-policy view

Default Level

2: Configuration level

Task Name and Operations

Task Name Operations
route-base write

Usage Guidelines

Usage Scenario

If a route matches the filtering conditions specified in the if-match clause, you can run the apply preference command to change the priority of the route for route selection. When different protocols discover multiple routes to the same destination, the route discovered by the protocol with a higher priority is selected to forward IP packets.

  • Run the route-policy command to enter the Route-policy view.
  • A route-policy may consist of multiple nodes. The relationship between the nodes is "OR". The system matches a route against the nodes in sequence. If the route matches a node, the route matches the route-policy, and the system no longer matches it against other nodes.
  • Each node comprises a set of if-match and apply clauses. The if-match clauses define the filtering rules that are used to match certain route attributes. The relationship among if-match clauses of the same node that are based on different route attributes is AND. A route matches a node only when the route matches all the filtering rules specified in the if-match clauses of the node. The apply clauses specify actions. The relationship among if-match clauses of the same node that are based on the same route attribute is OR. The system matches routes against the if-match clauses in order. If a route matches an if-match clause, the system no longer matches the route against the rest if-match clauses. For example, the if-match community-filter 1 and if-match as-path-filter 1 configurations in node 10 are based on different route attributes. Therefore, the relationship among if-match clauses of this node is AND. The if-match community-filter 1 and if-match community-filter 2 configurations in node 20 are both based on the community attribute. Therefore, the relationship among if-match clauses of this node is OR. The apply clauses specify actions. If a route matches a node, the apply clauses set some attributes for the route.

Prerequisites

A route-policy has been configured using the route-policy command.

Configuration Impact

After a route matches a route-policy, the priority of the route is changed.

Precautions

Currently, a route-policy cannot be applied to set the BGP preference of routes advertised to or accepted from a BGP peer using the peer route-policy command. Instead, the preference route-policy command can be run in the BGP view to change the BGP preference globally.

Example

# Set the priority for routes.
<HUAWEI> system-view
[~HUAWEI] route-policy policy permit node 10
[*HUAWEI-route-policy] apply preference 90
Copyright © Huawei Technologies Co., Ltd.
Copyright © Huawei Technologies Co., Ltd.
< Previous topic Next topic >