Config Lab: OSPF Metrics

Wendell Odom
By Wendell Odom September 24, 2021 15:05

OSPF chooses the best route to reach a subnet based on the lowest cost among all possible routes. OSPF calculates the cost as the sum of the OSPF interface costs of all outgoing interfaces in the route. Unsurprisingly, you can configure OSPF to influence the choice of the best route, with this lab asking you to try several OSPF mechanisms.

All about Config Labs

The blog has a series of lab exercises called “Config Labs.” Each lab presents a topology with the relevant initial configuration for each device. The lab also lists new requirements, after which you should create the additional configuration to meet those requirements. You can do the lab on paper, in a text editor, or use software tools like Cisco Packet Tracer or Cisco Modeling Labs.

Once you have created your answer, you can click various tabs at the bottom of this post to see the lab answers, comments about the lab, and other helpful information.

The Lab Exercise

Lab Requirements

OSPF uses the concept of cost as its metric for routes. The fundamental concept is straightforward:

  1. Examine a router from a route to a subnet.
  2. Find the OSPF interface cost of each outgoing interface in the route, that is, all interfaces out which a packet would be forwarded when traveling that route.
  3. Add the costs to find the cost of the route.
  4. For all routes from one router to some remote subnet, compare the costs. Place the route with the lowest cost into the routing table.

OSPF supports a couple of methods for you to influence the cost calculation, which in turn influences which routes a router adds to its routing table. You can set the cost directly using an interface subcommand. You can change the interface bandwidth setting for individual interfaces, allowing OSPF to calculate the interface cost. And you can change the system-wide reference bandwidth, which can be used to scale the interface cost, so it works well with higher-speed interfaces.


For production networks, you would likely set the OSPF RID on the routers using a consistent method. This lab instead asks you to use all methods just so you can think about how to configure each. Configure the lab as follows:

  1. All routers: Change the Reference Bandwidth to 100,000, making the default OSPF cost on a GigabitEthernet interface 100.
  2. Use these conventions:
    • R1’s route to should use R2, not R3, as the next-hop router.
    • You may configure router R1 only.
    • You may configure the OSPF cost explicitly; you cannot indirectly change the cost by configuring the bandwidth.
    • Assume all GigabitEthernet interfaces actually run at 1 Gbps.
  3. R1’s route to Configure so that R1’s cost for its route to is 150, as summarized in Table 1 below.
  4. R1’s route to Configure so that R1’s cost for its route to is 220, as summarized in Table 1 below.
  5. R4’s route to Configure so that R4’s cost for its route to is 180, as summarized in Table 1 below.


Router Route to this Subnet Cost of Route (after Configuration)
R1 (through R2) 150
R1 220
R4 180

Table 1: OSPF Route Costs to Achieve Through Configuration


Figure 1: Topology for this Lab


Initial Configuration

The configurations on the four routers show a minimal OSPF configuration. It uses mostly default OSPF settings, except that the configurations set the RID for each router.

Example 1: R1 Config


Example 2: R2 Config


Example 3: R3 Config


Example 4: R4 Config


The lab does not call for any switches or PCs. Note that if you add them yourself, you can use all default configurations in a Cisco switch for this lab, which would place all devices connected to a switch in the same VLAN.

Answer Options - Click Tabs to Reveal

You can learn a lot and strengthen real learning of the topics by creating the configuration – even without a router or switch CLI. In fact, these labs were originally built to be used solely as a paper exercise!

To answer, just think about the lab. Refer to your primary learning material for CCNA, your notes, and create the configuration on paper or in a text editor. Then check your answer versus the answer post, which is linked at the bottom of the lab, just above the comments section.

You can also implement the lab using the Cisco Packet Tracer network simulator. With this option, you use Cisco’s free Packet Tracer simulator. You open a file that begins with the initial configuration already loaded. Then you implement your configuration and test to determine if it met the requirements of the lab.

(Use this link for more information about Cisco Packet Tracer.)

Use this workflow to do the labs in Cisco Packet Tracer:

  1. Download the .pkt file linked below.
  2. Open the .pkt file, creating a working lab with the same topology and interfaces as the lab exercise.
  3. Add your planned configuration to the lab.
  4. Test the configuration using some of the suggestions below.

Download this lab’s Packet Tracer File

You can also implement the lab using Cisco Modeling Labs – Personal (CML-P). CML-P (or simply CML) replaced Cisco Virtual Internet Routing Lab (VIRL) software in 2020, in effect serving as VIRL Version 2.

If you prefer to use CML, use a similar workflow as you would use if using Cisco Packet Tracer, as follows:

  1. Download the CML file (filetype .yaml) linked below.
  2. Import the lab’s CML file into CML and then start the lab.
  3. Compare the lab topology and interface IDs to this lab, as they may differ (more detail below).
  4. Add your planned configuration to the lab.
  5. Test the configuration using some of the suggestions below.

Download this lab’s CML file!


Network Device Info:

This table lists the interfaces listed in the lab exercise documentation versus those used in the sample CML file.

