Routing Fundamentals


Routing Fundamentals

Simon
Welcome! Today we’re building a foundation for understanding routing, a key topic for the CCNA and networking in general. We’ll look at what routing is, how to read a Cisco router’s routing table, what connected and local routes do, and how a router chooses between routes that could match the same packet.

Corey
Let’s begin with the basic comparison. A switch uses a MAC address table to help forward Ethernet frames. A router uses a routing table to help forward IP packets, and its entries describe known destination networks or addresses.

Simon
Exactly. Routing is the process routers use to determine the path IP packets should take across a network to reach their destination. When a router receives a packet, it checks the routing table for the best route to use.

Corey
And a route is essentially an instruction. It can say, “To reach destinations in this network, send the packet to this next hop,” where the next hop is the next router along the path.

Simon
There are two other possibilities worth keeping in mind. If the destination is directly connected to the router, the router can send the packet directly to that destination. And if the destination is the router’s own IP address, the router receives the packet for itself rather than forwarding it.

Corey
Routes can be learned in different ways. With dynamic routing, protocols such as OSPF allow routers to share routing information automatically and build their routing tables. With static routing, a network engineer or administrator manually configures routes.

Simon
Today, though, we’re focusing on connected and local routes. They’re not dynamic or static routes: they’re added automatically when an IP address is configured on an interface and that interface is enabled.

Corey
To make the examples concrete, picture four routers, R1 through R4, connected across a WAN—a wide area network that can span a large geographical area, even different cities or countries. R1 and R4 each also connect to a LAN, or local area network. Each LAN could represent an office with many hosts, even though the diagram shows just one PC.

Simon
The example uses an orderly addressing scheme: the router number matches the last octet of its interface addresses. That makes the lab easier to follow, but you shouldn’t expect that exact pattern in real networks.

Corey
Here are the addresses. R1’s LAN is 192.168.1.0/24, with R1 G0/2 at 192.168.1.1 and PC1 at 192.168.1.10. The R1-to-R2 WAN is 192.168.12.0/24: R1 G0/1 is .1 and R2 G0/0 is .2.

Simon
The R1-to-R3 WAN is 192.168.13.0/24, with R1 G0/0 at .1 and R3 G0/0 at .3. The R2-to-R4 link is 192.168.24.0/24, with R2 G0/1 at .2 and R4 G0/0 at .4.

Corey
And the R3-to-R4 WAN is 192.168.34.0/24, with R3 G0/1 at .3 and R4 G0/1 at .4. Finally, R4’s LAN is 192.168.4.0/24, with R4 G0/2 at .4 and PC4 at .10. In the next lesson, static routes will be used to let PC1 and PC4 communicate.

Simon
For this lesson, we’ll concentrate on R1. Once its interface addresses are configured and the interfaces are enabled with no shutdown, the command show ip interface brief can confirm the interface IPs and their status.

Corey
One small command-line detail: while you’re in interface configuration mode, you can enter another interface command directly, such as interface G0/1. You don’t have to exit back to global configuration mode first.

Simon
To see the routing table, use show ip route. The output includes a codes legend near the top and the actual routes below. The legend helps decode the letters beside each route.

Corey
Two codes are central here. C means connected: the route leads to the network attached to an interface, using that interface’s configured network mask. L means local: the route is for the exact IP address assigned to an interface.

Simon
So, if an enabled interface has an IP address configured, it normally contributes two routes: one C route to its network and one L route to its own address. R1 has three configured interfaces in this example, so it has three connected routes and three local routes—even before static or dynamic routes are added.

Corey
Take R1 G0/2, configured as 192.168.1.1/24. A /24 means the first 24 bits—the first three octets—identify the network, while the last eight bits are the host portion. Set those host bits to zero and you get the connected network, 192.168.1.0/24.

Simon
That connected route covers addresses in the 192.168.1.0 through 192.168.1.255 range. In the routing table, it says that network is directly connected through GigabitEthernet0/2, so R1 knows which interface to use for destinations in that network.

Corey
For example, 192.168.1.2, 192.168.1.7, and 192.168.1.89 all belong to 192.168.1.0/24, so that route matches those destinations. But 192.168.2.1 does not begin with the same first three octets, so this route doesn’t match it.

