Config Lab: OSPF Metrics
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.
The Lab Exercise
Lab Requirements
OSPF uses the concept of cost as its metric for routes. The fundamental concept is straightforward:
- Examine a router from a route to a subnet.
- 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.
- Add the costs to find the cost of the route.
- 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:
- All routers: Change the Reference Bandwidth to 100,000, making the default OSPF cost on a GigabitEthernet interface 100.
- 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.
- 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.
- 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.
- 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:
- Download the .pkt file linked below.
- Open the .pkt file, creating a working lab with the same topology and interfaces as the lab exercise.
- Add your planned configuration to the lab.
- Test the configuration using some of the suggestions below.
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:
- Download the CML file (filetype .yaml) linked below.
- Import the lab’s CML file into CML and then start the lab.
- Compare the lab topology and interface IDs to this lab, as they may differ (more detail below).
- Add your planned configuration to the lab.
- 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.Â
- Check the OSPF metrics per the routers from the show ip route command, and compare those values to the values requested in the lab.
- Use the show ip ospf interface command to confirm the OSPF cost of each interface on each router.
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?
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…
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?
Hi Alberto,
The lab is asking you to configure such that the cost of the route, which the routers calculate as the sum of the outgoing costs. The config affects single interfaces’ costs. I think the lab commentary tab explains it from there.
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?
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…
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
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. 🙂
Writing it out is always best 🙂 Thanks again Wendell!
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?
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.
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
Got it. no worries.
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.
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.
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.
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.
Yep. There was a typo in point #5 in the instructions. It’s fixed now – thanks for the heads up.
Wendell
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.”?
Dirk,
Yes indeed! I just changed the lab per your comment. Thanks for the note!
Wendell
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.
Hi Kirill,
Well, from some perspectives, they don’t. the users and the network itself can work just fine if the users of the computers never ping each other.
You state that hosts send data to their default router (true), and into the Internet (true), but they also send packets to other destinations within the corporate network (often to servers.) That might be a more meaningful ping test, rather than pinging between two end-user computers.
However, as a network engineer, you can test the ability of the routers to forward packets by performing ping commands. That’s more the gist of most references. With IP routing, for instance, the routers collectively do NOT simply define routes between the internet-facing router and each end-user subnet. Instead, the routers learn routes to all subnets. So a ping from any end-user host to any other end-user host tests some of the routes on the routers., so it can be useful – but not necessary.
Hope this helps,
Wendell
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.
Sure, Kirill.
I think I may have misunderstood the gist of your original question. In your original question, you contrasted the need for computers to ping (which tests routing) to the fact that one primary traffic flow occurs from an end-user device into the Internet – a flow that does not forward packets to another end-user subnet. So my answer was specific to that context. In your follow-up, you ask three questions, closing with “This is the reason for knowing all routes in a network?”, which to me, was a different question.
So, for that one, routers need to know all routes within a company because the routers will likely need, at some point, to forward packets to hosts in all subnets. Thinking about that question, and that alone, routers normally have routes to all subnets in an enterprise, so that, when a packet in any subnet sends a packet, the collective routers have a route with which to deliver the return packet back to that user.
EG, imagine many end-user subnets in the enterprise, and all that end-users do is connect to servers in the Internet. The packets flowing from the servers in the Internet, to each end-user host, require routes in the enterprise routers that match all those end-user subnets. Those are examples that drive the need for a router to know about all subnets.
In short, the enterprise routers need routes for all subnets that contain hosts that might send packets.
Or it could be that I’m just misunderstanding you.
In response to your second paragraph, I don’t think you “need” Rick’s book to understand IPv6. It’s a great book, but it’s not the only place to learn about IPv6. I’m curious what gave you that idea?
As for the Sim, you’d have to ask the folks at Pearson about that. I don’t have a lot of insight into the product anymore – I’ve been away from it for about. eight years.
Kirill,
Another thought on your question. Consider router B1, at a branch, with subnet B, with hosts in it. B1 has only one WAN link. So, other than its connected routes, all its OSPF-learned routes would refer to the WAN link as the outgoing interface. In that case, you could easily argue that router B1 doesn’t need routes to all subnets, but could instead use a default route. Figure 20-6 in the current Vol 1 book shows that case. Is that more what’s got you thinking about how some routers don’t need all routes, but maybe could get by with less than that?
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
Hi Tewa,
That would be a case in which CPT does not act like real gear… assuming you do see neighbors reachable on those interfaces in the output of show ip ospf neighbor. On a real router, you would see 1/1 out at the far right of the lines for the three WAN interfaces.
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.
Charlie,
The suggested config tab shows the R1 config, but I omitted the relevant R2, R3, and R4 config. My apologies. The lab text does mention what needs to be configured on those three routers (reference-bandwidth 100000), which impacts your question, so your question may stem from not realizing that config is needed. Now it’s obvious with a short answer config section for R2, R3, and R4.
That said, the Lab Commentary tab speaks specifically to your question. As configured, the R1 G0/0/0 interface has a cost of 50, and the R2 G0/0 interface a cost of 100, for a total cost of 150. So, from R1’s perspective, a packet to subnet 172.16.2.0/24, through R2, would exit those two interfaces, cost 50 and 100 respectively, for a total cost of 150.
Take a look at the above, plus the Lab Commentary tab, and follow up if that doesn’t clear it up.
Wendell
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!
Sure thing, Austin. Love it when a plan comes together!! 🙂
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?
Hi Elizabeth,
I’m not sure I’m getting the context. So… Table 1 doesn’t ask you to set costs s.t. R1’s OSPF route to 172.16.1.0/24 will have cost 80. So I’m thinking you’re looking at the answer, seeing cost 80 set on R1’s G0/0, and calculating that OSPF on R1 would calculate an OSPF route for 172.16.1.0/24 w/ cost 80.
But you say that’s a problem, and I’m not seeing why. The lab doesn’t ask you to make R1’s route to 172.16.1.0/24 have any particular cost. Were you actually referring table 1’s direction to create settings s.t. R4’s OSPF route for 172.16.1.0/24 is 180? Feel free to follow up.
Note that whatever OSPF on R1 calculates as the cost of its OSPF route to 172.16.1.0/24, that route is also connected to R1, so R1 will list the connected route is it’s routing table (lower administrative distance), rather than the OSPF learned route.
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?
Hi Kirill,
R2 and R3 could be considered to connect to the same LAN switch in the same VLAN. At L3, they’ll be in the same subnet.
More generally, when a network drawing shows an Ethernet LAN with perpendicular lines like that, it’s meant to represent an Ethernet – but it implies that the particulars of the LAN switches are unimportant. EG, it could be a dozen connected LAN switches, or one, but the devices are in the same VLAN.
W