Introduction
Routers connect different IP networks and decide where packets should go next. Routing concepts explain how routers choose paths, build routing tables, and forward packets toward their destinations.
Learning Goals
By the end of this module, you should be able to:
- Explain the two main functions of a router.
- Describe path determination and packet forwarding.
- Apply the longest prefix match rule.
- Identify route sources in a routing table.
- Explain directly connected, static, dynamic, and default routes.
- Describe administrative distance and load balancing.
Two Main Router Functions
A router performs two major tasks:
- Path determination: Choose the best route to a destination network.
- Packet forwarding: Move packets from the incoming interface to the correct outgoing interface or next hop.
Routers use routing tables to make these decisions.
Path Determination
When a packet arrives, the router checks the destination IP address and searches the routing table for the best matching route. A route may point to an exit interface, a next-hop IP address, or both.
The best match is not always the route with the smallest network. It is the route with the longest matching prefix.
Longest Prefix Match
If multiple routes match a destination, the router chooses the most specific match. A longer prefix length means more network bits match.
Example IPv4 routing entries:
| Route | Prefix Length |
|---|---|
0.0.0.0/0 | least specific default route |
192.168.0.0/16 | broad private network route |
192.168.10.0/24 | more specific LAN route |
192.168.10.50/32 | host route |
For destination 192.168.10.50, the /32 route wins if present. If not, /24 beats /16, and /16 beats /0.
Activity: Longest Match Practice
IPv6 Longest Match
IPv6 uses the same longest-prefix principle. A route such as 2001:db8:acad:10::/64 is more specific than 2001:db8:acad::/48, and both are more specific than the default route ::/0.
Building the Routing Table
Routes can enter the routing table through several sources:
- directly connected interfaces,
- static route configuration,
- dynamic routing protocols,
- default route configuration,
- local host routes for interface addresses.
A route is usable only if its associated interface or next hop is reachable.
Packet Forwarding Decision Process
A simplified forwarding process is:
- Receive a frame on an interface.
- Remove the Layer 2 header.
- Inspect the destination IP address.
- Find the best matching route.
- Decrement TTL for IPv4 or Hop Limit for IPv6.
- Re-encapsulate the packet in a new Layer 2 frame for the outgoing link.
- Forward the frame out the selected interface.
Packet Forwarding Mechanisms
Cisco routers have used different forwarding methods over time:
- Process switching: CPU handles packet decisions individually.
- Fast switching: A route cache speeds up repeated flows.
- Cisco Express Forwarding (CEF): Uses optimized forwarding information structures for efficient forwarding.
Modern Cisco devices commonly use CEF.
Activity: Basic Router Verification
Route Sources
Routing tables identify how a route was learned. Common codes include:
- C: directly connected network,
- L: local interface address,
- S: static route,
- O: OSPF route,
- D: EIGRP route,
- R: RIP route,
- B: BGP route.
Exact codes depend on platform and enabled protocols.
Directly Connected Networks
When a router interface is configured with an IP address and is up/up, the connected network is installed in the routing table. A local host route for the interface address is often installed as well.
Static Routes
A static route is manually configured by an administrator. Static routes are predictable and efficient, but they do not automatically adapt to topology changes unless additional tracking or floating static routes are used.
Dynamic Routing Protocols
Dynamic routing protocols allow routers to exchange route information and adapt to changes. Examples include OSPF, EIGRP, RIP, IS-IS, and BGP. Dynamic routing is useful when networks are larger or change frequently.
Default Route
A default route is used when no more specific route matches the destination. It is commonly used to send unknown traffic toward an upstream router or internet edge.
IPv4 default route: 0.0.0.0/0
IPv6 default route: ::/0
Administrative Distance
Administrative distance measures the trustworthiness of a route source. When two routes to the same destination have the same prefix length but different sources, the route with the lower administrative distance is preferred.
For example, a directly connected route is usually preferred over a static route, and a static route is usually preferred over many dynamic routes.
Static or Dynamic Routing?
Static routing is useful for:
- small networks,
- stub networks,
- default routes,
- backup routes,
- predictable paths.
Dynamic routing is useful for:
- larger networks,
- redundant topologies,
- frequent changes,
- automatic convergence.
Many real networks use both.
Best Path and Load Balancing
Routers choose the best path using routing information such as prefix length, administrative distance, and routing protocol metric. If multiple equal-cost routes exist, the router may load balance traffic across them.
Activity: Route Source Identification
Summary
Routing is the process of choosing paths and forwarding packets between networks. Routers use longest prefix match, route sources, metrics, and administrative distance to decide where traffic should go.