Config Lab: OSPF Metrics

 In 200-301 V1 Ch23: OSPF - Optional Features, 200-301 V1 Part 6: OSPF, 200-301 V1 Parts, Config Lab, Config Lab CCNA Vol 1 Part 6, Hands-on

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 172.16.2.0/24 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 172.16.2.0/24: Configure so that R1’s cost for its route to 172.16.2.0/24 is 150, as summarized in Table 1 below.
  4. R1’s route to 172.16.4.0/24: Configure so that R1’s cost for its route to 172.16.4.0/24 is 220, as summarized in Table 1 below.
  5. R4’s route to 172.16.1.0/24: Configure so that R4’s cost for its route to 172.16.1.0/24 is 180, as summarized in Table 1 below.

 

Router Route to this Subnet Cost of Route (after Configuration)
R1 (through R2) 172.16.2.0/24 150
R1 172.16.4.0/24 220
R4 172.16.1.0/24 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.

hostname R1
!
interface GigabitEthernet0/0
 ip address 172.16.1.1 255.255.255.0
 ip ospf 1 area 0
!
interface GigabitEthernet0/0/0
 ip address 172.16.12.1 255.255.255.0
 ip ospf 1 area 0
!
interface GigabitEthernet0/1/0
 ip address 172.16.13.1 255.255.255.0
 ip ospf 1 area 0
!
interface GigabitEthernet0/2/0
 ip address 172.16.14.1 255.255.255.0
 ip ospf 1 area 0
!
router ospf 1
 router-id 1.1.1.1

Example 1: R1 Config

 

hostname R2
!
interface GigabitEthernet0/0
 ip address 172.16.2.2 255.255.255.0
 ip ospf 1 area 0
!
interface GigabitEthernet0/0/0
 ip address 172.16.12.2 255.255.255.0
 ip ospf 1 area 0
!
router ospf 1
 router-id 2.2.2.2

Example 2: R2 Config

 

hostname R3
!
interface GigabitEthernet0/1
 ip address 172.16.2.3 255.255.255.0
 ip ospf 1 area 0
!
interface GigabitEthernet0/0/0
 ip address 172.16.13.3 255.255.255.0
 ip ospf 1 area 0
!
router ospf 1
 router-id 3.3.3.3

Example 3: R3 Config

 

hostname R4
!
interface GigabitEthernet0/0
 ip address 172.16.4.4 255.255.255.0
 ip ospf 1 area 0
!
interface GigabitEthernet0/0/0
 ip address 172.16.14.4 255.255.255.0
 ip ospf 1 area 0
!
router ospf 1
 router-id 4.4.4.4

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

 

router ospf 1
 auto-cost reference-bandwidth 100000
!
interface GigabitEthernet0/0
 ip ospf cost 80
!
interface GigabitEthernet0/0/0
 ip ospf cost 50
!
interface GigabitEthernet0/2/0
 ip ospf cost 120

Example 1: R1 Config

 

router ospf 1
 auto-cost reference-bandwidth 100000

Example 2: R2 Config

 

router ospf 1
 auto-cost reference-bandwidth 100000

Example 3: R3 Config

 

router ospf 1
 auto-cost reference-bandwidth 100000

Example 4: R4 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 172.16.2.0/24, 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 172.16.2.0/24

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 172.16.2.0/24. 

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 172.16.2.0/24 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 172.16.2.0/24 150 R1 G0/0/0, 50
R1 172.16.4.0/24 220 R1 G0/2/0, 120
R4 172.16.1.0/24 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
Subscribe
Notify of
guest

35 Comments
Oldest
Newest Most Voted
Inline Feedbacks
View all comments
jp

Hello,

Why are the costs in the answer different than the problem presented? Also, don’t we need to configure R4 Gi0/0/0 interface’s for cost?

certskills

Hi JP,
Sorry for the delay in answering.
Q1: I think I’m misunderstanding you, but: The lab begins with default costs, and asks you to reconfigure the costs per some details in the lab. So the answer by definition lists different costs than at the beginning of lab. On my reading of the answer, it meets the requirements.
Q2: The lab states to only configure router R1, so while you could meet the goal of changing R4’s cost for a route by changing the config on R4’s G0/0/0, instead, the lab shows that route’s cost changing due to config on R1’s G0/0 interface.
Hope this helps…

alberto silva

Hello, I think I have the same question, i wonder why it was asked to configure 150, 180, 220 costs and the configuration is showing, 50, 80 and 120?

KG

Hello Wendell!

Thanks for this lab. For the reference bandwidth, isn’t it by default already 100,000 kbps? To change it to 1 gbps, shouldn’t we enter it in as 1000 as when this is changed the router sees the units as mbps?

certskills

Hi KG,
You’re welcome!
OSPF reference bandwidth defaults to 100, with a unit of Megabits/second. To change the reference BW to 1 Gbps (aka 1000 Mbps), you’d configure “reference-bandwidth 1000”.
Are you possibly confusing the setting or units with interface bandwidth? See next comment…

KG

Hello Wendell!

Thank you for the response! Got it. Yea i was confusing it with the interface bandwidth as the interface bandwidth is viewed by the router in kbps.

So in this lab, we are configuring the ospf reference bandwidth with the speed of 100,000 mbps or 100GigE so that our cost on the interfaces is 100. Right? I think i understand it now lol

Thank You!

KG

certskills

