TechKnowSurge
Cisco CCNA 3.1 Cisco CCNA 3.2
VideoNetworkFree

Routing Table

This content covers how routers determine which routes are installed in the routing table and how the best path is selected when multiple options exist for the same destination. Key concepts include administrative distance, routing metrics, longest prefix match, and default route behavior.

Complete this video to capture a CTF flag worth 1 point.

About this video

Routers do not blindly accept every route they learn. Before any route enters the routing table, the router evaluates administrative distance, a numerical value assigned to each routing source that reflects how trustworthy that source is considered to be. Directly connected networks carry an administrative distance of zero, static routes default to one, and dynamic routing protocols occupy a range from EIGRP's summary routes at five up to internal BGP at 200. When the same destination network is advertised by multiple protocols simultaneously — for example, both OSPF at 110 and RIP at 120 — only the route from the protocol with the lower administrative distance is installed. This mechanism ensures that more reliable or administrator-preferred sources take precedence over less favored ones. Once the administrative distance comparison has filtered competing protocol sources, the metric resolves ties among routes learned through the same protocol. OSPF calculates cost based on link bandwidth, meaning a path through gigabit connections will carry a lower cost than one traversing 100 Mbps links, even if both paths involve the same number of hops. RIP, by contrast, uses hop count exclusively, which makes it unable to distinguish between paths with different bandwidth characteristics. The route with the lowest metric for a given protocol and destination is the one that gets installed. EIGRP is a notable exception in that it supports unequal-cost load balancing, but for most protocols, only the lowest-metric route makes it into the table. With routes installed, the router still must decide which entry to use when a packet arrives with a destination address that could match more than one entry. It applies longest prefix match, comparing the destination IP address in binary against all routing table entries and selecting the one whose subnet mask covers the greatest number of matching bits. A more specific entry — say a slash 27 — will always win over a less specific one like a slash 8, regardless of the order entries appear in the table. The default route, represented as 0.0.0.0/0, matches any destination and serves as the last resort when no more specific route exists. If no default route is configured and no entry matches the incoming packet's destination, the router discards the packet entirely.

What you'll learn

What's covered

Routing Table

Aligned to

Cisco CCNA
3.1 Interpret the components of routing table
3.2 Determine how a router makes a forwarding decision by default

Key terms

Router
A network device that forwards data packets between networks based on IP addresses.
Routing Protocol
A protocol used by routers to communicate and share routing information to determine the best path for data.
Active Directory
AD
Microsoft's directory service used to manage users, computers, and resources in a network.
Metric
A value used by a router to determine the preferred path to a destination when multiple routes exist; lower values typically indicate a more preferred route.
Longest Match
A routing lookup method where a router selects the most specific matching route entry in the routing table for a given destination address.
Default Route
A catch-all routing entry represented as 0.0.0.0/0 (IPv4) or ::/0 (IPv6) that a router uses to forward packets when no more specific matching route exists in the routing table. It is typically configured to point toward the next-hop router or ISP connection.

Topics

Networking Routing Table Administrative Distance Routing Metrics Longest Prefix Match Default Route

Transcript

Route Installation

We'll start out with route installation — how your router chooses the right routes to put into the routing table. It could have a lot of different options to get to the same network, so which one does it choose? One of the answers to that is administrative distance. Then, once things are installed onto the routing table, there still could be multiple options to the same networks out there, so we also need to know how it chooses the right option — and what happens if there's no matching route in the routing table at all.

Here's the scenario that we're working with. We have a PC right here with this IP address that's trying to get a web page from this IP address right here. It sends out an initial request and it reaches this router right here, and this router has certain information in it. How does it get that information? Let's say we have a couple of routing protocols that are working, RIP and OSPF, so it is learning of these routes through RIP and OSPF. This router right here reports in with both RIP and OSPF that it has access to the network, so we have a route for each one of these destined for the network that this server is hanging off of. It also gets similar information from this router down here, one from RIP and one from OSPF, so it has to make a determination of which route it's going to choose. Furthermore, we may have a static route that's also entered on here, and let's say the static route points in this direction right here to get to this destination.

So what we need to do is start rendering down all of this information. We now have five routes to get to this final destination. How is this router going to choose, first of all, what gets installed onto the routing table, and second of all, what route it's going to choose if there's multiple routes entered onto the routing table?

Administrative Distance

The first answer to this is administrative distance. Administrative distance is a way to tell this router which one of these protocols is more favorable — which one is going to give a more honest answer to how to get to this network right here. For instance, the static route has an administrative distance of one, and lower is better. An administrative distance of one says that if I've assigned a static route on here, I probably want that static route to be used. If I didn't want that static route to be used — maybe it's a floating route that I only want to use as a backup scenario — I would change the administrative distance to be something much greater than one, something that's greater than RIP or OSPF. So administrative distance is a way to gauge through what protocol it learned of the direction to this server right here, and how reliable that is.

The second thing is going to be the metric. Even though it's learned that maybe OSPF is the preferred method here, it's learning OSPF through this router right here and OSPF through this router right here, and it's going to have the same administrative distance because it's learning both of those through OSPF. That's where the metric comes in. There's going to be a measurement — in OSPF it's a measurement of cost, of how much cost it takes to get in this direction, or how much cost it will be to go from this direction.

If it's a directly connected network, it's going to have an administrative distance of zero. It doesn't need to go through any other routers or any other devices because it's directly attached, and that's going to be the fastest way to get onto that network, so that makes sense. The next one is a static route. With a static route we can actually set the administrative distance as well, so we can specify what the priority of the static route is going to be. If we don't specify it and we just leave it at its default, the default is one.

