Routing is the fundamental process of selecting a path for traffic in a network or between or across multiple networks. At its core, routing allows devices on completely different networks—perhaps separated by thousands of miles—to communicate with each other.
Routing occurs at Layer 3 (the Network Layer) of the OSI model. The hardware devices primarily responsible for this process are Routers and Layer 3 Switches.
The Routing Process Conceptually
To understand routing, you must understand how a computer decides where to send a packet of data. Every IP Address contains a network portion and a host portion.
When a computer wants to send data, it asks one question: "Is the destination IP on my local network, or a remote network?"
- Directly Connected Networks: If the destination is local, the computer uses ARP to find the MAC address and sends the data directly through a local switch.
- Remote Networks: If the destination is on a different network, the computer knows it cannot reach it directly. It must forward the packet to a router. The specific router responsible for handling outbound traffic from a local network is called the Default Gateway.
The Routing Journey: Host to Destination
Imagine a PC at 192.0.2.50 trying to load a webpage from a web server at 198.51.100.80. Here is the step-by-step routing flow:
- The Host: The PC determines
198.51.100.80is a remote network. It packages the data with a Source IP of192.0.2.50and a Destination IP of198.51.100.80. It sends this packet to its Default Gateway (the local office router). - The First Router: The local router receives the packet. It strips away the local Ethernet frame, reads the Destination IP, and checks its Routing Table to see if it knows how to reach the
198.51.100.0/24network. - The Next Hop: The routing table tells the router to forward the packet to the next router along the path (the Next Hop), which might be an ISP router.
- The Hops Continue: Each router along the path receives the packet, checks its own routing table, and forwards it to the next hop. The Source IP and Destination IP remain unchanged during this journey (unless NAT is used).
- The Destination: Eventually, a router realizes it is directly connected to the
198.51.100.0/24network. It sends the packet down to the local switch, which delivers it directly to the web server.
The Default Route (0.0.0.0/0)
The internet contains nearly a million unique routes. It is impossible for a small office router to know all of them. Instead, it relies on a Default Route (often written as 0.0.0.0/0). This route simply means: "If you don't know where to send a packet, send it here." The local router sends all unknown internet traffic to the ISP's router, which has much larger, more comprehensive routing tables.
How Routers Learn Routes
Routers can learn how to reach remote networks in two ways, which are detailed in our Static vs Dynamic Routing guide:
- Static Routing: An administrator manually types the network and next hop into the router's configuration.
- Dynamic Routing: Routers automatically talk to each other using protocols like OSPF or BGP to map out the network and calculate the best paths automatically.
Useful Commands
To diagnose routing issues, you can inspect how your local machine handles routing.
Windows
> route print # View your computer's local routing table
> tracert 8.8.8.8 # View every router hop to a destination
Linux (e.g., Ubuntu/Debian)
$ ip route # View your local routing table and gateway
$ traceroute 8.8.8.8 # View every router hop
For more on how to use tracing tools, see Traceroute Explained.
Quick Summary
- Routing is the Layer 3 process of forwarding packets toward a remote destination.
- Devices use their Default Gateway to reach any IP not on their local subnet.
- Routers use routing tables to determine the best "Next Hop" for every packet.
- The Default Route is used when a router does not have a specific path to a destination.