My last Daily Drill Down, “IP routing in 40 short steps,” described how a packet is sent from an originating host on one network over to another host on a different network through an internetwork, as well as exactly what happens to those packets during that process. This Daily Drill Down is going to take things a step further and focus on both IP routing and how routers use a routing table to accomplish the task of forwarding those packets properly throughout an internetwork.
There are three different ways a routing table is built:
- · Statically
- · By default
- · Dynamically
I'm going to talk about the first two—static and default routing tables that are built by network administrators.
A little review
But first, a little review...Remember that an internetwork is defined as two or more networks connected with a router or routers. Also recall that routers don't keep track of, or care even the slightest bit about, hosts, but they are extremely concerned about networks and the best path to access each one.
Logical addressing (IP, for example) is what's used to identify each host on the internetwork. Routers read the network portion of an IP address to figure out where in the Net world a host is and then use a routing table to determine the best path to the network that the destination host is located on.
Once that network is located, the packet is sent to the destination network by forwarding the packet, hop-to-hop, until it reaches the specific router that's directly connected to the destination host's network. From there, the destination host's unique hardware address is used to get the packet to the host that's supposed to receive it.
It's all about maps
Routers have maps, or at least a form of them. They must have a map of the entire internetwork to explain to them where each logical network is located, as well as to guide their decision in choosing the quickest, most efficient way to get there. This map is called a routing table, and each routed protocol you use has to have its own map. For instance, if you're running IP, IPX, and AppleTalk on your network, each of your routers will have three maps—one for each routing protocol—all describing the same physical networks in a different way.
It's kind of a language barrier thing; the reason each protocol has separate routing tables is because each protocol really is like a different language. Say you've built a gated community, and in it, you have a street you named Cat Street. Everyone on that block speaks English, and the street sign is in English. Then a Spanish family moves in that doesn't speak any English, so you add a sign that reads Avenida Gato. Next, a French family moves in—they don't speak English or Spanish—so you add Le Chat to the sign. You now have three separate signs describing Cat Street in three different ways.
Take a look at Figure A, which has two 2500 routers connected with a serial link.
|Each router must have all three networks in the routing table in order to send packets through the internetwork.|
By default, each router will have the directly connected networks in its routing table. Before we take a look at the routing tables, let's view the configuration used on each router.
Here's the basic configuration for the 2500A router.
Here's the basic configuration for the 2500B router.
The 2500B router had the DCE end of the serial link, so the clock rate command needed to be added. We should now have two networks in each routing table. Let's view each table with the show ip route command (or the short form: sh ip route). Here's the 2500A router.
And here's the 2500B router.
The 2500A router is directly connected to subnets 32 and 64. The 2500A must have a route entered for the 96 subnet. The 2500B router is directly connected to the 64 and 96 subnets. The 2500B router must have an entry for the 32 subnet.
Configuring static routes
Static routes are routes configured and entered into the routing table by the administrator. Typically, in larger networks, creating nothing but static routes would be a gruesome task (if not impossible), so dynamic routing is usually used (examples are RIP and OSPF). However, in smaller networks, static routing can work well; it saves overhead on the router CPU and bandwidth on the serial links that dynamic routing protocols greedily consume as fast as my golden retriever will steal and swallow an unattended turkey sandwich!
To configure a static route, use the global configuration command ip route. Since the 2500A router must understand how to get to the 96 subnet, let's configure a static route that describes to the router what to do when it receives a packet with a destination IP network of 192.168.10.96.
The ip route command is broken down as follows:
- · ip route: The command issued to add a route to a routing table
- · 192.168.10.96: The destination network
- · 255.255.255.224: The subnet mask used on the network
- · 192.168.10.66: Where to send a packet with a destination IP network of 192.168.10.96
Notice that the IP routing table now has an entry for the 192.168.10.96 subnet via 192.168.10.66, which is the next hop gateway from the 2500A router.
This is working great; we're halfway to finishing our routing tables. The reason we're only half done is that the 2500B router still doesn't know how to send packets to the 32 subnet. If a packet is sent from HostA on the 32 subnet over to HostB on the 96 subnet, it'll definitely get to HostB, and HostB will respond by sending a new packet back to the configured default gateway. The problem is that 2500B will discard the packet since it doesn't know how to get to the 32 subnet. So, let's configure 2500B with a route to network 192.168.10.32.
The ip route command is broken down as follows:
- · ip route: The command used to add a static route
- · 192.168.10.32: The destination route we want router 2500B to know about
- · 255.255.255.224: The mask used in the network
- · 192.168.10.65: The next hop router used to get to subnet 32
The routing table for the 2500B router now knows how to get to subnet 32 and packets can be sent from HostA to HostB and back again.
Configuring default routing
Since we have an Internet connection off the 2500B serial 0 interface, we need to add a default route to the routing table of the 2500B router. This is just like adding a static route, except wildcards of all zeros (0s) are used instead of a network and mask.
Here is an example of configuring the serial 1 interface on the 2500B router and then setting up default route. The ISP provided an IP address of 188.8.131.52/30 for the interface. Since /30 is a block size of 4, the valid hosts are 65 and 66. We can set our next hop to 66 since we were given 65 for our router’s interface.
The default route command is broken down as follows:
- · ip route: The command used to add a static or default route
- · 0.0.0.0: The wildcard used to say “any” network not already in the routing table
- · 0.0.0.0: Wildcard mask to say “any” network mask
- · 184.108.40.206: Next hop gateway
If you don't know the next hop gateway for some reason, you can always create the command like this:
ip route 0.0.0.0 0.0.0.0 s1
This will tell the router to send packets that aren't in the routing table out serial 1. Also, notice that I used the ip classless command. This tells the route not to drop packets that are destined for a network that's not in the routing table, but to use the default route instead. If you don't use the ip classless command, packets like that would be dropped before being sent to the default route. (ip classless is on by default in IOS 12.x.)
Okay, so the routing table on the 2500B router now looks like this.
The S* is a static default route. Notice also that the gateway of last resort is now set as well. Since a router cannot set a default gateway and since it actually is the default gateway for a network, routers use a gateway of last resort instead, which is really a default route.
A couple of tips
- · Routers need current, up-to-date “maps.” If a routing table doesn't have a route to each network that it's going to be required to send packets to, then packets will be dropped.
- · Troubleshooting a routing table problem is tough. But by using the ping program and Traceroute command, you can find exactly where a packet is failing in an internetwork. Each of these commands will be discussed in future articles.
By now it should be pretty clear both why it's important to understand how a routing table is used in an internetwork and how important it is to be able to read a routing table and understand the output. There are many tools that can help you understand this concept, but the best tool is experience. Use the tools I’ve shown you, and eventually, you’ll be whipping up routing tables faster than you can say “cat” in three different languages.