Routing
What is Routing?
Routing is the process of selecting the best path for data packets to travel from source to destination across one or more networks. Routers use routing tables to make forwarding decisions based on destination IP addresses.
Static vs Dynamic Routing
| Feature | Static Routing | Dynamic Routing |
|---|---|---|
| Configuration | Manually configured by admin | Automatically learned via routing protocols |
| Adaptability | Does not adapt to network changes | Adapts automatically to topology changes |
| Overhead | No routing protocol overhead | Routing protocol traffic overhead |
| Scalability | Poor (manual updates needed) | Excellent |
| Security | More secure (no protocol to exploit) | Less secure (routing updates can be spoofed) |
| Use Case | Small networks, stub networks, default routes | Large, complex networks |
Dynamic Routing Protocols
| Protocol | Type | Algorithm | Use Case |
|---|---|---|---|
| RIP | IGP, Distance Vector | Bellman-Ford | Small networks (max 15 hops) |
| OSPF | IGP, Link State | Dijkstra (SPF) | Large enterprise networks |
| EIGRP | IGP, Hybrid | DUAL | Cisco networks |
| BGP | EGP, Path Vector | Best Path Selection | Internet backbone, ISPs |
| IS-IS | IGP, Link State | Dijkstra | Large ISP networks |
IGP = Interior Gateway Protocol (within an autonomous system) | EGP = Exterior Gateway Protocol (between autonomous systems)
Distance Vector vs Link State
| Feature | Distance Vector | Link State |
|---|---|---|
| Knowledge | Only knows neighbors and distances | Complete topology map |
| Updates | Periodic full table updates to neighbors | Triggered updates (LSAs) flooded to all |
| Convergence | Slow | Fast |
| Memory/CPU | Low | High |
| Loops | Prone to routing loops | Loop-free (SPF algorithm) |
| Examples | RIP, IGRP | OSPF, IS-IS |
NAT - Network Address Translation
NAT allows multiple devices on a private network to share a single public IP address. It translates private IP addresses to public IP addresses and vice versa.
- SNAT (Source NAT): Translates the source IP address. Used when private hosts access the Internet. The router replaces the private source IP with its public IP.
- DNAT (Destination NAT): Translates the destination IP address. Used for port forwarding — incoming traffic to a public IP is redirected to a private server.
- PAT (Port Address Translation) / NAT Overload: Maps multiple private IPs to a single public IP using different port numbers. Most common form of NAT in home routers.
Default Gateway
The default gateway is the router that a device uses to send traffic to destinations outside its local network. When a device doesn't have a specific route for a destination, it sends the packet to the default gateway.
Example: If your PC has IP 192.168.1.100/24 and default gateway 192.168.1.1, all traffic to non-192.168.1.x addresses goes to 192.168.1.1 (your router).
Ready to Level Up Your Skills?
Explore 500+ free tutorials across 20+ languages and frameworks.