When you send a message to someone on the same local network, the data may reach them directly. But what happens when you want to access a server located on another network or another side of the world?
The data needs to find a path through multiple networks. This process is called Routing.
Routing is the process of determining and using a path for forwarding packets from a source network toward a destination network.
Routers are the main devices responsible for routing.
Computer
↓
Router A
↓
Router B
↓
Router C
↓
Web Server
Each router examines the destination IP address and decides where the packet should go next.
Why Do We Need Routing?
The Internet is not one giant network. It is made up of millions of interconnected networks.
If your computer wants to communicate with a server on another network, it needs a way to reach that network.
Routing helps:
Find paths between networks
Forward packets toward their destinations
Connect different networks
Choose appropriate next hops
Keep large networks organized
Without routing, devices would have no practical way to communicate across different IP networks.
How Does Routing Work?
Suppose your computer wants to communicate with a server:
Your PC
192.168.1.10
|
↓
Router
|
↓
Internet
|
↓
Server
Your computer checks whether the destination is on its local network.
If the destination is on another network, the packet is sent to the default gateway, usually a router.
The router then checks its routing table to determine where to forward the packet.
Packet arrives
↓
Check destination IP
↓
Look at routing table
↓
Choose next hop/interface
↓
Forward packet
This process is repeated by routers along the path until the packet reaches its destination network.
What Is a Routing Table?
A routing table is a collection of information that a router uses to decide where to forward packets.
A simplified routing table might look like:
Destination Network | Next Hop | Interface |
|---|---|---|
192.168.1.0/24 | Directly connected | LAN |
10.0.0.0/8 | 192.168.1.1 | WAN |
172.16.0.0/16 | 192.168.1.2 | WAN |
0.0.0.0/0 | ISP Router | WAN |
When a packet arrives, the router compares the destination IP address with its routing entries and selects the most specific matching route.
What Is a Next Hop?
A next hop is the next router or destination to which a packet should be forwarded.
For example:
Router A → Router B → Router C → Destination
↑
Next Hop
From Router A's perspective, Router B is the next hop.
After Router B receives the packet, it makes its own routing decision.
Types of Routing
Routing is commonly classified into:
Static Routing
Dynamic Routing
1. Static Routing
In static routing, routes are manually configured by a network administrator.
For example:
Network: 10.0.0.0/8
Next Hop: 192.168.1.1
The administrator explicitly tells the router where to send traffic for that network.
Advantages
Simple for small networks
No routing-protocol overhead
Gives administrators direct control
Disadvantages
Manual configuration
Difficult to maintain in large networks
Does not automatically adapt to network failures or topology changes
Static routing is useful when the network is small or the routing requirements are simple and predictable.
2. Dynamic Routing
In dynamic routing, routers use routing protocols to exchange information and learn routes automatically.
Some well-known routing protocols include:
RIP
OSPF
BGP
EIGRP
For example:
Router A ←→ Router B
↕ ↕
Router C ←→ Router D
Routers exchange routing information and can update their routing tables when the network changes.
Advantages
Automatically learns routes
Adapts to network changes
Suitable for larger networks
Disadvantages
More complex
Uses network and processing resources
Requires understanding of routing protocols
Routing Protocols
Different routing protocols use different methods to determine the best paths.
RIP
RIP (Routing Information Protocol) uses hop count as its primary metric.
A route with fewer hops is generally preferred.
RIP is simple but has limitations and is not suitable for many modern large networks.
OSPF
OSPF (Open Shortest Path First) is a link-state routing protocol commonly used within organizations and enterprise networks.
It uses a cost metric and builds a view of the network topology to calculate routes.
BGP
BGP (Border Gateway Protocol) is used to exchange routing information between autonomous systems and is fundamental to Internet routing.
It uses policies and path attributes to select routes rather than simply choosing the physically shortest path.
Routing vs Forwarding
These two terms are closely related but are not exactly the same.
Routing
Routing is the process of determining paths and maintaining routing information.
Forwarding
Forwarding is the actual process of moving a packet from an incoming interface to the appropriate outgoing interface.
Think of it like this:
Routing → Decides the path
Forwarding → Moves the packet
Routing vs Switching
Routing and switching are also commonly confused.
Routing | Switching |
|---|---|
Connects different IP networks | Mainly connects devices within a local network |
Uses IP addresses | Uses MAC addresses for Ethernet forwarding |
Performed primarily by routers | Performed primarily by switches |
Works mainly at the Network Layer | Works mainly at the Data Link Layer |
For example:
PC ── Switch ── Router ── Internet
↑ ↑
Switching Routing
The switch handles local Ethernet forwarding, while the router handles forwarding between IP networks.
Default Route
Sometimes a router does not have a specific route for a destination.
In that situation, it can use a default route if one is configured.
For IPv4, the default route is commonly written as:
0.0.0.0/0
For IPv6, it is:
::/0
A default route essentially means:
"If no more specific route matches, send the packet this way."
For example, a home router typically has a default route toward the ISP.
Simple Real-Life Example
Suppose you open a website hosted on another network.
The process can be simplified as:
Your Computer
↓
Default Gateway
↓
Router 1
↓
Router 2
↓
Router 3
↓
Web Server
At each routing step, the router examines the destination IP address and decides where to forward the packet next.
The exact path may change depending on routing information and network conditions.
Conclusion
Routing is the process of determining paths and forwarding packets between different networks.
Routers use routing tables to make forwarding decisions, and routes can be configured manually using static routing or learned automatically using dynamic routing protocols.
The easiest way to remember the concept is:
Routing → Decide where the packet should go
Forwarding → Send the packet to the next destination
Once you understand routing, concepts such as routing tables, default gateways, static routes, OSPF, BGP, and autonomous systems become much easier to understand.