Yep… w/ Ref BW = 100,000 (meaning 100,000 Mbps or 100 Gbps), and an interface BW of 1,000,000 (meaning 1,000,000 Kbps or 1 Gbps), the ratio is 100, making the calculated OSPF cost 100.
I always struggled with units back in HS/College Physics – helps to write out the equation w/ units sometimes to make the units match. 🙂

KG

Writing it out is always best 🙂 Thanks again Wendell!

KG

Hello Wendell!

Thank you for your labs, they are very helpful. For the reference bandwidth, by default, doesn’t the router list it as 100,000kbps? Also, when we want to change it, it changes it in units of mbps? So for a gigabit reference bandwidth, shouldn’t it be 1,000mbps?

certskills

Looking here again, I think you’re repeating the same question, probably because I was slow in approving the first one – sorry about that. I think I already answered – follow up if not.

KG

Hello Wendell!

Apologies as i did not realize that you had to release the post first before it appeared on the comments. You have answered my question, please disregard this post.

Thank You!

KG

certskills

Got it. no worries.

Ramanathan Prabakaran

Some understandable points from the lab answrs here, (perhaps, due to the lack of sufficient, or due to the lack of updated contents of OSPF, study material), are the values of path costs are, not merely their magnitudes, but, they are, Vectors, possesing both a direction, and magnitude.

Of course, it is quite, a natural point that, a path or any path towards a destination, is a Vector element.

Please would you confirm the point I mentioned here about path cost, i.e, it is a Vector element???

Tks a lot.

certskills

Hi Ram,
I wouldn’t consider OSPF cost to be a vector. Both interface cost, and even the cost of a route generated by the SPF process, is a unitless non-negative number with no direction or vector element in the cost. Certainly, a route that’s calculated by OSPF both has a metric component as well as details like next-hop that you could treat as a vector, but that’s the route as a vector, not the cost. Just my opinion; not something that’s mattered in my world. Hope this helps.

GJM

I am a little confused on this one. I know it says to only configure R1, but when setting the reference bandwidth it said to make sure to match across all other routers; so I did. But I see you didn’t do that on the other routers.

Also I configured R4 G0/0/0 with a cost of 80 (to change the cost of the route to 172.16.1.0). But I also see you configured it differently than myself.

GJM

Oh nevermind, I think I understand it now. You wanted us to configure the outgoing interface costs on R4 to reach the 172.16.1.0, which is R1 G0/0.

Dirk

Hello,

In the lab requirements shouldn’t it say “cost” instead of “RID” in
“For production networks, you would likely set the OSPF RID on the routers using a consistent method.”?

kirill

Hello,

Have a question about chapter 20: Implementing OSPF. Why do computers need to be able to ping each other through different subnets when all they need is to reach the internet through their respective default gateways? I understand if its a server in a different subnet that they need to reach, but why computers.

kirill

Thanks for the reply.
With OSPF implemented on all routers. All hosts reach the internet facing router? Since routers know routes to all subnets? This is the reason for knowing all routes in a network?
Also, To fully understand ipv6 you need rick graziani ipv6 fundamentals? The pearson network simulator goes more in depth on ipv4 then ipv6. It doesn’t go into full detail on the numbering scheme for hosts.

Tewa

Hello Wendell,

Please a question. The show ip ospf int brief command on R1 does not list any values in the neighbor column, why is that? Is R1 not considered to have neighbor relationships with R2, R3 & R4?

R1(config-if)#do show ip ospf int brief
Interface PID Area IP Address/Mask Cost State Nbrs F/C
Gig0/2/0 1 0 172.16.14.1/255.255.255.0 120 BDR 0/0
Gig0/1/0 1 0 172.16.13.1/255.255.255.0 100 BDR 0/0
Gig0/0/0 1 0 172.16.12.1/255.255.255.0 50 BDR 0/0
Gig0/0 1 0 172.16.1.1/255.255.255.0 80 DR 0/0

Charlie

Hi Wendell,

I have done the lab according to the specs. All show commands list correct cost numbers after configs. I am a little confused as to why the cost numbers add up the way they do. For instance for R1 int. G0/0/0, if the cost is 50, why would the total trip from R1 to R2 be 150 and the same for the other configured costs (220 & 180)?
Counting outgoing interfaces from R1 to R2 it would only be 2 hops. How does a cost of 50 add up to 150 total cost? What am I missing? Thank you.

austin dillard

I initially got this wrong, but after reading through the comments, it clicked. By changing the cost on the GI links to 100 for R1, R2, and R4, it made all the links cost that amount to use. So, by adjusting the interface costs on R1, we effectively add to the costs on the other routers, creating the correct sum total. Thanks for the insight!

Elizabeth

Finding the cost from R1 to 172.16.1.0/24 with R1 interface G0/0 having cost 80, the route consists of R1s G0/0, connected to 172.16.1.0/24 with cost 80, as the sole interface in the route. The cost is the sum of the costs of the outgoing interfaces, that being 80 which is incorrect. What am I missing?

kirill

Hello Wendell,

Question about the attached image. Router R2 G0/0 and R3 G0/0 in the same subnet. When you connect their LANs together. Are you closing the network at that segment or they are connected to a LAN switch?

Document_20241204_0001
Contact Us

We're not around right now. But you can send us an email and we'll get back to you, asap.

35
0
Would love your thoughts, please comment.x
()
x