Networking handbook · Chapter 15

Routing fundamentals

A router usually needs to know only the next hop for a destination. A useful forwarding worksheet records the destination prefix, next hop and output interface, then applies the same longest-prefix comparison a router would use.

In this guide13 sections

Introduction

A router usually needs to know only the next hop for a destination. A useful forwarding worksheet records the destination prefix, next hop and output interface, then applies the same longest-prefix comparison a router would use.

Build the forwarding entries

An active interface can supply a connected prefix. Operators can add static routes, and routing protocols can learn paths from neighbors. The routing process chooses eligible paths and installs forwarding entries. Preference rules and metrics depend on the implementation and protocol.

Forwarding is the subsequent per-packet decision. Within an ordinary destination-based table, select the matching entry with the longest prefix. A more specific installed entry wins over an installed covering prefix for destinations within it. A default route has zero fixed bits.

Resolve the next hop

A connected destination can usually be reached through the destination’s own link address. A remote prefix points toward another router. On Ethernet, an IPv4 node commonly uses ARP for the chosen next hop, while IPv6 uses Neighbor Discovery.

At a routed hop, the router removes the incoming link framing, decrements the IPv4 TTL or IPv6 Hop Limit, and builds framing for the outgoing link. In ordinary forwarding without translation or tunneling, the final IP destination stays the same while the link destination changes.

Plan both directions

A route from a branch to headquarters supplies only the outward decision. The reply has a different destination and each router looks it up independently. A valid return path may use different routers.

For summary routes, examine the entire block a summary covers, including gaps between assigned subnets. The advertising router must have a defined policy for traffic to those gaps. A more-specific route can direct one constituent subnet along another path.

Diagram

  1. Destination 198.51.100.190
  2. Match /0, /24 and /25
  3. Select /25
  4. Resolve 192.0.2.2 on transit link
For the entries below, the upper-half /25 matches more destination bits than either its /24 parent or the default route.

Worked examples

Choose between a branch route and a summary

  1. Assume the router can directly reach next hops 192.0.2.1 and 192.0.2.2. Install the three example entries in the table.
  2. For 198.51.100.190, the /24 and the 198.51.100.128/25 both match. The /25 covers last octets 128–255, so select 192.0.2.2.
  3. For 198.51.100.42 the /25 misses and the /24 selects 192.0.2.1. For 203.0.113.10 neither specific route matches, so use the default.

CIDR Calculator: Normalize a /20 route from an interface record

  1. For 172.20.29.209/20, the first 16 bits fix 172.20. Another four fix the upper half of octet three. The mask is 255.255.240.0.
  2. The third octet 29 is 00011101. Keeping its leading 0001 gives 16 at the bottom and 31 at the top. The fourth octet can run from 0 to 255.
  3. The resulting route is 172.20.16.0/20. Its final address is 172.20.31.255. Count 16 values of the third octet times 256 values of the fourth to obtain 4,096.

Reference table

Routing fundamentals reference
Installed prefixNext hopCoverage in this table
198.51.100.128/25192.0.2.2Upper half of the branch block
198.51.100.0/24192.0.2.1Parent branch block
0.0.0.0/0192.0.2.1Fallback for other IPv4 destinations

Configuration example

  • In a branch design, document the transit interface and on-link reachability of 192.0.2.2 alongside the /25 route. Configure the peer with a route back to the source subnet.
  • If equal-cost paths are enabled, record which equally specific entry can use multiple next hops and how the device distributes flows.

Common mistakes

  • Choosing the numerically lowest next-hop address before comparing destination prefixes.
  • Assuming two endpoints with different subnet masks agree about which destinations are on-link.

Frequently asked questions

Can a low-metric default route override an installed /24?

For ordinary destination-based forwarding in one table, the matching /24 is more specific. Metrics choose among eligible paths to a prefix during route selection.

Why does a packet need both an IP address and a MAC destination?

The IP address identifies the destination for routing across the internetwork. The link address delivers this frame to the next recipient on the local Ethernet segment.

What does a default route do?

It is a fallback route used when no more specific route matches the destination. It points the packet toward a next hop or outgoing interface.

Does a router send a frame directly to a remote server's MAC address?

No. On an Ethernet link, it resolves the next hop's local link-layer address. The remote destination's MAC address is not carried end to end across routed links.

How is the matching route chosen?

Forwarding generally uses longest-prefix match among valid routes, with routing protocol preference and local policy determining which routes enter the forwarding table.

Can two routes to the same prefix exist?

Yes. Routing protocols and static configuration can provide alternatives. The system selects among them using route preference, metrics, policy, and sometimes load-sharing rules.

What is the difference between a routing table and a neighbor table?

A routing table chooses an outgoing path or next hop for an IP destination. A neighbor table maps a directly reachable next-hop IP address to link-layer information on that link.

When is a static route useful?

A static route can provide a simple fixed path in a small or stable design. Dynamic routing is more suitable when paths or topology need to adapt automatically.

Does BGP choose routes based only on the shortest physical path?

No. BGP route selection considers attributes and policy between autonomous systems. The chosen path reflects administrative decisions as well as reachability information.

Can a router have a route without a working neighbor entry?

Yes. The route can be installed while next-hop resolution fails. Packets may then be queued or dropped until the adjacent neighbor becomes reachable.

What is equal-cost multipath routing?

ECMP allows a router to use multiple routes with equal selection cost for the same destination. Traffic may be distributed across paths according to the device's hashing and policy.

Does a route identify every router along the path?

Usually not. A route identifies a destination prefix and a next hop or interface. Each router independently selects its next step.

Why can the forward and return routes differ?

Routing is selected independently at each endpoint and hop. Policy, topology, load balancing, and failures can create asymmetric paths.

What does administrative distance mean?

Some router vendors use administrative distance or preference to choose among routes learned from different sources. The exact value and rules are platform-specific.

Can a default route create a routing loop?

Yes. Misconfigured default routes between routers can send traffic back and forth. TTL or hop-limit prevents indefinite circulation, but the loop still causes packet loss and delay.

Further learning and references