In this tutorial, we’ll take a look at routing tables. We’ll go over what they are, and what they’re used for. We’ll also learn how to understand the entries made in routing tables. Routing tables are essential in the routing because they maintain a map of connected networks, which ensures that the process of forwarding packets is as efficient as possible.
Without the presence of routing tables, routers would have no idea how to get packets to their intended destinations. The entire forwarding process would be tedious and time-consuming.
2. What Are Routing Tables?
Before we dive into routing tables, let’s first define routers. A router is a device that acts as a gateway to a network and is also responsible for forwarding packets or messages to destination addresses. In addition, a router determines the best routes for forwarding packets based on the information stored in its routing table:
A routing table is a table or database that stores the location of routers based on their IP addresses. This table acts as an address map to various networks, and is usually stored in the RAM of most routers or forwarding devices. As such, a routing table contains information about various networks, and how to get to them.
We can generate routing tables dynamically or statically. We usually achieve dynamic generation with the help of routing protocols. In contrast, we achieve static generation by manually entering routes into a routing table. With the dynamic generation of entries, the routing protocols share information with different routes on how to get to different networks.
3. Routing Table Entries
Now that we’ve defined routing tables, let’s take a look at the content in routing table entries:
3.1. Components of Routing Table Entries
An entry in a routing table is usually a route to a specific network. The basic components of each entry in the routing table are:
- Destination address: this refers to the IP address of the destination network.
- Subnet mask/Netmask: this refers to the class or range of the destination address. It’s used to map the destination address to the right network.
- Gateway/Next Hop: this refers to the next IP address to which the packet is forwarded.
- Interface: this refers to the outgoing interface that connects to the destination.
- Metric: this assigns a value to each route to ensure that optimal routes are chosen for sending packets. In some instances, the metric is the number of hops or number of routers to be crossed to get to the destination network. If multiple routes exist, the route with the lowest metric is usually chosen.
3.2. A Routing Table Entry Example
Now that we’ve listed the components of a routing table entry, let’s dive into understanding an entry based on an example. We’ll use the routing table given previously.
Looking at the first entry below, suppose PC1 would like to send a packet to PC3 on the destination at 18.104.22.168. However, PC3 is not on PC1’s network, so PC1 forwards this packet to Router A. Upon arrival at Router A, the router checks its routing table for a path to destination 22.214.171.124:
Since a path exists, the packet will be forwarded to the gateway at 10.0.0.2 through interface eth3 on Router A.
Now let’s consider the second entry. Suppose a user on PC1 wants to send a packet to PC25 on the network 126.96.36.199. Router A will check its routing table for an entry to the address on which PC25 is located. Since there is no recorded entry, Router A forwards this packet to the default gateway at 10.0.0.1 through the interface eth0 to other networks connected to it:
The default gateway route is always present in any routing table. It’s used when there is no entry for a specific network on the routing table. The default gateway usually connects to other remote networks. For example, in a home environment, the default gateway is connected to the Internet.
In the third and final entry, just like the first entry, a packet addressed to destination 188.8.131.52 will be forwarded to the gateway at 10.0.0.3 through interface eth5:
3.3. Types of Routing Table Routes
Additionally, it’s important to note that some routing entries also capture information on the type of route present. In routing, several types of routes exist. For instance, a route can be one of the following:
- Directly connected route: refers to a route to a network that is directly connected to a router’s interface
- Remote routes: refers to a route to a remote network usually learned dynamically through routing protocols
This article has provided an overview of understanding the entries in routing tables. First, we defined routers, and then routing tables. We discussed how routing tables are generated, and where they’re stored. We also explained the components of routing table entries and gave examples of how to decipher these entries. Finally, we looked at the types of routes that are usually recorded in routing tables.