How To Configure OSPF Cost Metric

In the previous posts, we have discussed the basics of Open Shortest Path First (OSPF) protocol and how to configure OSPF routing. In this post, we will explain how the OSPF protocol decides the best (or shortest) path to a destination network and how to configure OSPF cost metric value. Before configuring the OSPF cost metric value, we would recommend to have a quick review of OSPF routing protocol and how to configure OSPF routing protocol. You may use the following links to understand the OSPF routing protocol.

The OSPF routing protocol uses the cost metric to determine the best path to a destination network. The cost metric is based on the bandwidth of the interfaces. The total cost of a route is equal to the sum of all outgoing interface costs. The lowest cost is preferred to route the network traffic.

The following table lists the default OSPF cost values used by Cisco routers, which depends on the types of the interface being used for a specific route.OSPF Default Cost Metric

How to Calculate OSPF Cost?

Now, let’s have a look how the OSPF cost is calculated. To calculate the OSPF cost metric of an interface, the following formula is used.

  • Cost = 100/ the bandwidth of the interface in Mbps

For example, let’s calculate the OSPF cost of an Ethernet interface. We know that the bandwidth of an Ethernet interface is 10. So the OSPF cost metric value for an Ethernet interface would be:

  • Cost = 100/10 = 10

Let’s have a look at another example: how to calculate the cost of a T1 interface?

  • Cost =100/1.544 = 64 (approximately)

Note: For the Serial interfaces, OSPF will use the configured bandwidth, measured in Kbps, to determine the cost.

How to Change the Default OSPF Cost Metric?

You can change the default cost metric value for an interface. However, you should be very careful otherwise, your network may misbehave if you configure the cost metric value inappropriately. In order to change the default OSPF cost metric value, you need to execute the following commands.

Router(config)#interface <name/number>
Router(config-if)#ip ospf cost <cost value 1-65535>

For example, let’s set the OSPF cost metric value as 150 for the Fa0/0 interface. To do so, execute the following commands.

Router(config)#interface Fa0/0
Router(config-if)#ip ospf cost 150

The following figure shows how to change or configure the OSPF cost metric.OSPF Cost Metric

In this post, we have learned how to configure OSPF cost metric value. Hope it helped you to understand the OSPF cost metric. Please share the post with others too, sharing it will not cost you anything.

Posted in Cisco, Routing Tagged with: , ,