preference (OSPF view)

Function

The preference command sets a priority for OSPF routes.

The undo preference command restores the default value.

By default, the priority of OSPF routes is 10. When ASE is specified, the default value is 150.

Format

preference { preferencevalue | { route-policy route-policy-name | route-filter route-filter-name } } *

preference { ase | intra | inter } { preferencevalue | { route-policy route-policy-name | route-filter route-filter-name } } *

undo preference

undo preference { ase | intra | inter }

Parameters

Parameter Description Value
preferencevalue

Specifies a priority of OSPF routes.

The smaller the priority value, the higher the priority.

The value of the priority is an integer ranging from 1 to 255.

route-policy route-policy-name

Specifies the name of a route-policy.

The name is a string of 1 to 200 case-sensitive characters, with spaces not supported. When double quotation marks are used around the string, spaces are allowed in the string.

route-filter route-filter-name

Specifies the name of route filter policy.

The value is a string of 1 to 200 case-sensitive characters, spaces not supported. If parameters are included in the referenced route-filter, specify values for them in the format of (var1, var2, ...var8) behind the route-filter name. A maximum of eight parameters can be specified, and each value ranges from 1 to 200 characters.

ase

Sets a priority for AS external routes.

-

intra

Sets a priority for intra-area routes.

-

inter

Sets a priority for inter-area routes.

-

Views

OSPF view

Default Level

2: Configuration level

Task Name and Operations

Task Name Operations
ospf write

Usage Guidelines

Usage Scenario

Multiple dynamic routing protocols can be run on a device. The system needs to set a default priority for each routing protocol. If different protocols have routes to the same destination, the protocol with the higher priority is selected to forward IP packets. To set a priority for OSPF routes, run the preference command.

You can apply a route-policy to set the priority of a specific route by setting route-policy in the preference command:

  • If the apply preference clause has been configured for the route-policy, the route priority is determined as follows:
  • For the routes matching the route-policy, the priority is determined by the apply clause.
  • For the routes that do not match the route-policy, the priority is determined by the preference command.

    In the following example, the priority of the routes matching the route-policy abc is set to 50, and the priority of the routes that do not match the route-policy is set to 30.

    route-policy abc permit node 1

    if-match cost 20

    apply preference 50

    ospf 1

    preference 30 route-policy abc
  • If the apply preference clause has not been configured for the route-policy, the priority of routes is determined by the preference command.

    In the above example, if the apply preference 50 clause has not been configured for the route-policy abc, the priority of all routes is set to 30.

Configuration Impact

When there are routes discovered by multiple routing protocols on the same router, you can enable the router to prefer OSPF routes by setting highest priority for them.

Example

# Set the priority of external routes in OSPF process 200 to 130.
<HUAWEI> system-view
[~HUAWEI] ospf 200
[*HUAWEI-ospf-200] preference ase 130
# Set the priority of routes in OSPF process 100 to 150.
<HUAWEI> system-view
[~HUAWEI] ospf 100
[*HUAWEI-ospf-100] preference 150
Copyright © Huawei Technologies Co., Ltd.
Copyright © Huawei Technologies Co., Ltd.
< Previous topic Next topic >