OSPF use cost as a metric. On Cisco routers cost is nothing more than calculated cumulative bandwidth on the path from source to destination. However we are just using bandwidth, there is a formula for calculating the cost. The lower the metric the better the path. More bandwidth means better right? Thats why the formula for calculating cost is 10to8(100 mb/sek)/BW(bps).
RFC2328 doesnt specify what cost should be, but Cisco uses BW as a reference value.
Default costs value are:
- T1 (1544 Mbps serial link) – 64
- E1 (2048 Mbps serial link) – 48
- Ethernet (10 Mbpsek) – 10
- FastEthernet (100 Mbpsek) – 1
- GigabitEthernet (1 Gbpsek) – 1
Changing the cost metric is necessary if you have faster interfaces than FastEthernet. The ip ospf cost, bandwidth, auto-cost reference-bandwidth are the commands can be used to manipulate the cost.
Auto-cost reference-bandwidth changes the numerator value in the formula (10to8). Auto-cost reference value is in Mbps so the default value is 100. Change should be done on all routers to reflect the proper cost calculation.
Bandwidth command doesn’t change the actual bandwidth at the interface. It is used for OSPF, EIGRP, QoS calculations and its not recommended to change it unless you want to reflect the real bandwidth put on the interface for example from ISP.
Ip ospf cost will override your cost calculated at interface. It is an integer value from 1 to 65535. The lower the number the better.
Calculating the cost for External routes E1/E2
The cost of external routes depends on the external type configured on ASBR:
- E1 – in routing table as O E1 external routes calculates the cost by adding the external cost to the internal cost of each link the packet crosses. Use this type when multiple ASBRs are advertising the external route to the same autonomous system, to avoid suboptimal routing.
- E2 – this is default. In E2 packet use always only external cost assigned. Default cost is 20.