OSPF uses the OSPF cost in order to calculate the best path to the destination. This cost comes from the speed your interfaces are operating at.
As you can see below, we have different types of interfaces, each with a cost number assigned.Figure 1 – OSPF cost per interface
To check the OSPF cost on our interfaces, we can use
show ip ospf interface brief
R1# show ip ospf interface brief Interface PID Area IP Address/Mask Cost State Nbrs FastEthernet0/0 1 0 192.168.10.1/255.255.255.0 1 DR 0/0 GigabitEthernet0/0 1 0 192.168.12.1/255.255.255.0 1 DR 0/0 GigabitEthernet0/1 1 0 192.168.13.1/255.255.255.0 1 BDR 0/0 Ethernet0/0 1 0 192.168.11.1/255.255.255.0 100 DR 0/0
Here, we can clearly see that:
FastEthernet and GigabitEthernet interfaces have a cost of 1
Ethernet (10 Mbps) has a cost of 100
OSPF uses these values to evaluate the efficiency of each OSPF link.
The lower the cost, the more preferred the path.Answer the question below
In a typical OSPF network, to determine which path can be used to send packets to the destination, OSPF accumulates the cost of all the outgoing interfaces along the way and chooses the path with the lowest total cost.
Figure 2 – OSPF Topology
In this example, we can check the route selected for
192.168.20.0/24
using:R1# show ip route 192.168.20.0 Routing entry for 192.168.20.0/24 Known via "ospf 1", distance 110, metric 3, type intra area Last update from 192.168.4.2 on GigabitEthernet0/1, 00:00:10 ago Routing Descriptor Blocks: * 192.168.4.2, from 192.168.20.1, 00:00:10 ago, via GigabitEthernet0/1 Route metric is 3, traffic share count is 1
As you can see, the OSPF cost is 3 when using the path:
R1 -> R5 -> R4 -> 192.168.20.0/24
Cost: 1 + 1 + 1 = total cost 3The alternative path is:
R1 -> R2 -> R3 -> R4 -> 192.168.20.0/24
Cost: 1 + 1 + 1 + 1 = total cost 4Figure 3 – OSPF chooses the path with the lowest total cost
OSPF selects the first path because it has the lowest metric.
Answer the question below
How does OSPF choose the best path?
The OSPF cost is calculated using the following formula:
Figure 4 – Formula used to calculate OSPF cost
The reference bandwidth (in Mbps) is, by default, set to 100 Mbps.
The link bandwidth is determined by your interface type on your OSPF router.Imagine you have a FastEthernet 100 Mbps interface:
→ The calculation is:Cost = 100 / 100 = 1
Pretty easy, right?
This default reference value was defined a long time ago, back when 100 Mbps was considered fast.
But today, network speeds have evolved a lot and that creates a problem.Let’s look at the different interface types, their bandwidths, and their default OSPF costs:
OSPF Default Cost per Interface Type
Interface
Formula (100 / Bandwidth in Mbps)
OSPF Cost
DSL (768 Kbps)
100 / 0.768
133
DS1 (1.544 Mbps)
100 / 1.544
64
Ethernet (10 Mbps)
100 / 10
10
FastEthernet (100 Mbps)
100 / 100
1
GigabitEthernet (1 Gbps)
100 / 1000
1
10-GigabitEthernet (10 Gbps)
100 / 10000
1
40-GigabitEthernet (40 Gbps)
100 / 40000
1
Table 1 – Default OSPF cost values per interface type (based on 100 Mbps reference).
If you examine the table above, you'll notice a key detail: from 100 Mbps and more, the OSPF cost stays fixed at 1, even as interface speeds increase. That’s because the cost is calculated using the formula100 / bandwidth
, and OSPF cost only works with whole numbers.When the result is a decimal, like 0.1 for a 1 Gbps link, it gets rounded up to 1. This means that whether you're using FastEthernet, Gigabit, or even 10 Gbps interfaces, OSPF sees them all as equal in cost.
The Problem With Default Cost
In this OSPF topology, all links with a bandwidth of 100 Mbps or more are assigned the same cost: 1.
Figure 5 – OSPF sees 100 Mbps and 1 Gbps as equal
40 % Complete: you’re making great progress
Unlock the rest of this lesson
If you’d like to continue your CCNA journey, create your free account now.
Access all free CCNA lessons
Practice with quizzes and level test
Progress tracking in your dashboard
Made by network engineers - CCNP certified
Create your Free Account1151 learners continued their CCNA journey this month