Routing Basics: How Data Travels Across Networks
Understand IP routing fundamentals including routing tables, routing protocols, static and dynamic routing, and how data crosses the internet.
Tracing Packet Routes Across Networks
When a packet leaves your machine, how does it reach its destination? Understanding routing tables, next-hop selection, and routing protocols is critical for network mapping, troubleshooting latency, and identifying where traffic is being redirected or dropped. This guide covers the routing concepts you need for network analysis and security assessments.
Prerequisites
Understanding of IP addressing, subnetting, and the OSI model Layer 3.
How Routing Works
The Routing Table
Every router maintains a routing table — a database of known networks and the best path to reach them.
ip route show
# default via 192.168.1.1 dev eth0
# 192.168.1.0/24 dev eth0 scope link
# 10.0.0.0/8 via 192.168.2.1 dev eth1
Entries include: destination network, next hop, interface, and metric (cost).
Default Gateway
The default route (0.0.0.0/0) is used when no more specific route matches. For home networks, this is the router connecting to the internet.
Routing Decision Process
Static Routing
Manually configured by an administrator. Best for small networks, stub networks, default routes, and security-sensitive environments.
# Linux: Add a static route
sudo ip route add 10.0.0.0/24 via 192.168.1.254 dev eth0
# Remove
sudo ip route del 10.0.0.0/24
Example
Network A (192.168.1.0/24) connected to B (192.168.2.0/24) connected to C (10.0.0.0/24). Router A needs: ip route add 10.0.0.0/24 via 192.168.2.1
Dynamic Routing
Protocols automatically discover topology changes and update routing tables.
Interior Gateway Protocols (IGP) — Within an organization
RIP: Distance-vector, hop count metric (max 15), simple but slow, legacy.
OSPF: Link-state, cost based on bandwidth, fast convergence (seconds), most common enterprise IGP.
EIGRP: Cisco proprietary hybrid protocol, fast convergence, Cisco-only.
Exterior Gateway Protocols (EGP) — Between organizations
BGP (Border Gateway Protocol): Path-vector protocol, the routing protocol of the internet. Uses path attributes, supports complex policies. Over 900,000 routes in the global BGP table.
Path Selection Criteria
- Directly connected: 0
- Static: 1
- OSPF: 110
- eBGP: 20 / iBGP: 200
Data Flow Across the Internet
traceroute google.com
# 1 192.168.1.1 (home router)
# 2 10.0.0.1 (ISP access)
# 3 72.14.237.1 (ISP backbone)
# 4 142.250.80.46 (Google server)
Real-World Examples
Multi-Homed Organization: Company with two internet connections uses BGP to advertise IP ranges through both for redundancy.
OSPF in Data Centers: Large data centers use OSPF between hundreds of switches. When a server fails, OSPF detects it within seconds.
BGP Hijacking: A malicious ISP falsely advertises IP ranges, diverting traffic. Route Origin Authorization (ROA) and RPKI help prevent this.
Common Mistakes
Forgetting return routes — routing is bidirectional. Using dynamic routing on simple networks (overkill). Misconfiguring administrative distance causing routing loops.
Best Practices
Use static routes for simple stable networks. Use OSPF for redundant or changing networks. Use BGP for multi-homed internet. Document routing decisions. Monitor routing tables for unexpected changes. Implement RPKI and BGP filtering.
Related Tools
traceroute — Trace packet path. ip route — View/modify routing table. bird — Open-source routing daemon. FRRouting — Routing suite. Wireshark — Analyze routing protocols. bgp.he.net — BGP looking glass.
Related Articles
Summary
Routing forwards packets toward destinations across networks. Static routes are manually configured for stable networks. Dynamic protocols like OSPF (interior) and BGP (exterior) adapt to topology changes automatically. The internet relies on BGP connecting thousands of autonomous systems.