ospf cost

Function

The ospf cost command sets a cost for an OSPF interface.

The undo ospf cost command restores the default cost.

By default, the cost of an OSPF interface is calculated using the following formula: Interface cost = Bandwidth reference value/Interface bandwidth, in which the bandwidth reference value can be changed using the bandwidth-reference command.

Format

ospf cost value

undo ospf cost

Parameters

Parameter Description Value
value

Specifies the cost of an OSPF interface.

The value is an integer ranging from 1 to 65535.

Views

100GE interface view, 10GE interface view, 25GE sub-interface view, 25GE interface view, 400GE interface view, 40GE interface view, 50GE sub-interface view, 50GE interface view, Eth-Trunk interface view, FlexE interface view, GE optical interface view, GE electrical interface view, GMPLS-UNI interface view, Global VE sub-interface view, Loopback interface view, Tunnel interface view, VBDIF interface view, VE sub-interface view, VLANIF interface view

Default Level

2: Configuration level

Task Name and Operations

Task Name Operations
ospf write

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 using the ospf cost command. Load balancing can be implemented among several routes of the same protocol, cost, and destination address. According to the actual networking condition, you can determine whether to perform load balancing by changing the interface cost.

If no cost is set for an OSPF interface using 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.

NOTE:

No default cost is configured for trunk interfaces, because they have multiple member interfaces that are in constant change.

Precautions

The ospf cost command cannot run on null interfaces.

Example

# Set the cost of GigabitEthernet 0/1/0 that runs OSPF to 65.
<HUAWEI> system-view
[~HUAWEI] interface GigabitEthernet0/1/0
[~HUAWEI-GigabitEthernet0/1/0] ospf cost 65
Copyright © Huawei Technologies Co., Ltd.
Copyright © Huawei Technologies Co., Ltd.
< Previous topic Next topic >