apply local-preference

Function

The apply local-preference command sets the local preference (Local-Pref) for BGP routes.

The undo apply local-preference command cancels the configuration.

By default, for a locally generated route and route learned from an EBGP peer (such routes do not carry the Local-Pref attribute), the device uses 100 as the local preference of those routes during route selection; for a route learned from an IBGP peer (such a route carries the Local-Pref attribute), the device uses the carried Local-Pref attribute value as the local preference of the route.

Format

apply local-preference [ + | - ] preference

undo apply local-preference

Parameters

Parameter Description Value
+

Increases the local preference of BGP routes, with the final local preference of a BGP route not greater than 4294967295. If a BGP route does not carry the Local-Pref attribute, the device uses 0 as the base local preference.

-

-

Reduces the local preference of BGP routes, with the final local preference of a BGP route not smaller than 0. If a BGP route does not carry the Local-Pref attribute, the device uses 0 as the base local preference. In this case, the local preference of the BGP route is still 0 after the deduction.

-

preference

Specifies the local preference of BGP routes.

The value is an integer ranging from 0 to 4294967295.

Views

Route-policy view

Default Level

2: Configuration level

Task Name and Operations

Task Name Operations
route-base write

Usage Guidelines

Usage Scenario

The Local-Pref attribute is a proprietary attribute of BGP, used to determine the optimal route when traffic leaves an AS. When a BGP device obtains multiple routes with the same destination address but different next hops through IBGP peers, the route with the largest Local_Pref value is selected. The apply local-preference command sets only the local preference for BGP routes.

  • 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 BGP route matches a route-policy, the local preference of the BGP route is changed.

Precautions

The Local_Pref attribute is used for route selection only within an AS and is not advertised outside the AS. Therefore, the apply local-preference command does not take effect in an export policy when the policy is used to filter routes to be advertised to an EBGP peer.

After the apply local-preference command is run in a route-policy or its configuration is changed, route updates are triggered.

Example

# Set the local preference of BGP routes to 130.
<HUAWEI> system-view
[~HUAWEI] route-policy aaa permit node 10
[*HUAWEI-route-policy] apply local-preference 130
[*HUAWEI-route-policy] quit
[~HUAWEI] bgp 100
[*HUAWEI-bgp] peer 10.1.1.1 as-number 200
[*HUAWEI-bgp] peer 10.1.1.1 route-policy aaa import
Copyright © Huawei Technologies Co., Ltd.
Copyright © Huawei Technologies Co., Ltd.
< Previous topic Next topic >