A routing table is one of the most important elements inside a router. In this lesson you will learn how it works, what it contains, and why it is essential for packet forwarding.
1. Introduction to Routing Table
When your router receives a packet for a remote network, it has to decide which path the packet should take. Without a routing table, your router doesn’t know where to send it, and the packet cannot reach its destination.
Figure 1 – Packet entering R1, routing table needed for decision
To solve this problem, every router is equipped with a routing table. This table is essential because it tells your router which path a packet should take to reach its destination. The process of choosing this path is called a routing decision, and it gives your router the ability to forward packets instead of staying blocked.
Answer the question below
2. What is a Routing Table?
Each router has its own routing table. In this table, your router lists the IP networks (Layer 3) it knows and the paths packets should follow to reach them. (See also our OSI Model lesson for a reminder of the layers.)
Figure 2 – Router must use its routing table to forward the packet
You can think of it like road signs on a highway. Just like signs guide you to the right exit to reach your destination, the routing table guides packets step by step until they arrive where they need to go.
Answer the question below
What does a router use to know reachable networks?
3. How Does a Router Learn Routes?
Routers can learn routes in different ways:
Connected routes: these are created automatically when one of the router’s interfaces is up and has an IP address.
Static routes: these are added manually by the administrator.
Dynamic routes: these are learned from other routers using routing protocols like OSPF, RIP, or EIGRP.
Default route: this is a special route used when no other entry matches, usually pointing to the Internet.
Figure 3 – A routing table can include connected, static, dynamic, and default routes
Sometimes the same network is learned from more than one source. In that case, your router will choose only one route to keep in its routing table.
Answer the question below
Which special route is used when no entry matches?
4. Structure of a Routing Table Entry
Once your router has learned routes, it stores them in the routing table. On Cisco IOS, you can use the command show ip route
to display the table.
Figure 4 – Example of connected, static, dynamic, and default routes in Cisco IOS
At the top of the output, you’ll see a legend with codes. These codes tell you how each route was learned. For CCNA, you mainly need to focus on the following:
Code | Type of Route | Example | Meaning |
---|---|---|---|
C (orange) | Connected route | 192.168.1.0/24 is directly connected, GigabitEthernet0/0 | Your router knows this network because one of its interfaces belongs to it. |
S (blue) | Static route | 192.168.20.0/24 [1/0] via 10.0.0.254 | This route was configured manually by the administrator. |
O (green) | OSPF route | 192.168.3.0/24 [110/2] via 10.0.0.2, GigabitEthernet0/1 | This network was learned dynamically using the OSPF protocol. |
S* (red) | Default route | 0.0.0.0/0 [1/0] via 195.238.2.22 | This is the route your router uses when no other entry matches, usually to reach the Internet. |
Table 1 – Route Codes in Cisco IOS
When you look at the routing table, each line corresponds to a destination network, with a code that shows you where the route comes from.
Breakdown of a Routing Table Entry
Each line in the routing table tells your router exactly how to forward packets. Let’s take the example highlighted in Figure 5.
Figure 5 – Breakdown of a routing table entry in Cisco IOS
Field | Example | Meaning |
---|---|---|
Code (O) | OSPF | Shows how the route was learned. Here, it was discovered dynamically with OSPF. |
Destination | 192.168.3.0/24 | The network your router knows how to reach. |
[110] | The trust level of this route. Lower values are preferred. | |
Metric | [2] | The cost of the route, calculated by the routing protocol (OSPF in this case). |
Next Hop | 10.0.0.2 | The IP address of the next router to forward the packet to. |
Outgoing Interface | GigabitEthernet0/1 | The local interface your router uses to send the packet toward the next hop. |
At first, this format might look a bit detailed. Don’t worry, in the next section we’ll follow a real packet step by step so you can see exactly how the routing table guides it to its destination.
Answer the question below
Which IOS command displays the routing table?
5. How Routers Decide Where to Send Packets
When your router receives a packet, it has to decide what to do with it. This process is called a routing decision, and it always starts with one question: What is the destination IP address?
Step 1 – Identify the destination IP
Your router inspects the packet header and extracts the destination IP address. This is the key information it compares against the routing table.
Figure 6 – Router must check its routing table to make a forwarding decision
Step 2 – Compare with the routing table
Next, your router checks its routing table to see if one of the routes includes this destination IP. In practice, it verifies whether the IP falls within the range of a known network.
In our example, the packet is addressed to 192.168.3.1
. Your router looks at its table and finds that this IP belongs to the network 192.168.3.0/24
.
Figure 7 – Router looks up its routing table to find the OSPF route
Step 3 – Select the matching route
The routing table entry for 192.168.3.0/24
was learned dynamically through OSPF. This entry tells your router that traffic for this network should be sent to the next hop 10.0.0.2 using the outgoing interface GigabitEthernet0/1
.
Figure 8 – Router forwards the packet out G0/1 to the next hop 10.0.0.2
This gives your router both the destination (the next hop) and the way to reach it (the outgoing interface).
Step 4 – Forward the packet
Once the best route is identified, your router forwards the packet out of the correct interface. In our example, the packet exits through G0/1 and is sent to the next hop 10.0.0.2
.
What if no route exists?
You might be wondering what happens if a packet arrives and your router has no route for its destination.
Figure 9 – Packet dropped when no matching route and no default route exists
In this situation, your router first checks if a default route (0.0.0.0/0) is configured.
If the default route exists, the packet is forwarded there.
If no default route is set, your router has no path to follow and drops the packet.
Answer the question below
Which packet field does the router check first?
6. Conclusion
The routing table is at the heart of every routing decision. Without it, your router cannot forward packets, and communication between networks would be impossible.
By now, you understand:
how a routing table is built,
the different types of routes it can contain,
and how your router uses it to decide where to send packets.
This knowledge is essential for the CCNA exam, but even more importantly, it will help you when troubleshooting real networks.
Now that you know how routing decisions work, what do you think will happen if both a static route and an OSPF route point to the same destination? We’ll answer this in the next lesson on Administrative Distance.
Answer the question below