Simon
That gives us an important term: a route matches a packet when the packet’s destination IP address is part of the network or address specified by that route. If a particular route doesn’t match, the router has to look for another route that does.

Corey
Now compare the local route for that interface: 192.168.1.1/32. A /32 fixes all 32 bits, so it identifies one exact IP address. Its mask is 255.255.255.255, and it matches 192.168.1.1—but not 192.168.1.2 or any other address.

Simon
That local route tells R1 that a packet addressed to 192.168.1.1 is for R1 itself. The router should receive it, not send it out of G0/2 toward another host.

Corey
Now for route selection. Suppose a packet arrives with destination 192.168.1.1. Both the connected route 192.168.1.0/24 and the local route 192.168.1.1/32 match. Which one should R1 use?

Simon
It chooses the most specific matching route. The /24 route covers 256 addresses, while the /32 route describes just one. Since /32 has the longer prefix length and matches a smaller, more specific range, R1 selects it and keeps the packet for itself.

Corey
The full rule is: select the matching route with the longest prefix length. Both parts matter—a route must match the destination first, and then its prefix length must be compared with the other matching routes.

Simon
You may also notice lines in show ip route saying that a network is variably subnetted, with a number of subnets and masks. Those lines are not routes themselves. In this example, the message reflects multiple entries associated with that network using different masks, such as /24 and /32.

Corey
The detailed meaning depends on understanding subnetting, which is covered separately. For now, the practical point is not to mistake those summary lines for routes: focus on the actual entries marked C, L, or another route code.

Simon
Let’s practice. First, a packet arrives at R1 with destination 192.168.1.1. The /24 connected route and the /32 local route both match, but the /32 is more specific. R1 receives the packet for itself.

Corey
Next, the destination is 192.168.13.3. R1’s connected route for 192.168.13.0/24 is the matching route, so R1 sends the packet toward the destination through G0/0.

Simon
What about 192.168.1.244? That address matches the connected route to 192.168.1.0/24, and there isn’t a more specific matching route in the example. R1 uses that route and sends the packet out of G0/2.

Corey
For 192.168.12.1, the local route 192.168.12.1/32 matches. Even though the address is also within the connected 192.168.12.0/24 network, the /32 is more specific, so R1 receives the packet for itself.

Simon
Now try 192.168.4.10. In the routing table we’re considering, R1 has no route that matches that destination, so it drops the packet.

Corey
That’s a useful contrast with switching. A switch can flood a frame when it doesn’t know the destination MAC address; that’s called an unknown-unicast frame. A router does not flood an IP packet when it has no matching route—it drops it.

Simon
And the way the two devices look up destinations is different, too. A switch looks for an exact destination MAC address entry in its MAC address table. A router checks which routes match the destination IP, then uses the most specific matching one.

Corey
Let’s pull the essentials together. A routing table is a set of instructions about known destinations. A connected route, marked C, points to the network attached to an enabled interface; a local route, marked L, identifies the exact interface IP with a /32 prefix.

Simon
If the packet matches multiple routes, choose the matching route with the longest prefix. That’s why a /32 local route wins over a /24 connected route for the router’s own address. If no route matches, the router drops the packet rather than flooding it.

Corey
And remember the two automatic entries: when you configure an IP address on an interface and enable it, the routing table gains a route to the connected network and a local route to the configured IP. If the interface is shut down, those routes won’t appear.

Simon
Here’s a quick check. When you configure an IP address on an enabled router interface, what kind of route represents that exact IP? It’s a local route, marked L; the connected route represents the network instead.

Corey
Another check: if R1 has a local route to 192.168.3.25/32 and receives a packet for 192.168.3.25, it receives the packet for itself. The address is specifically identified as one of the router’s own interface addresses.

Simon
And if a packet to 10.0.1.23 matches both 10.0.1.0/24 and 10.0.1.23/32, there are two matching routes. The /32 local route is the most specific, so the router receives the packet for itself.

Corey
That covers the foundation: what routing does, how connected and local routes appear in the table, how to determine whether a route matches, and how longest-prefix selection works. Next, we can build on it by looking at static routes and how next hops guide packets through a network.

Ask anything
We've read this whole study set, so questions about it get the best answers.