< Home

preference (OSPF)

Function

The preference command sets the preference of an OSPF route.

The undo preference command restores the default preference of the OSPF route.

By default, the preference of the OSPF route is 10. When ASE is specified, the default value is 150.

Format

preference [ ase ] { preference | route-policy route-policy-name } *

undo preference [ ase ]

Parameters

Parameter Description Value
ase Indicates the preference of the AS external route. -
preference Specifies the preference of the OSPF route.

The smaller the preference value, the higher the preference.

The value of the preference is an integer ranging from 1 to 255.
route-policy route-policy-name Specifies the name of the route policy. The value must be the name of an existing routing policy.

Views

OSPF view

Default Level

2: Configuration level

Usage Guidelines

Usage Scenario

The routing protocols may share and select the routing information because the router may run multiple dynamic routing protocols at the same time. In this case, a preference should be set for each routing protocol. When different protocols find multiple routes to the same destination, the route discovered by the protocol with a higher preference is selected. This command sets the preference of an OSPF route.

When configuring the route-policy parameter, you can set the preference for specific routes by using the routing policy.
  • If the apply preference clause is included in the route-policy, different routes have different preference:
    • Matched routes: Their preference is set by the apply clause.

    • Unmatched routes: Their preference is set by the preference command.

    As shown in the following example, the preference of routes that match the policy abc is set to 50, and the preference of routes that do not match the policy abc 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 is not included in the route-policy, the preference of routes is set by the preference command.

    In the above example, if the apply preference 50 clause is not included in the policy abc, the preference of all routes is set to 30.

Configuration Impact

When multiple routing protocols discover the same route, you can set OSPF preference to maneuver route selection.

Creating a route-policy before it is referenced is recommended. By default, nonexistent route-policies cannot be referenced using the command. If the route-policy nonexistent-config-check disable command is run in the system view and a nonexistent route-policy is referenced using the current command, the configured priority apply to all OSPF routes.

Example

# Set the preference of routes in OSPF process 1 to 150.

<sysname> system-view
[sysname] ospf 1
[sysname-ospf-1] preference 150

# Set the preference of external routes in OSPF process 100 to 130.

<sysname> system-view
[sysname] ospf 100
[sysname-ospf-100] preference ase 130
Copyright © Huawei Technologies Co., Ltd.
Copyright © Huawei Technologies Co., Ltd.
< Previous topic Next topic >