VMware ESXi and vSphere Cluster Management

Routing Tables Explained: How Routers Choose Where to Forward Packets

Learn how IPv4 routers use connected, static, dynamic, and default routes to select forwarding paths with longest-prefix matching.

A routing table is a device's local list of known IP destination networks and the instructions used to forward packets toward them. Routers consult this table whenever they receive an IP packet that must be sent onward.

This lesson focuses on IPv4 routing tables, including connected, static, dynamic, and default routes. It assumes you understand IPv4 addresses, subnet masks, CIDR notation, basic subnetting, router interfaces, and default gateways.

What a Routing Table Does

When a router receives an IP packet, it reads the packet's destination IP address. This is the address of the intended receiving host. The router compares that address with destination prefixes in its routing table.

The matching route provides a forwarding instruction. It can identify:

  • The outgoing interface through which the packet should leave.
  • A next hop, meaning the neighboring router to which the packet should be sent.
  • Both a next-hop address and an outgoing interface.

Routing information is local to each device. Two routers connected to the same topology can have different routing tables because they may have different interfaces, configured routes, learned routes, or routing policies. Active routing information is normally held in the device's memory while it is operating.

From Host to Router: The Forwarding Process

Suppose Host A needs to communicate with Host B, but the hosts are in different IPv4 subnets.

  1. Host A compares Host B's destination IP address with Host A's own address and subnet mask.
  2. Host A determines that Host B is outside its local subnet.
  3. Because Host B is off-subnet, Host A sends the frame to its configured default gateway, usually a router interface on Host A's local network.
  4. The router receives the frame, extracts and processes the IP packet, and reads the packet's destination IP address.
  5. The router searches its routing table for a route matching that destination address.
  6. The selected route identifies the next hop, outgoing interface, or both.
  7. The router forwards the packet through the selected interface toward Host B's network.

The host does not normally send an off-subnet frame directly to the remote host. The remote host is not on the local Layer 2 network, so Host A cannot deliver the frame directly to it. Instead, Host A delivers the frame locally to the default gateway, which begins the routed journey.

If the router has no suitable route and no usable default route, it cannot forward the packet. Depending on configuration and policy, it may discard the packet and generate an ICMP destination-unreachable message.

Two-subnet example

Imagine the following topology:

  • Host A: 192.168.10.10/24
  • Router interface toward Host A: 192.168.10.1/24
  • Router interface toward Host B: 10.0.0.1/8
  • Host B: 10.20.5.25/8
  • Host A's default gateway: 192.168.10.1

Host A sees that 10.20.5.25 is not in 192.168.10.0/24, so it sends the packet to 192.168.10.1. The router then finds a route for the 10.0.0.0/8 network and sends the packet through the interface connected to that network.

Anatomy of a Routing Table Entry

A route is a forwarding record for a destination prefix. Its exact display format depends on the operating system, but the important concepts are consistent.

FieldMeaningExample
Route source/codeHow the route was learned or installed.C for connected
Destination prefixThe network or address range to which the route applies.10.0.0.0
Subnet mask or CIDR lengthDefines the size of the destination range./8 or 255.0.0.0
Next-hop addressThe neighboring router used for the next forwarding step when applicable.192.168.1.2
Outgoing interfaceThe local interface used to transmit the packet.FastEthernet0/1
Administrative distanceA route-source preference used by Cisco platforms when competing routes exist for the same prefix.110
MetricA path value used by a routing protocol to compare routes learned by that same protocol.2

A displayed route might include values such as [110/2]. The first value is commonly the administrative distance, and the second is the metric. These values matter after the router has identified competing routes to the same destination prefix. The primary lookup rule is still the matching destination prefix.

Destination Prefixes and Address Ranges

A CIDR prefix combines a network address with a prefix length. The prefix length states how many of the 32 IPv4 bits identify the network portion.

For example, 10.0.0.0/8 means that the first 8 bits identify the network. The remaining 24 bits identify addresses within that network. Its address span is:

  • First address: 10.0.0.0
  • Last address: 10.255.255.255

The prefix 10.0.0.0/8 represents a range, not one individual destination host. Addresses such as 10.1.2.3 and 10.250.4.9 are individual host addresses inside that range. The network prefix is the route's matching region; the host address is the specific destination inside that region.

How Routes Reach the Routing Table

Route typeHow it is installedTypical useMaintenance characteristic
ConnectedAutomatically created when an addressed interface is operational.A network attached directly to the router.Changes when interface addressing or operational status changes.
StaticManually configured by an administrator.Small networks, stub networks, backup paths, and default routing.Requires manual updates when the topology changes.
DynamicLearned through a routing protocol.Networks where routers must exchange reachability information.Can adjust automatically as topology information changes.

Directly Connected Routes

A router automatically installs a directly connected route when an interface has an IP address and subnet mask and the interface is operational. The route identifies a network attached directly to that interface.

For example, if a router interface is configured as 10.0.0.1 255.0.0.0 and is active, the router can install a route for 10.0.0.0/8. Traffic matching that network is sent through the associated local interface.

Cisco IOS uses the route code C to identify a connected network. A connected route generally does not need a next-hop address because the destination network is directly reachable through the router's own interface. The router may use Layer 2 address resolution, such as ARP, to deliver the packet on that local network.

Reading a connected Cisco route

Use this Cisco IOS command to display the IPv4 routing table:

show ip route

A simplified entry might look like this:

C    10.0.0.0/8 is directly connected, FastEthernet0/1

Interpret the entry as follows:

  • C identifies a connected route.
  • 10.0.0.0/8 is the destination prefix.
  • is directly connected means no remote next-hop router is required for this destination network.
  • FastEthernet0/1 is the outgoing interface.

