How Routing Works: A Beginner Guide to Network Routing

Routing is the process of forwarding data packets from source to destination across multiple networks. Routers use routing tables and protocols to find the most efficient path.

Network Routing

Every time you load a website or send a message, your data packets travel through a chain of routers across the internet. Routing is the process that decides the path those packets take from source to destination, and it happens automatically across thousands of devices in milliseconds.

What Is Network Routing

Routing is the process of selecting paths in a network along which data packets travel from one device to another. Routers are the specialised devices that perform this job at every step of the journey. Each router examines a packet's destination IP address, consults its routing table to find the best available path, and forwards the packet to the next device in the chain.

No single router knows the full path from source to destination. Each one only needs to know the next hop, meaning the next router to send the packet to that brings it closer to its destination. This hop-by-hop forwarding continues until the packet reaches the network where the destination device lives, at which point it is delivered directly.

Routing operates at the network layer of the internet protocol stack, working with IP addresses rather than the physical MAC addresses used by switches on a local network. Every device connected to the internet, from home routers to the core backbone routers operated by ISPs, participates in this system.

How a Router Decides Where to Forward a Packet

The decision a router makes for each incoming packet is called a forwarding decision. It happens at very high speed using a lookup against the router's routing table. The process follows a consistent sequence for every packet received.

  1. A packet arrives at the router with a destination IP address in its header
  2. The router extracts the destination IP address and performs a lookup in its routing table
  3. The routing table is searched for the most specific matching entry, which is the route with the longest prefix that matches the destination address
  4. The router identifies the next hop IP address and the outgoing interface associated with the matching route
  5. The router forwards the packet out through the correct interface toward the next hop router
  6. The time to live (TTL) value in the packet header is decremented by one at each hop to prevent packets from circulating indefinitely
  7. The packet continues hopping from router to router until it reaches the destination network and is delivered to the target device

What Is a Routing Table

A routing table is a database stored in a router's memory that lists all the network destinations the router knows how to reach and the best way to reach each one. Every forwarding decision is based on this table. Routing tables are built either manually by a network administrator or automatically by routing protocols that share information between routers.

FieldWhat It Contains
Destination NetworkThe IP address range this route applies to, expressed in CIDR notation such as 192.168.1.0/24
Subnet MaskDefines how many bits of the address identify the network versus the individual host within it
Next HopThe IP address of the next router to forward the packet to on the way toward the destination
InterfaceThe physical or virtual port on the router through which the packet should be sent
MetricA cost value used to compare routes when multiple paths to the same destination exist. Lower values indicate preferred routes.
Route SourceHow the route was learned, whether statically configured, learned via a routing protocol, or directly connected

When multiple routes match a destination, the router selects the most specific one based on the longest prefix match. For example, a route for 192.168.1.0/24 is preferred over a route for 192.168.0.0/16 for a packet destined for 192.168.1.50, because the /24 prefix is more specific. If two routes are equally specific, the metric value determines which one wins.

Types of Routing

TypeHow It WorksUsed When
Static RoutingRoutes are manually entered by a network administrator and do not change unless manually updatedSmall or simple networks with predictable, stable topology where administrative overhead is low
Dynamic RoutingRouters automatically exchange routing information with each other using routing protocols and update their tables as the network changesLarge or complex networks where routes change frequently due to failures, additions, or traffic conditions
Default RouteA catch-all route that matches any destination not found in the routing table, forwarding those packets to a specified gatewayAll home routers use a default route pointing to the ISP. Edge routers use it to forward unknown destinations to the internet backbone.

Routing Protocols

Dynamic routing relies on protocols that allow routers to automatically discover networks, share routing information with each other, and adapt when the network topology changes. Different protocols are designed for different scales and environments.

  • OSPF (Open Shortest Path First): A link-state protocol used within a single organisation's network, called an autonomous system. Each router builds a complete map of the network and calculates the shortest path to every destination based on link cost. OSPF converges quickly after topology changes and scales well to large enterprise networks.
  • BGP (Border Gateway Protocol): The routing protocol that underlies the entire internet. BGP is used between autonomous systems, meaning between different ISPs, data centres, and large networks, to exchange reachability information. Every ISP and major network uses BGP to announce which IP address ranges they can reach. BGP is a path-vector protocol that considers routing policies and business relationships rather than just shortest path.
  • RIP (Routing Information Protocol): One of the oldest dynamic routing protocols, designed for small networks. RIP uses hop count as its only metric and limits routes to a maximum of 15 hops. It is largely replaced by OSPF in modern networks but is still encountered in simple or legacy environments.
  • EIGRP (Enhanced Interior Gateway Routing Protocol): A Cisco-developed protocol that combines features of both distance-vector and link-state protocols. It considers bandwidth and delay in its metric calculation and converges faster than RIP while being simpler to configure than OSPF in some scenarios.

