O'Reilly logo

Cisco IOS Cookbook, 2nd Edition by Ian Brown, Kevin Dooley

Stay ahead with the world's most comprehensive technology and business learning platform.

With Safari, you learn the way you learn best. Get unlimited access to videos, live online training, learning paths, books, tutorials, and more.

Start Free Trial

No credit card required

Adjusting OSPF Costs

Problem

You want to change the OSPF link costs.

Solution

The auto-cost reference-bandwidth command allows you to change the reference bandwidth that OSPF uses to calculate its metrics:

Router5#configure terminal 
Enter configuration commands, one per line.  End with CNTL/Z.
Router5(config)#router ospf 87
Router5(config-router)#auto-cost reference-bandwidth 1000
Router5(config-router)#exit
Router5(config)#end
Router5#

You can also adjust the OSPF cost of a single interface with the ip ospf cost configuration command:

Router5#configure terminal 
Enter configuration commands, one per line.  End with CNTL/Z.
Router5(config)#interface Ethernet0
Router5(config-if)#ip ospf cost 31
Router5(config-if)# exit
Router5(config)#end
Router5#

Discussion

The custom in OSPF networks is to make the link cost inversely proportional to the bandwidth of a link. This isn’t required, but it is common, and it is the default behavior for Cisco routers. The reference bandwidth defines the link speed that has an OSPF cost of 1. By default, the reference bandwidth is 100 Mbps.

However, if you have faster links in your network, such as gigabit Ethernet or OC-3 connections, OSPF can’t give these links a better cost than 1. So you should set the reference bandwidth to at least as high as the fastest link in your network. In fact, you may want to set this value higher than the bandwidth of your fastest link to ensure that you don’t have to reconfigure your whole network when you eventually upgrade some ...

With Safari, you learn the way you learn best. Get unlimited access to videos, live online training, learning paths, books, interactive tutorials, and more.

Start Free Trial

No credit card required