Routing Basics — Understanding How Routers Connect Networks¶
Routing is the process of forwarding packets between different networks. Unlike switches, which forward Ethernet frames using MAC addresses, routers make forwarding decisions using IP addresses and routing tables. Every time you access a website, connect to a cloud service, communicate between subnets, or browse the Internet, routers determine the best path for your packets. Routing is the foundation of enterprise networking, cloud computing, data centres, and the Internet. Every Linux administrator, DevOps engineer, Cloud Architect, Platform Engineer, Site Reliability Engineer (SRE), and Network Engineer should understand routing fundamentals.
Learning Path¶
Course Progress
What You'll Learn¶
After completing this lesson, you'll be able to:
- Understand routing fundamentals
- Learn the role of routers
- Understand routing tables
- Learn how packets are forwarded
- Understand next-hop routing
- Learn direct and indirect routing
- Apply routing concepts in enterprise and cloud environments
Prerequisites¶
Complete:
- Module 1: Networking Fundamentals
- Module 2: IPv4 Addressing
- Module 3: IPv6
- Module 4: Switching
Why Learn Routing?¶
Imagine two computers located in different networks.
Computer A:
Computer B:
Since they belong to different networks:
A router is required.
What is Routing?¶
Routing is the process of moving packets from one network to another.
Example:
The router determines the best path toward the destination.
What is a Router?¶
A Router is a Layer 3 (Network Layer) device.
Its primary responsibilities are:
- Connect Different Networks
- Forward Packets
- Maintain Routing Tables
- Select Best Paths
- Separate Broadcast Domains
Switch vs Router¶
| Switch | Router |
|---|---|
| Layer 2 | Layer 3 |
| Uses MAC Addresses | Uses IP Addresses |
| Forwards Frames | Routes Packets |
| Connects Devices in Same Network | Connects Different Networks |
When is Routing Required?¶
Routing is needed whenever traffic must leave the local network.
Examples:
- Different Virtual Local Area Networks (VLANs)
- Different Subnets
- Branch Offices
- Cloud Networks
- Internet Access
Packet Journey¶
Suppose a user accesses:
The packet travels:
Every router along the path forwards the packet closer to its destination.
Routing Table¶
A router makes decisions using a:
Example:
| Destination Network | Next Hop |
|---|---|
| 192.168.10.0/24 | Direct |
| 192.168.20.0/24 | Router A |
| 10.0.0.0/8 | Router B |
| 0.0.0.0/0 | Internet Gateway |
Directly Connected Network¶
Example:
Router Interface:
Any destination inside:
is reached directly.
No additional router is required.
Indirect Network¶
Suppose the destination is:
Not directly connected.
Router:
Next Hop¶
The Next Hop is the next router that should receive the packet.
Example:
The packet moves from router to router until it reaches the destination network.
Default Gateway¶
Every host has a:
Example:
Computer:
Gateway:
If the destination is outside the local network:
Default Route¶
Routers also use a:
IPv4:
IPv6:
If no specific route exists, packets follow the default route.
Longest Prefix Match¶
Routers always choose the most specific matching route.
Example:
Destination:
Available routes:
Selected route:
because it has the longest matching prefix.
Routing Workflow¶
Packet Arrives
↓
Read Destination IP
↓
Search Routing Table
↓
Best Match Found
↓
Forward Packet
↓
Next Hop
Routing Decision Example¶
Host:
Destination:
Host determines:
Enterprise Example¶
Company Network:
↓
↓
↓
The router enables communication between all departments.
Cloud Perspective¶
Cloud providers use routing to connect:
- Virtual Machines
- Subnets
- Virtual Networks
- Internet Gateways
- Virtual Private Network (VPN) Connections
- Hybrid Networks
Routing tables determine how cloud traffic flows between resources.
Kubernetes Perspective¶
Routing is essential for:
- Pod-to-Pod Communication
- Pod-to-Service Communication
- Node-to-Node Traffic
- Ingress Traffic
- Egress Traffic
Container Network Interface (CNI) plugins install routes automatically on Kubernetes nodes.
Linux Perspective¶
Display routing table.
Display IPv6 routing table.
Display network interfaces.
Test routing.
Display the default gateway.
Routing Example¶
Every router performs a routing table lookup before forwarding the packet.
Hands-on Lab¶
Task 1¶
Display your routing table.
Task 2¶
Display your IPv6 routing table.
Task 3¶
Find your default gateway.
Task 4¶
Run:
Observe how packets travel through multiple routers.
Task 5¶
Draw a network showing:
- Client
- Router
- ISP
- Internet
- Server
Illustrate packet flow.
Task 6¶
Create a routing table for:
- HR Network
- Finance Network
- Engineering Network
- Internet
Task 7¶
Explain the difference between:
- Direct Route
- Indirect Route
- Default Route
Task 8¶
Research routing tables in your preferred cloud provider (AWS, Azure, or GCP).
Linux Commands¶
| Command | Purpose |
|---|---|
ip route | Display IPv4 routing table |
ip -6 route | Display IPv6 routing table |
ip addr | Display IP addresses |
traceroute | Trace packet path |
ping | Test connectivity |
Common Mistakes¶
❌ Confusing switching with routing.
✅ Switches forward frames; routers forward packets.
❌ Forgetting the default gateway.
✅ Configure the correct gateway for every subnet.
❌ Assuming routers use MAC addresses for routing.
✅ Routers make forwarding decisions using IP addresses.
❌ Ignoring the routing table.
✅ Always verify routes during troubleshooting.
❌ Misunderstanding longest prefix matching.
✅ Routers choose the most specific matching route.
Best Practices¶
- Keep routing tables simple and well documented.
- Use meaningful IP addressing plans.
- Verify default gateways on all hosts.
- Monitor routing changes in production environments.
- Prefer route summarisation where appropriate.
- Regularly test end-to-end connectivity.
Interview Questions¶
Beginner¶
- What is routing?
- What is a router?
- What is a routing table?
- What is a default gateway?
Intermediate¶
- Explain how a router forwards packets.
- What is a next hop?
- What is the difference between direct and indirect routing?
- Explain longest prefix matching.
Architect Level¶
- Design a routing architecture for a multi-site enterprise.
- How would you troubleshoot a routing issue between two data centres?
- Explain routing in hybrid cloud environments.
Summary¶
In this lesson, you learned:
- Routing fundamentals
- Routers
- Routing tables
- Direct routing
- Indirect routing
- Default gateways
- Default routes
- Next-hop routing
- Longest prefix matching
- Linux routing commands
Routing is the foundation of Layer 3 networking. Routers examine destination IP addresses, consult routing tables, and forward packets toward their destination using the best available path. Every enterprise network, cloud platform, and Internet connection depends on efficient routing to deliver data reliably.
Key Takeaways¶
- Routing connects different IP networks.
- Routers operate at OSI Layer 3.
- Routing decisions are based on IP addresses.
- Routing tables determine where packets are forwarded.
- The default gateway allows hosts to reach remote networks.
- Routers use longest prefix matching to select the most specific route.
What's Next?¶
In the next lesson, you'll learn about Static Routing.
You'll explore:
- What static routes are
- How to configure static routes
- Default static routes
- Recursive next-hop routing
- Floating static routes
- Linux static route configuration
- Enterprise use cases
By the end of the lesson, you'll understand how to manually configure routes and when static routing is the right choice for production networks.