Autonomous Systems and Internet Routing

The internet is not a single network managed by one organisation. It is a collection of tens of thousands of independently managed networks called autonomous systems (AS). Each autonomous system is assigned a unique AS number and is responsible for routing within its own network. BGP is used to exchange routing information between autonomous systems, allowing packets to travel across organisational boundaries from one end of the internet to the other.

When you send a request from your home network to a server in another country, the packet may pass through your ISP's network, then a regional carrier, then an internet exchange point where multiple networks peer with each other, then the destination network's ISP, before finally reaching the target server. Each boundary crossing between autonomous systems involves BGP routing decisions.

Tracing the Route Your Data Takes

You can observe the actual path your packets take across the internet using the traceroute tool, which is built into every major operating system. It sends a series of packets with incrementally increasing TTL values and records the address and response time of each router that responds along the path.

Trace a route on Windows:
tracert google.com
# Each line shows one router hop, its IP or hostname, and round-trip time in milliseconds
Trace a route on Linux or macOS:
traceroute google.com
# Some hops may show * * * if the router does not respond to probes

A typical traceroute to a server in another country will show 10 to 20 hops. The first few are usually your home router and your ISP's local infrastructure. The middle hops cross backbone and carrier networks. The final hops approach the destination server's network. High latency on a specific hop indicates congestion or a long physical distance on that link.

Frequently Asked Questions

  1. How many routers does my data pass through?
    Most internet connections involve 10 to 20 router hops between your device and the destination server. Connections within the same country or region typically involve fewer hops and lower latency. Connections to servers on the other side of the world may involve more hops as packets cross multiple autonomous systems and ocean cables. You can count the exact hops for any destination using the traceroute or tracert command.
  2. Is routing the same as switching?
    No. Switching operates at the data link layer and forwards frames within a local network using MAC addresses. A switch connects devices on the same network and does not concern itself with IP addresses. Routing operates at the network layer and forwards packets between different networks using IP addresses. A router connects separate networks and makes decisions based on IP routing tables. Your home router performs both functions, switching traffic between devices on your local network and routing traffic between your local network and the internet.
  3. What happens if a router on the path fails?
    In networks using dynamic routing protocols such as OSPF or BGP, neighbouring routers detect the failure when they stop receiving routing protocol messages from the failed router. They update their routing tables to remove routes that depended on that router and calculate alternative paths. This convergence typically takes seconds to a few minutes depending on the protocol and configuration. Static routes do not adapt automatically, which is why large networks rely on dynamic routing for resilience.
  4. What is the difference between a router and a modem?
    A modem converts the signal from your ISP's infrastructure, whether that is a cable line, DSL telephone line, or fibre connection, into a standard network signal your devices can use. A router connects multiple devices on your local network and routes traffic between them and the internet. Most home broadband equipment combines both functions into a single device, but in enterprise environments they are separate. Your ISP provides the modem function, and you may add your own router behind it for more control over your local network.
  5. What is BGP hijacking?
    BGP hijacking occurs when a network operator, either maliciously or through misconfiguration, announces IP address ranges that belong to another organisation. Because BGP relies on trust between autonomous systems rather than cryptographic verification, other routers may accept these false announcements and begin routing traffic for those addresses through the attacker's network. This can result in traffic interception, eavesdropping, or service disruption. BGP hijacking incidents have affected major platforms and caused significant internet outages. RPKI (Resource Public Key Infrastructure) is a security extension designed to prevent this by cryptographically verifying which autonomous systems are authorised to announce specific IP ranges.

Conclusion

Routing is what makes the internet function as a single connected system despite being composed of thousands of independently operated networks. Every packet you send traverses multiple routers, each making a local forwarding decision based on its routing table, passing the packet closer to its destination one hop at a time. Dynamic routing protocols allow the internet to adapt automatically to link failures, congestion, and topology changes, maintaining connectivity without human intervention. Understanding how routing works gives you insight into network performance, troubleshooting tools like traceroute, and the global infrastructure your applications depend on. Continue with NAT, default gateway, and subnetting to build a complete picture of how networks are structured and connected.