To inspect the route selected for a particular destination or prefix, use:

show ip route 10.0.0.0

Static Routes

Static routing means that an administrator manually configures routes. A static route can specify a next-hop IP address, an exit interface, or both.

Static routes are useful in small networks, stub networks with one main exit path, backup paths, and default routing. For example, this command illustrates a route to 192.0.2.0/24 through a neighboring router:

ip route 192.0.2.0 255.255.255.0 192.168.1.2

This command illustrates a default static route through an upstream next hop:

ip route 0.0.0.0 0.0.0.0 192.168.1.1

Static routes do not automatically understand a changed topology. If the next hop fails or the network design changes, the administrator must update the configuration unless another mechanism is being used to track availability.

Dynamic Routes

Dynamic routing means that routers learn routes through routing protocols. Routers exchange reachability information, select paths according to protocol rules, and can adjust their route information when the topology changes.

Common examples include RIP, OSPF, and EIGRP where supported by the platform. This introductory lesson does not require protocol-specific configuration. The important distinction is that dynamic routes are learned and maintained through a routing process rather than entered individually by an administrator.

Route Selection Fundamentals

Longest-prefix match

A router may have more than one route that matches a destination. It first applies longest-prefix match: the matching route with the greatest number of network bits is the most specific and is selected.

Consider these routes:

  • 10.0.0.0/8 through one interface
  • 10.20.0.0/16 through another interface

The destination 10.20.5.25 belongs to both ranges. The /16 route is more specific than the /8 route, so the router uses the forwarding information associated with 10.20.0.0/16.

Default routes

The IPv4 default route is written as 0.0.0.0/0. Its zero network bits make it the least-specific route: it can match every IPv4 destination. A router uses it only when no more-specific matching route is available.

For example, with 192.168.10.0/24 directly connected and 0.0.0.0/0 through an upstream router, a destination of 203.0.113.25 does not match the local /24 but does match the default route. The router sends it to the configured upstream next hop.

Administrative distance and metric

If equivalent destination prefixes are learned from different sources, route preference values help decide which route enters or remains in the routing table. On Cisco platforms, administrative distance expresses preference between route sources. A lower value is generally preferred.

A metric is a path value used by a routing protocol to compare routes learned by that same routing process. Metric meanings differ between protocols. For beginner route lookups, first identify the matching prefix and apply longest-prefix match; then consider administrative distance and metric when competing candidates have equivalent prefixes.

Route Lookup Examples

Destination IPAvailable matching routesSelected routeReason
A destination on a directly attached network10.0.0.0/8 connected10.0.0.0/8 connectedThe destination matches the connected prefix, so the associated local interface is used.
10.20.5.2510.0.0.0/8 and 10.20.0.0/1610.20.0.0/16Both match, but /16 is more specific than /8.
203.0.113.25192.168.10.0/24 and 0.0.0.0/00.0.0.0/0Only the default route matches.
A destination outside every known prefixNo matching route and no default routeNoneThe router cannot forward the packet and may return ICMP destination unreachable, subject to policy.

Host Operating-System Routing Tables

Routing tables are used by end hosts as well as routers. A host route table helps the operating system decide whether a destination is directly connected or should be sent to the default gateway.

For a directly connected destination, the host sends traffic onto its local network. For an off-subnet destination, it selects a route through the configured default gateway. The host is therefore making a routing decision, although its table format and forwarding behavior are not identical to a router's.

On Windows, display the local IPv4 and IPv6 routing tables with:

route print

When troubleshooting, check the host's IP address, subnet mask, and default gateway. A router can have a correct route to the remote subnet while the host still fails to send traffic correctly because its own addressing or gateway configuration is wrong.

Troubleshooting Routing Problems

No route to a remote destination

  • Display the routing table and look for a prefix containing the destination IP address.
  • Check whether a suitable default route exists.
  • Determine whether the route should be connected, static, or dynamically learned.
  • Enable or correct the relevant interface, add or correct a static route, or repair routing-protocol reachability and advertisements.

A connected network is missing

  • Verify that the interface has the correct IP address and subnet mask.
  • Check that the interface is administratively enabled and has an operational link state.
  • Confirm that the expected network prefix is derived from the configured address and mask.
  • Correct the interface addressing or bring the interface and underlying link up.

Traffic takes an unexpected path

  • List every route that matches the destination IP address.
  • Compare prefix lengths and identify the longest match.
  • For same-length candidates, inspect route-source preference and metric.
  • Look for an overly broad static route or an unintended default route.
  • Adjust the incorrect prefix, next hop, preference, metric, or routing policy.

The host cannot reach a remote subnet

  • Verify the host's IP address, mask, and default gateway.
  • Confirm that the host recognizes the target as off-subnet.
  • Verify return-path routing from the remote network back to the host network.
  • Correct the host gateway configuration or add the missing reverse route.

Exam-Relevant Summary

  • A router examines the destination IP address in an incoming packet.
  • A routing table is local to the device and contains destination prefixes plus forwarding instructions.
  • A host sends off-subnet traffic to its default gateway.
  • A connected route is automatically created for an active, addressed router interface and is shown by Cisco IOS with code C.
  • A static route is manually configured and must usually be updated manually when the topology changes.
  • A dynamic route is learned through a routing protocol such as RIP, OSPF, or EIGRP.
  • The route with the longest matching prefix is selected.
  • 0.0.0.0/0 is the least-specific default route and is used as a fallback.
  • Administrative distance compares route sources, while a routing metric compares paths according to a routing protocol.
  • If no route matches and no default route exists, the router cannot forward the packet and may generate an ICMP destination-unreachable message.

For a related reference, see Routing Table Explained.