How does OSPF work out the interface cost?
By default the ospf cost calculation is based on a reference bandwidth of 100Mb
The calculation is Reference BW / Configured BW
So for a 100Mb interface using the default reference bandwidth of 100Mb
The calculation is 100Mb / 100Mb =1
However with modern networks 100Mb is not the fastest interface and 1G and 10G interfaces are common however the ospf cost can go no lower than 1 so it cannot differntiate between a 100Mb interface or a 1G / 10G interface.
To overcome this issue you can set an auto-cost reference bandwidth to affect this calculation.
This is set in the ospf process
Router1(config)#router ospf 1 Router1(config-router)#auto-cost reference-bandwidth ? <1-4294967> The reference bandwidth in terms of Mbits per second
Router1(config-router)#auto-cost reference-bandwidth 20000 % OSPF: Reference bandwidth is changed. Please ensure reference bandwidth is consistent across all routers. Router1(config-router)#
Note the reference bandwidth command warns you that you need to make the same change across all your routers. This is to ensure all routers can make their calcuations on the same information.
So how does this affect your ospf int cost?
Router1#sh ip ospf int FastEthernet0/0 is up, line protocol is up Internet Address 10.251.251.162/28, Area 1 Process ID 1, Router ID 195.89.22.116, Network Type BROADCAST, Cost: 200
As you can see from the output of sh ip ospf interface, the Cost of this interface is now 200
The other way of affecting the cost of an interface is through the ip ospf cost command on the interface itself – this will override the calculated cost
Router1(config)#int f1/0 Router1(config-if)#ip ospf cost 12345 Router1#sh ip ospf int FastEthernet1/0 is up, line protocol is up Internet Address 123.123.123.123/28, Area 1 Process ID 1, Router ID 195.89.22.116, Network Type BROADCAST, Cost: 12345
As you can see from the output of sh ip ospf int the cost has now changed to 12345
This is great fun in the lab but you need to ensure you have your interface costs consistent across your network to ensure optimum routing path calculations.