< Home

ospf cost

Function

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: Interface cost = Bandwidth reference value/Interface bandwidth where, the bandwidth reference value can be changed using the bandwidth-reference command.

Format

ospf cost cost

undo ospf cost

Parameters

Parameter Description Value
cost Indicates the cost for running OSPF. The value ranges from 1 to 65535.

Views

Ethernet interface view, Ethernet sub-interface view, Eth-Trunk interface view, Eth-Trunk sub-interface view, Tunnel interface view, Loopback interface view, Dialer interface view, VLANIF interface view, Virtual-Template interface view, BDIF interface view

Default Level

2: Configuration level

Usage Guidelines

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

Example

# Specify the cost to 65 on an OSPF interface GigabitEthernet 0/0/1.

<sysname> system-view
[sysname] interface GigabitEthernet 0/0/1
[sysname-GigabitEthernet0/0/1] ospf cost 65
Copyright © Huawei Technologies Co., Ltd.
Copyright © Huawei Technologies Co., Ltd.
< Previous topic Next topic >