Networking - Routing in Networking
1. What is Routing in Networking?
Routing is the process of selecting a path for data packets to travel from the source device to the destination device across networks.
-
Done by routers (network devices).
-
Uses routing tables and routing protocols.
-
Works at the Network Layer (Layer 3) of the OSI Model.
2. How Routing Works
When you send data to another device:
-
Your device creates a packet with the destination IP.
-
The packet goes to your default gateway (router).
-
The router checks its routing table.
-
The router forwards the packet toward the next hop (another router or destination).
-
The process repeats until the packet reaches the destination.
3. Example of Routing
Scenario:
You want to access www.example.com from your laptop.
-
Laptop IP:
192.168.1.10
-
Router IP:
192.168.1.1
-
Website IP:
203.0.113.5
Step-by-Step Process
-
Laptop sends the packet to the router (default gateway).
-
Router checks its routing table.
-
If the destination (
203.0.113.5
) is outside the local network, the router forwards it to the ISP router. -
ISP router forwards the packet across multiple routers on the internet.
-
Finally, the packet reaches the destination server and the response travels back the same way.
4. Types of Routing
A. Static Routing
-
Manually configured by network administrators.
-
Best for small networks.
-
No automatic updates if the network changes.
Example Command (Cisco):
Router(config)# ip route 192.168.2.0 255.255.255.0 192.168.1.2
This means:
To reach 192.168.2.0
, send packets to next hop 192.168.1.2
.
B. Dynamic Routing
-
Uses routing protocols to update routes automatically.
-
Best for large, complex networks.
Popular Routing Protocols:
Protocol | Type | Algorithm | Use Case |
---|---|---|---|
RIP | Distance Vector | Hop count | Small networks |
OSPF | Link State | Dijkstra’s SPF | Medium to large networks |
EIGRP | Hybrid | DUAL Algorithm | Cisco-based networks |
BGP | Path Vector | Best path selection | Internet backbone |
C. Default Routing
-
Used when a router doesn’t know the route.
-
Configures a default path for unknown destinations.
Example Command (Cisco):
Router(config)# ip route 0.0.0.0 0.0.0.0 192.168.1.1
Meaning:
If the destination is unknown, send all packets to 192.168.1.1
.
5. Routing Table
Routers store routes in a routing table, which contains:
-
Destination network
-
Subnet mask
-
Next hop (gateway)
-
Interface
-
Metric (cost)
Example Routing Table
Destination Network | Subnet Mask | Next Hop | Interface | Metric |
---|---|---|---|---|
192.168.1.0 | 255.255.255.0 | Directly Connected | eth0 | 0 |
192.168.2.0 | 255.255.255.0 | 192.168.1.2 | eth1 | 1 |
0.0.0.0 | 0.0.0.0 | 192.168.1.1 | eth0 | 5 |
6. Diagram of Routing
[Laptop]
192.168.1.10
|
| (Private Network)
|
[Router A]
192.168.1.1
Public IP: 103.45.21.5
|
| Internet
|
[Router B - ISP]
|
| -----> Routing via multiple routers
|
[Web Server]
203.0.113.5
7. Summary of Routing
Aspect | Static Routing | Dynamic Routing | Default Routing |
---|---|---|---|
Configured by | Manually | Automatically | Manually |
Best for | Small networks | Large networks | Unknown destinations |
Protocols | None | RIP, OSPF, BGP, EIGRP | None |
Scalability | Low | High | Medium |
Maintenance | Manual updates | Automatic updates | Simple |