We also have:

  • an EIGRP summary route, which is at 5
  • external BGP, which is 20
  • internal EIGRP, which is 90
  • OSPF at 110
  • IS-IS at 115
  • RIP at 120
  • internal BGP at 200

Notice that we have EIGRP here as a summary route and we have it as an external route, and they're all different administrative distances. That's because it can learn about EIGRP in a few different ways, and depending on how it learned it, it may favor it or not. So we see a range from 0 to 200. Remember, the lower number is more favorable, so as we work up in this graph, this is more favorable towards the top — this is what we love, up here — and it doesn't favor the ones towards the bottom of this graph.

Here's the output of a show ip route, so this is the routing table we're looking at. As we've seen in prior videos, the O stands for OSPF, and when we take a look at the administrative distance we see 110 on that. We also see that there are several directly connected networks with the C here, and it doesn't specify anything about the administrative distance because the administrative distance is zero on those. We also see static routes here, and they are set to the default of one right there. This router also could be getting the same routes through RIP, but RIP has a higher administrative distance — RIP is at 120 — so it would never get installed on the routing table, because OSPF is the preferred routing protocol. It's going to choose the lower administrative distance routing protocol, and that's OSPF.

Metric

The other thing that affects what routes actually get installed on this routing table is the metric right here. Specifically with OSPF, OSPF has a metric of cost: what is the cost to get to that network? We see 132, 67, 66 to 131, so we see a different cost to get to these different networks. With OSPF we're not going to see different costs actually being installed on the routing table — they're going to get weeded out if it's a higher cost to get there. I believe one of the exceptions to that would be EIGRP, because it can do unequal cost load balancing, but we're not going to get into that too much. Just know that it's using administrative distance and metric to determine what goes into the routing table, and if there are duplicate networks that it can get to, then it's going to choose the one that has the lowest administrative distance and the one that has the lowest metric.

Each of your dynamic routing protocols is going to use a different metric to measure what is the best route to your final destination. If this router is trying to get to this network right here, what it needs to do is determine what is the best route. OSPF uses a metric of cost, versus RIP, which uses a metric of hop count.

Let's take a look at hop count here. Hop count would be: to get to this network right here, if it were to go this direction it would be 1, 2, and then we get into that network; in this direction it would be one, two to get into this network. So it's treating both of these routes as being the same to get to this final destination.

OSPF works a little differently, though. It's based off of cost, and it looks at bandwidth. Let's say it's a hundred Meg connection on both of these sides, and it's a thousand Meg, or one gig, connection on these sides. This would be the better route to go. RIP would report that it's the same no matter which way you go — it will be the same hop count — therefore it's not the best at determining what is the best route. OSPF is actually more accurate, because what it does is it counts into the equation the cost or the bandwidth of each of these links. It sees that this is a slower connection, so the cost is higher for those links; the bandwidth here is higher, so the cost is lower. So then what gets reported into this router right here is that the cost, or metric, to go this direction is actually cheaper than the cost to go this direction, and so this is going to be the route that gets installed onto the routing table.

Longest Match

So far we've talked about administrative distance and metric as a way to determine the best path to get installed on the routing table, and the routes that don't measure up, the routes that are not the best, are not going to get installed on the routing table. Now, when an IP packet comes into your router and the router takes a look at the destination IP address, it could actually still match multiple network statements in here, so it still needs a way to determine which route it's going to use. That's where longest match comes in. It will take a look at what is the longest match within the routing table, so it can send it in that direction.

Let's say an IP packet comes into a router and it's 10.1.10.34. I've also got the binary equivalent of that. In its routing table it has multiple network statements, so here are some of the network statements that exist on there. What I've done is I've created a binary equivalent to all of that, and this quad zero with this slash zero says that nothing really needs to line up. All the red means that nothing really needs to line up to match this statement, to match this route. So if we look at this, well, of course, none of it needs to match, so we're good to go. But do we really want to send it on its default route? Probably not.

This one right here matches up with this right here, so this would actually be a better route to go, because we've got more matching bits — remember, these don't matter. So this would be a better route than the default route would be. We can see that this one actually has more matching bits to it, so that would be even better, and you can see where I'm going with this. Even up to this point right here, this has all matching bits for the /27 that's in here, so even this one would line up and be a good match for this. But the best one is the longest match: what has the most number of bits matching. So we see this one right here, but this /32 means that they all need to match, and we see that this last bit doesn't line up. Since that doesn't line up, we can't use that one. So the longest match out of all of these would be this route right here — this is the one that we would choose.

That's where the default route comes into play. Notice I switched this first bit right here, so I just added a 1 to it, and therefore it doesn't line up with any of these now except for this default route.

No Match in the Routing Table

So what happens if there's no match in here? Notice I changed the first bit — I just added one to it. I've also had to take out the default route, because if we had the default route it would still line up with that. So I took out the default route, and now we don't have any matches. It doesn't match up with any one of these, so it can't use any of these routes. When it doesn't have a route that it can match up against, then it just drops this packet. It doesn't do anything with that packet. So that's what happens if there is no match in the routing table.

We started out by talking about route installation — which routes actually get put on, or installed into, the routing table. Your router uses administrative distance and metric. Administrative distance is a way to determine which are the best, most reliable protocols to use, and then out of those protocols, what is going to be the best route to take. Then, once it puts that into the routing table, there still could be multiple matches, and that's where it can use the longest match to match up the best route. Finally, we ended up talking about what if there were no matches: then we would have to just drop that packet, if there was no default route and there were no other matches.

About TechKnowSurge

TechKnowSurge builds IT and cybersecurity professionals through hands-on, concept-first training built around real understanding — not memorization. Free interactive tools, structured programs, and 25+ years of real-world experience, all in one place.

Explore free tools and programs →