ospf cost
Function
The ospf cost command sets the cost of an OSPF on an interface.
The undo ospf cost command restores the default cost for OSPF.
By default, the cost of an interface running OSPF is calculated using the following formula: bandwidth-reference command. The default cost of loopback interface is 0.
where, the bandwidth reference value can be changed using theParameters
Parameter | Description | Value |
---|---|---|
cost | Specifies the cost of an OSPF-enabled interface. | The value is an integer ranging from 1 to 65535. By default, it is 1. |
Usage Guidelines
Usage Scenario
OSPF can automatically calculate the link cost for an interface based on the interface bandwidth. You can also set the link cost for the interface through ospf cost commands.
Load balancing can be performed among several routes with the same protocol, cost, and destination address. According to the actual networking condition, you can determine whether to perform load balancing by changing the cost of the interface.
Configuration Impact
If no cost is set for an OSPF interface through the ospf cost command, OSPF automatically calculates its cost based on the interface bandwidth. The calculation formula is as follows: Cost of the interface = Bandwidth reference value/Interface bandwidth. The integer of the calculated result is the cost of the interface. If the calculated result is smaller than 1, the cost is 1. Changing the bandwidth reference value can change the cost of an interface.
By default, the bandwidth reference value is 100 Mbit/s divided by the interface bandwidth. With the formula 100000000/Bandwidth, the default costs of the Ethernet (100 Mbit/s) interface is 1.
Precautions
The ospf cost command cannot run on null interfaces.