OSPF cost of S series switches

2

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.

Other related questions:
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.

Maximum number of equal-cost OSPF routes supported by an S series switch
The maximum number of equal-cost OSPF routes on an S series modular switch that supports OSPF is 16 and that on an S series fixed switch that supports OSPF is 8. You can run the maximum load-balancing number command to set the maximum number of equal-cost OSPF routes.

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.

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.

Definition of ABR in OSPF on S series switches
Question: What is the definition of ABR? Is a device with more than two areas configured an ABR? Answer: According to RFC 2328, an OSPF backbone area contains the ABRs of all areas. That is, an ABR must belong to a backbone area. If Area 2 and Area 3 are configured on a device with no interface in a backbone area, the device is not an ABR. If two or more areas are configured on an S series switch supporting OSPF and one of these areas is a backbone area, the switch is an ABR. Not all these areas must have interfaces in the Up state.

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