Routing table

A routing table contains routes that describe how destinations can be reached. Entries associate destination prefixes with forwarding information such as a next hop, an outgoing interface, or an action to reject traffic.

What a route describes

A route typically includes a destination prefix and how to handle matching traffic. Forwarding entries can identify an outgoing interface and a next-hop address. Other route types can deliver locally, reject traffic or discard it. Routers and ordinary end hosts both use routing information.

Routing protocols and configuration populate routing information; the forwarding lookup uses the installed result. A routing information base (RIB) and a forwarding information base (FIB) are related concepts, but they are not necessarily the same data structure or contain identical candidate routes.

Longest-prefix-match example

Consider these illustrative IPv4 routes:

192.0.2.0/24      directly connected on eth0
198.51.100.0/24   via 192.0.2.2 on eth0
0.0.0.0/0        via 192.0.2.1 on eth0

For destination 198.51.100.25, the /24 route matches more specifically than /0, so the next hop is 192.0.2.2. For 203.0.113.8, only the default route matches, so the next hop is 192.0.2.1. A destination inside 192.0.2.0/24 is normally reached directly on eth0.

Within a selected table, destination lookup prefers the most-specific matching prefix. Metrics and protocol preferences help choose among candidates under the platform's rules; a default route with a low metric does not automatically beat a matching /24.

Inspect the actual decision

These Linux commands are read-only:

ip -4 route show table main
ip -4 rule show
ip -4 route get 198.51.100.25

The main table is not always the whole story. Policy rules, VRFs, namespaces and source-address selection can change which table and route apply. A destination lookup is often more useful than assuming that one displayed table describes every packet.

Common confusions

An ARP or neighbor table maps next-hop addresses to link-layer neighbors; a routing table chooses where traffic should go. A selected route also does not prove end-to-end connectivity: neighbor resolution, filtering, forwarding configuration and a return path still matter. With no usable matching route, the system cannot simply forward the packet using an unrelated route.

References

Explore networking learning paths