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