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.
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. |
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.
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.<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