Device Lab Port  CML Port
R1 G0/0/0 G0/3
R1 G0/1/0 G0/1
R1 G0/2/0 G0/2
R2 G0/0/0 G0/2
R3 G0/0/0 G0/2
R4 G0/0/0 G0/2

Lab Answers Below: Spoiler Alert

Lab Answers: Configuration (Click Tab to Reveal)

Lab Answers


Figure 1: Topology for this Lab


Example 1: R1 Config

Commentary, Issues, and Verification Tips (Click Tabs to Reveal)

Lab Commentary

First, all routers should use the same OSPF reference bandwidth setting, no matter what value is used. The lab asks you to configure a value of 100,000, so each router needs to be configured with the auto-cost reference-bandwidth 100000 command in OSPF config mode.

Once configured, note that the GigE interfaces now have a calculated metric of 100. The reference bandwidth uses a unit of Megabits per second (Mbps). Unless set explicitly, a router calculates cost as:

reference_bandwidth / interface_bandwidth.

Finally, router gigabit interfaces default to a bandwidth setting of 1,000,000 Kilobits per second (Kbps). To use the same Mbps unit in the calculation, 1,000,000 Kbps is the equivalent of 1,000 Mbps. Given those facts, each GigabitEthernet interface’s cost is calculated as:

100,000 / 1000 = 100

Next, consider router R1’s route to subnet, the subnet connected to both R2 and R3. After changing the reference bandwidth, but before changing the individual interface costs, that route would have a metric of 200, based on the detail in Figure 2:

Figure 2: Cost 200 Route from R1 to

Of note, the route’s cost is the sum of the costs shown in a box because those are outgoing interfaces for the route from R1 to subnet 

The lab also requires you to solve a small puzzle. The lab does not tell you to change the cost of specific interfaces to specific values. Instead, it tells you:

  • Configure R1 only.
  • Make the cost of a route be some total.

To solve the puzzle, you have to think about each route to decide what interface costs will be added to find the cost of the route, and then change the cost of the interface on R1 to change the route’s total cost. Given the detail and analysis with Figure 2, you should configure R1’s G0/0/0 OSPF cost. The lab also asked you to cause that route to cost 150, and R2’s G0/0 cost of 100 cannot change. By configuring the ip ospf cost 50 command under R1’s G0/0/0 interface, you change the cost of that interface and the cost of R1’s route to subnet to be 150.

Table 1 repeats the requirements from lab, now with a notation of the router, interface, and new cost value needed to achieve the lab goals.

Router Route to this Subnet Cost of Route (after Configuration) Solution: Router Interface and New Cost
R1 150 R1 G0/0/0, 50
R1 220 R1 G0/2/0, 120
R4 180 R1 G0/0, 80

Table 1: OSPF Route Costs to Achieve Through Configuration

Known Issues in this Lab

This section of each Config Lab Answers post hopes to help with those issues by listing any known issues with Packet Tracer related to this lab. In this case, the issues are:

# Summary Detail
1 None No known issues related to this lab.


Why Would Cisco Packet Tracer Have Issues?

(Note: The below text is the same in every Config Lab.)

Cisco Packet Tracer (CPT) simulates Cisco routers and switches. However, CPT does not run the same software that runs in real Cisco routers and switches. Instead, developers wrote CPT to predict the output a real router or switch would display given the same topology and configuration – but without performing all the same tasks, an actual device has to do. On a positive note, CPT requires far less CPU and RAM than a lab full of devices so that you can run CPT on your computer as an app. In addition, simulators like CPT help you learn about the Cisco router/switch user interface – the Command Line Interface (CLI) – without owning real devices.

CPT can have issues compared to real devices because CPT does not run the same software as Cisco devices. CPT does not support all commands or parameters of a command. CPT may supply output from a command that differs in some ways from what an actual device would give. Those differences can be a problem for anyone learning networking technology because you may not have experience with that technology on real gear – so you may not notice the differences. So this section lists differences and issues that we have seen when using CPT to do this lab.

Beyond comparing your answers to this lab’s Answers post, you can test in Cisco Packet Tracer (CPT) or Cisco Modeling Labs (CML). In fact, you can and should explore the lab once configured. For this lab, once you have completed the configuration, try these verification steps. 

  1. Check the OSPF metrics per the routers from the show ip route command, and compare those values to the values requested in the lab.
  2. Use the show ip ospf interface command to confirm the OSPF cost of each interface on each router.

More Labs with Related Content!

Config Lab: OSPF Router IDs
Config Lab: IPv6 EUI-64 Addressing 1
Wendell Odom
By Wendell Odom September 24, 2021 15:05
Write a comment

No Comments

No Comments Yet!

Let me tell You a sad story ! There are no comments yet, but You can be first one to comment this article.

Write a comment
View comments

Write a comment

Comment; Identify w/ Social Media or Email


Subscribe to our mailing list and get interesting stuff and updates to your email inbox.

Thank you for subscribing.

Something went wrong.