Routing table

On this page 6

A routing table is the data structure in which a router or host stores known destination networks and the next hop or interface used to reach each of them. In routing it is the decision base for IP forwarding: for every packet, the device looks up the destination address in the table and sends the packet toward the most specific matching route.

Every IP-capable device has one, from a laptop with three entries to an Internet backbone router carrying the full global BGP table of roughly one million IPv4 prefixes and over 200,000 IPv6 prefixes. Routes enter the table from directly connected interfaces, manual configuration and dynamic routing protocols such as OSPF and BGP.

What a routing table entry contains

Each entry describes one destination prefix and how to reach it. The exact columns vary by operating system, but the same core fields appear on routers, servers and workstations.

FieldExampleMeaning
Destination prefix10.20.0.0/16The network the route covers
Next hop192.0.2.1Neighbor router that receives the packet
Outgoing interfaceeth1 or GigabitEthernet0/1Port used to send the packet
Route sourceConnected, static, OSPF, BGPHow the route was learned
Administrative distance0 to 255Trust ranking between sources
MetricCost, hop count, path attributesPreference among routes from one source
Fields of a typical routing table entry

A default route, written 0.0.0.0/0 for IPv4 or ::/0 for IPv6, matches every destination. It points to the default gateway and catches all traffic that no more specific entry covers, which is why most hosts need only a few entries.

How the lookup selects a route

Route selection follows the longest prefix match rule: among all entries that contain the destination address, the one with the longest prefix length wins. A packet to 10.20.5.9 therefore uses a 10.20.5.0/24 route rather than 10.20.0.0/16 or the default route.

When several sources offer the same prefix, the router first prefers the source with the lowest administrative distance, and then the route with the best metric within that source. If metrics tie, many routers install several paths and use equal-cost multipath (ECMP) to spread flows across them.

Route sourceTypical distanceInterpretation
Directly connected0Most trusted
Static route1Preferred over dynamic protocols
External BGP20Routes from other autonomous systems
OSPF110Interior link-state routing
RIP120Legacy distance-vector routing
Internal BGP200Routes learned inside the own AS
Common default administrative distances on many routers

These values are vendor defaults and can be changed, for example to create a floating static route with a distance of 250 that takes over only when the dynamic route disappears.

On a router, the routing table is not the only table involved in forwarding. The routing information base (RIB) holds the best routes chosen by the control plane, while the forwarding information base (FIB) is the optimized copy that hardware uses for every packet.

StructureContentsUsed by
Protocol tablesAll routes learned by one protocol, such as the BGP tableProtocol best-path selection
Routing table (RIB)Best route per prefix across all sourcesControl plane
FIBPrefixes with resolved next hops and interfacesData plane forwarding
ARP or neighbor cacheIP-to-MAC mappings for next hopsFrame construction
MAC address tableMAC-to-port mappings on switchesLayer 2 forwarding
Tables involved in IP forwarding

Large routers implement the FIB in TCAM or specialized memory for line-rate lookups. Because that memory is finite, the growth of the global table is a real hardware lifecycle concern for operators of older equipment.

Reading and troubleshooting a routing table

Administrators inspect the table with commands such as ip route on Linux, route print on Windows or show ip route on network operating systems. Most connectivity problems become visible once the actual chosen route for a destination is checked.

SymptomLikely causeCheck or fix
Traffic leaves the wrong interfaceMore specific route overrides intentLook up the exact destination
Destination unreachableNo matching route and no defaultAdd a route or default gateway
Routing loop, TTL expiredTwo routers point at each otherTrace the path, fix static routes
Asymmetric pathsReturn route differs from forward routeAlign policies, check stateful firewalls
VPN breaks Internet accessTunnel installs a default routeUse split tunneling where policy allows
Routing table symptoms and causes

A common pitfall is a static route left behind after a network change; it keeps winning because of its low administrative distance. Documenting static routes and monitoring table changes prevents such silent misrouting.

The simple explanation

A routing table is like a list of road signs stored inside a router. For each destination area, it says which exit to take next.

When data arrives, the router reads the destination, finds the most precise sign that fits and sends the data that way. If no sign matches, it uses a general direction for everything else, much like a sign that says all other destinations.

How it is used in practice

A company connects its head office to a cloud provider through a private link and also has a normal Internet connection. The edge router learns the cloud prefix 172.16.0.0/16 through BGP over the private link, while a default route points to the Internet provider.

When the private link fails, the BGP route disappears and traffic would follow the default route over the Internet, where the cloud addresses are not reachable. The network team adds a floating static route toward a backup VPN tunnel with a distance of 250. The next time the link fails, the routing table switches to the tunnel within seconds, and applications stay reachable without manual action.