Routing Fundamentals


Routing is the process of deciding where a packet should go after it leaves its local network. A router compares the packet’s destination address with the routes in its routing table, chooses the most specific usable route, and forwards the packet toward the next hop.

Understanding the Routing Table

A routing table is a list of destination prefixes and the information required to reach them. A route normally contains:

  • Destination prefix: The network the route matches, such as 192.0.2.0/24.
  • Next hop: The neighboring router that should receive the packet.
  • Outgoing interface: The interface used to forward the packet.
  • Route source: Connected, static, OSPF, BGP, or another protocol.
  • Preference and metric: Values used to select between competing routes.

Connected routes are installed automatically when an interface is up and has an address. Static routes are entered manually. Dynamic routes are learned from routing protocols.

How a Router Selects a Route

Route selection is frequently misunderstood because several decisions happen in sequence:

  1. Longest-prefix match: The most specific matching route wins. A /24 is preferred over a /16 for an address that matches both.
  2. Administrative preference: If multiple routing sources offer the same prefix length, the device compares the trust or preference assigned to each source.
  3. Protocol metric: If the routes come from the same protocol, the protocol’s metric selects the preferred path.
  4. Equal-cost handling: If multiple paths remain equal, the router may install more than one and load-share traffic.
Important: A default route does not override a more specific route. The default route is only used when no more specific destination is present.

Static Routes and Default Routes

Static routing works well for small, predictable networks and for special routes that should not depend on a dynamic protocol.

Cisco IOS example

ip route 10.20.0.0 255.255.0.0 192.0.2.2
ip route 0.0.0.0 0.0.0.0 198.51.100.1

Linux example

ip route add 10.20.0.0/16 via 192.0.2.2
ip route replace default via 198.51.100.1

VyOS example

configure
set protocols static route 10.20.0.0/16 next-hop 192.0.2.2
set protocols static route 0.0.0.0/0 next-hop 198.51.100.1
commit
save

Static routes are simple, but they can silently become incorrect when topology changes. Use tracking, health checks, or a dynamic routing protocol when automatic failover is required.

Dynamic Routing Protocols

Protocol Typical use What it optimizes
OSPF Enterprise, campus, service-provider internal routing Shortest path based on interface cost
IS-IS Large service-provider and data-center underlays Scalable link-state routing
BGP Internet routing, inter-domain policy, modern data-center fabrics Policy and path attributes rather than simple distance
RIP Legacy or very small networks Hop count

The choice of protocol should match the network’s operational needs. A small office with one router may not need dynamic routing. A hosting network with redundant routers, multiple upstreams, and many routed subnets almost certainly does.

Routing Policy and Traffic Engineering

Routing is not always about finding the mathematically shortest path. Operators often need to apply business or technical policy:

  • Prefer one internet transit provider for outbound traffic.
  • Keep backup links idle unless the primary path fails.
  • Route management traffic through a dedicated network.
  • Prevent customer routes from leaking into the core.
  • Send selected applications through a firewall or inspection device.

Policy can be implemented with route maps, prefix lists, routing protocol attributes, policy-based routing, or separate routing tables. Policy-based routing should be used carefully because it can make forwarding behavior harder to understand and troubleshoot.

Redundancy, First-Hop Protocols, and ECMP

Redundant routing requires more than installing two routers. The design must answer what happens to gateway addresses, sessions, routes, and state when one component fails.

  • First-hop redundancy: HSRP, VRRP, or a similar protocol provides a resilient default gateway to end devices.
  • Dynamic routing: Removes failed paths and installs alternatives.
  • ECMP: Equal-Cost Multi-Path routing uses multiple equal routes simultaneously.
  • Bidirectional Forwarding Detection: BFD can detect path failures faster than normal routing-protocol timers.

Fast convergence is useful only when the surrounding systems can tolerate it. Stateful firewalls, NAT devices, and asymmetric paths may still interrupt sessions even if the routing table converges immediately.

Routing Troubleshooting Workflow

  1. Confirm the destination address and prefix are correct.
  2. Check the local routing table for the most specific matching route.
  3. Verify the next hop is reachable through a connected network.
  4. Confirm ARP or IPv6 neighbor discovery can resolve the next hop.
  5. Check return routing from the destination back to the source.
  6. Look for ACLs, firewall policy, NAT, or policy-based routing that changes the path.
  7. Use traceroute and packet capture to identify where forwarding stops.
show ip route 203.0.113.25
show ip cef 203.0.113.25 detail
show arp
traceroute 203.0.113.25

ip route get 203.0.113.25
ip neigh show
tracepath 203.0.113.25