ip ospf cost [value]
Manually sets the OSPF cost (metric) on an interface, overriding the default cost derived from bandwidth, to influence path selection in OSPF routing.
ip ospf cost [value]When to Use This Command
- Forcing traffic to prefer a higher-bandwidth link by setting a lower cost on that interface.
- Making a backup link less preferred by assigning a higher cost to it.
- Equalizing costs across unequal-bandwidth links for load balancing.
- Adjusting OSPF metric to steer traffic away from a congested link.
Command Examples
Setting OSPF cost on a GigabitEthernet interface
Router(config-if)# ip ospf cost 10This command sets the OSPF cost to 10 on the current interface. No output is generated; the change is applied immediately.
Verifying the configured OSPF cost
Router# show ip ospf interface gigabitEthernet 0/0GigabitEthernet0/0 is up, line protocol is up
Internet Address 192.168.1.1/24, Area 0
Process ID 1, Router ID 1.1.1.1, Network Type BROADCAST, Cost: 10
Transmit Delay is 1 sec, State DR, Priority 1
Designated Router (ID) 1.1.1.1, Interface address 192.168.1.1
Backup Designated router (ID) 2.2.2.2, Interface address 192.168.1.2
Timer intervals configured, Hello 10, Dead 40, Wait 40, Retransmit 5
oob-resync timeout 40
Hello due in 00:00:03
Supports Link-local Signaling (LLS)
Cisco NSF helper support enabled
IETF NSF helper support enabled
Index 1/1, flood queue length 0
Next 0x0(0)/0x0(0)
Last flood scan length is 1, maximum is 25
Last flood scan time is 0 msec, maximum is 4 msec
Neighbor Count is 1, Adjacent neighbor count is 1
Adjacent with neighbor 2.2.2.2 (Backup Designated Router)
Suppress hello for 0 neighbor(s)The output shows OSPF interface details. The 'Cost: 10' field confirms the configured cost. Other fields: 'Internet Address' is the interface IP, 'Area' is the OSPF area, 'Process ID' and 'Router ID' identify the OSPF process, 'Network Type' is broadcast, 'State' is DR (Designated Router), and 'Neighbor Count' shows adjacent neighbors.
Understanding the Output
The 'show ip ospf interface' command displays OSPF parameters for an interface. The 'Cost' field shows the OSPF metric; lower values indicate more preferred paths. Default cost is 10^8 / bandwidth (bps). A manually set cost overrides this. Other key fields: 'State' indicates the router's role (DR, BDR, DROTHER); 'Neighbor Count' shows discovered neighbors; 'Adjacent neighbor count' shows fully adjacent neighbors. High cost values (e.g., >100) may indicate slower links or misconfiguration. Watch for mismatched costs on links that should be equal.
CCNA Exam Tips
CCNA exam tip: OSPF cost is inversely proportional to bandwidth; default cost = 10^8 / bandwidth. Manually setting cost overrides this.
CCNA exam tip: The 'ip ospf cost' command is configured in interface configuration mode, not OSPF router mode.
CCNA exam tip: OSPF uses cost as the metric; the lowest cost path to a destination is preferred.
CCNA exam tip: To verify the cost, use 'show ip ospf interface' and look for the 'Cost' field.
Common Mistakes
Mistake: Setting cost on the wrong interface, causing unintended path selection.
Mistake: Forgetting that cost is a 16-bit value (1-65535); values outside this range are rejected.
Mistake: Assuming cost is the only factor; OSPF also considers path type (intra-area, inter-area, external).
Related Commands
Practice for the CCNA 200-301
Test your knowledge with hundreds of CCNA practice questions covering all exam domains.
Practice CCNA Questions