The ospf cost command specifies the cost for 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: where, the bandwidth reference value can be changed using the bandwidth-reference command.
| Parameter | Description | Value |
|---|---|---|
| cost | Indicates the cost for running OSPF. | The value ranges from 1 to 65535. |
Usage Scenario
Generally, OSPF automatically calculate the link cost for an interface based on the bandwidth of the interface. You can modify the interface cost using the ospf cost command. For example, when you configure load balancing, you can run this command to modify the interface cost of the routes if conditions are satisfied for load balancing.
If the cost for OSPF on the interface is not configured using the ospf cost command, OSPF will automatically calculate the cost based on the bandwidth of the interface. 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 value is 1. By default, the reference value of bandwidth of OSPF is 100 Mbit/s.
Configuration Impact
The cost varies with bandwidth of the interface, the default costs of various types of interfaces are as follows:
56 kbit/s Serial port: 1785
64 kbit/s Serial port: 1562
E1 (2.048 Mbit/s): 48
Ethernet (100 Mbit/s): 1