A routing table is a data structure, essentially a digital map, stored inside a router or any Layer 3 device. It holds the information necessary to make forwarding decisions. For every packet it receives, the router consults this table to determine the best path to send the packet toward its final destination IP address.
Without a routing table, a router would be useless; it would have no idea where to send any data that wasn't for its own local networks.
- The Two Tables: RIB vs FIB
- Anatomy of a Route Entry
- How Routes Get in the Table (Route Sources)
- How a Router Chooses the Best Route
- Reading a Routing Table (Examples)
- Further Reading
The term routing table is often used generally, but in modern, high-performance routers, this “map” is actually split into two distinct tables that live on different planes of the router.
- Plane: Control Plane (the "brain")
- What it is: The master database of all routes. It’s the map library that holds every possible route the router has learned from all sources (static configuration, OSPF, BGP, etc.).
- Purpose: To aggregate all routing information, apply policies, and use criteria (like Administrative Distance and Metric) to select the single best route for every known destination network.
- Plane: Data Plane (the "workhorse," often in hardware/ASICs)
- What it is: The “shipping list” or “cheat sheet.” It contains only the single best, active route for every destination, copied directly from the RIB.
- Purpose: High-speed forwarding. When a packet arrives, the data plane hardware only looks at this simple, optimized table to make a forwarding decision instantly.
Analogy: The RIB is like Google Maps with all possible routes and modes. The FIB is the simplified turn-by-turn directions you follow while driving.
Each line in a routing table is an entry that contains several key pieces of information used for forwarding decisions.
A router’s RIB is populated from four main sources, listed from most trusted to least trusted.
- What they are: Networks physically attached to the router.
- Creation: Automatic when an interface is assigned an IP address (e.g.,
192.168.1.1/24). - Trust: Most trusted routes (Administrative Distance = 0).
- What they are: Routes manually configured by an administrator.
- Example:
ip route 10.0.0.0 255.255.255.0 192.168.1.2 - Trust: High (AD = 1). Simple and secure but do not adapt automatically to changes.
- What they are: Routes learned automatically from routing protocols like OSPF, EIGRP, RIP, or BGP.
- Purpose: Enable routers to share and adapt routes dynamically.
- Typical AD Values:
- OSPF: 110
- EIGRP: 90
- RIP: 120
- BGP: 20 (external) / 200 (internal)
- What it is: A special static route that matches all destinations (
0.0.0.0/0). - Example:
ip route 0.0.0.0 0.0.0.0 192.168.1.1 - Purpose: Used when no other route matches; crucial for edge routers connected to the Internet.
Routers use a two-step process for choosing and applying routes.
When a packet arrives, the router’s data plane checks its FIB using the Longest Prefix Match (LPM) rule.
The most specific route always wins.
Example Scenario:
A packet for 192.168.1.50 arrives. The router has:
192.168.0.0/16
192.168.1.0/24
0.0.0.0/0
Decision: All match, but /24 is the longest prefix → it’s chosen.
If multiple routes to the same destination exist in the RIB, the router uses tie-breakers.
- Chooses the route from the most trusted source (lowest AD).
Example:
Static route (AD = 1) vs. OSPF (AD = 110) → Static wins.
- If the ADs are equal, choose the route with the lowest metric.
Example:
Two OSPF routes: one with Metric 20 and one with 50 → Metric 20 wins.
Router> show ip route
O 10.1.1.0/24 [110/2] via 10.1.1.2, 00:05:30, GigabitEthernet0/1
Breakdown:
O→ Learned via OSPF10.1.1.0/24→ Destination network[110/2]→ Administrative Distance = 110, Metric = 2via 10.1.1.2→ Next hopGigabitEthernet0/1→ Exit interface
$ ip route show
default via 192.168.1.1 dev eth0
10.1.1.0/24 via 10.1.1.2 dev eth0
192.168.1.0/24 dev eth0 proto kernel scope link src 192.168.1.10Interpretation:
default→ Route of last resortvia→ Next-hop addressdev→ Outgoing interface