Skip to main content
networking

Routing Table

A routing table is a data structure in a router or host that maps destination network prefixes to next-hop addresses and interfaces. Longest prefix match determines which route applies. Routes come from static configuration, DHCP (default route), or dynamic protocols (BGP, OSPF). An empty routing table means no connectivity.

Definition

The routing table stores network reachability information: which destination prefixes can be reached via which next-hop routers and interfaces. When a packet arrives, the router performs longest prefix match – the most specific matching route wins. A route to 10.1.2.0/24 is preferred over 10.1.0.0/16 for destination 10.1.2.5. Routes have metrics (cost/preference) to choose between multiple paths. Static routes are manually configured and do not adapt to failures. Dynamic routing protocols (OSPF for intra-AS, BGP for inter-AS) populate routes automatically and converge around link failures. The default route (0.0.0.0/0) matches everything – it is used when no more specific route exists. Linux maintains multiple routing tables (main, local, custom) selected by policy routing rules.

Examples

  • ip route show table main lists all routes
  • ip route add 10.0.0.0/8 via 192.168.1.1 metric 100
  • ip rule add from 10.1.0.0/16 table 100 (policy routing)

Related Protocols

Related Terms