Timedora

1 Routing Tables and Packet Forwarding

Learn how routers read routing tables, select routes, and forward packets using destination prefixes, next hops, and outgoing interfaces.

What a contains

A router uses its routing information to decide where to send each packet. The forwarding process uses installed routes to select a and outgoing interface.

Routes can come from connected interfaces, administrator-configured static routes, and routing protocols. The is also called the RIB.

Reading route entries

A route usually identifies a destination prefix and how to reach it. In this Cisco IOS-style example, the first character or characters identify the route type:

  • C means connected: the prefix is on an active, configured router interface.

  • S means static: an administrator configured the route.

  • O means the route was learned through . Other routing protocols use their own route codes.

  • S* identifies a static . The 0.0.0.0/0 prefix matches any IPv4 destination that is not matched by a more-specific installed route.

In this Cisco-style display, the first number in brackets is the and the second is the . For example, [1/0] shows an of 1 and a metric of 0, while [110/20] shows an of 110 and a metric of 20. Exact displays and default values depend on the platform.

How routes are selected

Route installation and packet forwarding are separate decisions. When multiple sources offer routes to the same prefix, the router uses route-source preference, often called , to choose which route or routes to install. If routes from the same protocol compete, that protocol’s metric helps rank them. Lower values are preferred in common Cisco implementations, but route preferences and metrics can vary by platform and protocol.

For each packet, the router then selects among the installed routes by finding the . does not make a less-specific route beat a more-specific matching route during forwarding.

For example, if the router has 10.20.0.0/16 and 10.20.2.0/24, a packet addressed to 10.20.2.25 matches both, but the /24 is more specific because it matches more leading bits. A packet addressed to 10.20.3.25 matches the /16 but not the /24, so the /16 is selected.

Trace a packet’s path

For each packet, use its destination IP address to identify the installed route that will be used:

  1. Read the packet’s destination IP address.

  2. Find all installed route prefixes that contain that address.

  3. Choose the matching route with the longest prefix. If no route matches, use an installed ; if there is no matching route or , the router cannot forward the packet.

  4. Follow the selected route’s next-hop and outgoing-interface information.

For a directly connected destination, the router sends the packet out the connected interface toward the destination host. For a remote destination, it sends the packet to the specified next-hop router. The forwarding choice is based on the destination IP address, not on which route has the most attractive-looking metric among all table entries. Before transmission, the router may need to resolve a next-hop address to a link-layer address on the outgoing network.

Worked route selections

Suppose the router has these installed routes:

  • Destination 10.10.1.50 matches the connected /24, so send it directly out G0/0.

  • Destination 10.20.2.25 matches both the static /16 and /24. The /24 is more specific, so send the packet to 192.0.2.6 out G0/1.

  • Destination 10.20.3.25 matches the static /16, but not the /24, so send it to 192.0.2.2.

  • Destination 203.0.113.9 matches none of the listed specific routes, so use the via 192.0.2.2.

Apply the same selection process to these destinations:

  1. 10.10.1.200 — connected /24, out G0/0.

  2. 10.20.2.200 — /24, via 192.0.2.6 out G0/1.

  3. 10.20.8.1 — static /16, via 192.0.2.2.

  4. 198.51.100.20 — , via 192.0.2.2.

Putting the decisions together

Connected routes describe active local networks, static routes are configured by an administrator, and dynamic routes are learned through routing protocols. Route preferences and metrics help determine which competing routes for the same prefix are installed. When forwarding a packet, the router uses the most-specific matching installed route and sends the packet through the indicated interface toward its . If no specific route matches, an installed may provide a path.