Timedora

1 Routing Tables and Route Selection

Learn how to read routing-table entries, how routers install preferred routes for each prefix, and how longest-prefix matching determines packet forwarding.

Purpose of a

A router’s records destination networks it can reach and information used to forward packets toward them. When a packet arrives, the router examines its destination IP address, finds matching routes, and chooses the most specific usable route.

Reading route entries

A route entry commonly identifies how the route was learned, the destination network and prefix length, values used to compare candidate routes, and the forwarding path. It may also show how long ago the route was learned or updated.

A Cisco-style entry might look like this:

In this entry, O indicates an OSPF route, and 10.20.0.0/16 is the . [110/20] gives the and route , in that order. The is 192.0.2.2, and GigabitEthernet0/0 is the outgoing interface. Route codes and display formats differ among vendors, so consult the device documentation when interpreting unfamiliar output.

A describes a network attached directly to an active interface. A is a fallback that can match any destination when no more specific route applies. Its IPv4 form is 0.0.0.0/0, and its IPv6 form is ::/0.

How routers select routes

Route selection has two related stages. First, a routing source may compare its candidate paths using its protocol-specific . If routes for the same prefix come from different sources, the router may compare their route preference, called on Cisco platforms. A lower is preferred there. For example, Cisco’s default is 1 for static routes and 110 for OSPF routes. These values are platform-specific, not universal rankings.

Second, the router forwards each packet using . Among installed routes that match the destination, it chooses the route with the longest prefix, which covers the smallest address range.

and a protocol’s do not make the packet-by-packet longest-prefix decision. They help determine which route to install for a given prefix; longest-prefix matching then selects among installed routes that match the packet’s destination.

Applying longest-prefix matching

Suppose a contains these routes:

  • 10.0.0.0/8 via Router A

  • 10.1.0.0/16 via Router B

  • 10.1.2.0/24 via Router C

  • 0.0.0.0/0 via Router D

A packet destined for 10.1.2.99 matches all four entries, so the router uses 10.1.2.0/24, the longest matching prefix. A packet destined for 10.1.8.99 matches 10.0.0.0/8, 10.1.0.0/16, and the , so it uses 10.1.0.0/16.

A packet for 192.0.2.15 matches none of the specific prefixes, so the router uses the . If no route matches and there is no applicable , the router cannot forward the packet and discards it.