A Routing Table is the brain of a router (or any Layer 3 device). It is a database stored in the router's RAM that lists all the network destinations the router knows about, and exactly how to reach them. Without a routing table, a router would receive a packet, not know what to do with it, and immediately drop it.
Before reading this, ensure you understand the basic concept of Routing.
What Does a Routing Table Contain?
While the exact output varies between vendors (Cisco, Juniper, Linux, Windows), every routing table entry generally contains the following pieces of information:
- Destination Network: The remote network (e.g.,
198.51.100.0). - Prefix / Subnet Mask: The size of that network (e.g.,
/24or255.255.255.0). - Next Hop IP: The IP address of the next router in the path to hand the packet to.
- Outgoing Interface: The physical port on the router that the packet should exit (e.g.,
GigabitEthernet0/1oreth0). - Metric / Cost: A numerical value representing how "expensive" or "far" the route is. If the router knows two paths to the same destination, it chooses the one with the lowest metric.
- Route Type: How the router learned this route (e.g., Connected, Static, or Dynamic like OSPF).
Types of Routes
- Directly Connected Routes: These are automatically added to the routing table the moment an administrator assigns an IP address to a router interface and turns the port on. The router inherently knows how to reach networks physically plugged into it.
- Static Routes: Manually configured by an administrator. (See Static vs Dynamic Routing).
- Dynamically Learned Routes: Routes learned automatically from other routers using routing protocols.
- Default Route: The "catch-all" route (
0.0.0.0/0). Used when the router doesn't know a specific path to the destination.
The Longest Prefix Match Rule
A router might have multiple routes in its table that match a single destination IP. The universal rule of routing is: The router always chooses the most specific matching route. This is known as the Longest Prefix Match.
Imagine a router has the following three entries in its table:
0.0.0.0/0(The Default Route, pointing to the Internet via ISP 1)192.0.2.0/24(The main remote branch office network, pointing to a VPN)192.0.2.128/25(A highly secure subnet inside the branch office, pointing to a specific internal firewall)
If the router receives a packet destined for 192.0.2.150, which route does it take?
- It matches Route 1 (0 bits match, everything matches default).
- It matches Route 2 (24 bits match the network).
- It matches Route 3 (25 bits match the network).
The Winner: Route 3. Because /25 is a longer, more specific prefix than /24 or /0, the router sends the packet to the internal firewall.
Viewing the Local Routing Table
Even your PC has a local routing table to determine if traffic should go to the local Wi-Fi or to a VPN adapter.
Windows
Linux
Common Routing Table Troubleshooting
1. Missing Default Route
If your router can reach internal subnets but cannot reach the internet, check the routing table for 0.0.0.0/0. If it is missing, the router drops all internet traffic because it has no path to the web.
2. Incorrect Next Hop
If a route exists but traffic never arrives, the Next Hop IP might be a dead router, or point to an interface that is down. Use Traceroute to see where the packet is actually being sent.
3. Asymmetric Routing
If PC-A pings PC-B, the packet might take Router 1 to get there. However, PC-B's routing table might dictate that the reply should be sent back via Router 2. If Router 2 has a firewall enabled, it might drop the reply because it never saw the initial connection request. A route must be valid in both directions for two-way communication.
4. Route Exists, Destination Unreachable
A routing table only proves the router thinks it has a valid path. If the destination server is turned off, or a firewall blocks the traffic halfway there, the routing table will still look perfect while the connection fails.
Quick Summary
- A routing table dictates exactly where a router sends every packet it receives.
- Entries contain the destination network, next hop, outgoing interface, and metric.
- The router always prefers the most specific route (Longest Prefix Match).
- Local computers also possess routing tables to manage multiple network adapters.