The preference command sets a preference for an OSPF route.
The undo preference command restores the default preference of OSPF routes.
By default, the preference of OSPF routes is 10 and that of ASE routes is 150.
Parameter | Description | Value |
---|---|---|
ase | Indicates the preference of an AS external route. | - |
preference | Specifies the preference of an OSPF route. The smaller the preference value, the higher the preference. |
The value 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 40 case-sensitive characters, with spaces not supported. When double quotation marks are used around the string, spaces are allowed in the string. |
Usage Scenario
Multiple dynamic routing protocols can run on a switch at the same time. This creates a problem of route sharing and selecting among routing protocols. The system sets a default preference for each routing protocol. If different protocols have routes to the same destination, the protocol with a higher preference is selected to forward IP packets. To set a preference for an OSPF route, run the preference command.
Route matching the route-policy: Its preference is determined by the apply clause.
Route that does not match the route-policy: Its preference is determined by the preference command.
In the following example, the preference of the route matching the route-policy abc is set to 50 and the preference of the route that does 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 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 there are routes discovered by multiple routing protocols on the same switch, you can make the switch prefer OSPF routes by setting a high preference for them.
Precautions
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.