# Why is the default OSPF cost of an interface on an S series switch incorrect

53

Question: Why is default OSPF cost value incorrect?
For example, after OSPF is enabled on a device, the default OSPF cost value of an Ethernet interface is 7. Generally, the default OSPF cost value of an interface is 1.

Answer: The default OSPF cost value of an interface on an S series switch supporting OSPF depends on the values of bandwidth and bandwidth-reference. The value of bandwidth-reference is configured in an OSPF process. Generally, the default bandwidth-reference value is used. In this case, if the default bandwidth value is 100 Mbit/s, the OSPF cost value is 1.

###### Other related questions:
Calculating the cost of an OSPF interface on the firewall
Calculating the cost of an OSPF interface on the USG2000&5000&6000 series as follows: The cost configured on the interface is preferred. If no cost is configured on the interface, the formula for calculating the cost of the interface is as follows: Cost = Reference bandwidth/Interface bandwidth. The default reference bandwidth of OSPF is 100 Mbit/s. For example, the cost of a 10 Mbit/s Ethernet interface = 100 Mbits per second/10 Mbits per second = 10. If the calculation result is smaller than 1, the cost is set to 1. For example, the cost of a GE interface is 100 Mbits per second/1000 Mbits per second = 0.1, which is less than 1. Therefore, the cost of this interface is 1. The default cost on the loopback interface, which is a virtual interface, is 0.

How is the cost of an OSPF interface calculated
The principles of calculating the cost of an OSPF interface are as follows: The cost configured on the interface is preferred. If no cost is configured on the interface, the formula for calculating the cost of the interface is as follows: Cost = Reference bandwidth/Interface bandwidth. The default reference bandwidth of OSPF is 100 Mbit/s. For example, the cost of a 10 Mbit/s Ethernet interface = 100 Mbits per second/10 Mbits per second = 10. If the calculation result is smaller than 1, the cost is set to 1. For example, the cost of a GE interface is 100 Mbits per second/1000 Mbits per second = 0.1, which is less than 1. Therefore, the cost of this interface is 1. The default cost on the loopback interface, which is a virtual interface, is 0.

Why is the OSPF default cost incorrect
For example, after the OSPF process is enabled on the device, the information about the interface is displayed. The output information shows that the default OSPF cost of an Ethernet interface is 7. Generally, the default OSPF cost is 1. The default cost of an OSPF interface is calculated based on the bandwidth and bandwidth-reference. Bandwidth-reference is configured under the OSPF process. Normally, the default bandwidth-reference value is used. If the default bandwidth is 100 Mbit/s, the OSPF cost is calculated as 1.

OSPF cost of S series switches
The ospf cost command can be executed on an S series switch that supports OSPF to configure the cost required for running the OSPF protocol on an interface. Application scenario: The interface cost can be automatically calculated by OSPF based on the interface bandwidth or manually configured by using the ospf cost command. If the costs and destination IP addresses of multiple routes discovered by one routing protocol are the same, load balancing can be implemented among the routes. Modify interface costs to implement load balancing as required. Configuration impact: If no interface cost is configured by using the ospf cost command, OSPF automatically calculates the interface 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 value is 1. Changing the bandwidth reference value can change the cost of an interface. By default, the bandwidth reference value is 100 Mbit/s. Therefore, the default cost value of an Ethernet (100 Mbit/s) interface is 1 (100,000,000/the interface bandwidth). Example: Set the cost required by VLANIF 100 for running OSPF to 65. [HUAWEI] interface vlanif 100 [HUAWEI-Vlanif100] ospf cost 65 Set the cost required by GE0/0/1 for running OSPF to 65. [HUAWEI] interface gigabitethernet 0/0/1 [HUAWEI-GigabitEthernet0/0/1] undo portswitch [HUAWEI-GigabitEthernet0/0/1] ospf cost 65 Note: The cost calculated by OSPF is the cost of the route to the outbound interface of the destination network.

Why is an OSPF-enabled interface on an S series switch in different states
Question: Why is an OSPF-enabled interface in different states? Answer: If a tunnel interface is created using the IP address of an OSPF-enabled loopback interface and the tunnel interface is Down, the interface is in different states. You can run the display ospf interface all command to check details about an OSPF interface. [HUAWEI]display ospf interface all OSPF Process 1 with Router ID 1.1.1.1 Interfaces Area: 0.0.0.0 (MPLS TE not enabled) Interface: 1.1.1.1 (LoopBack0) Cost: 1 State: DR Type: Broadcast MTU: 1500 Priority: 1 Designated Router: 1.1.1.1 Backup Designated Router: 0.0.0.0 Timers: Hello 10 , Dead 40 , Poll 120 , Retransmit 5 , Transmit Delay 1 Interface: 1.1.1.1 (Tunnel0/0/1) Cost: 1562 State: Down Type: P2P MTU: 1500 Unnumbered Timers: Hello 10 , Dead 40 , Poll 120 , Retransmit 5 , Transmit Delay 1

###### If you have more questions, you can seek help from following ways:
To iKnow To Live Chat