Dynamic Routing
π Dynamic Routing Protocols & Route Selection
A Complete Technical Guide for Learners, Interviewees, and Network Engineers
πΉ Part 1: Dynamic Routing Basics
What is Dynamic Routing?
Dynamic routing allows routers to automatically exchange routing information using protocols, keeping their routing tables updated without manual configuration.
π Dynamic Routing vs. Static Routing
| Feature | Static Routing | Dynamic Routing |
|---|---|---|
| Configured by | Manually by admin | Automatically by protocol |
| Reaction to network changes | No automatic response | Adapts dynamically |
| Scalability | Limited and error-prone | Scales to large networks |
| Use case | Small or stable networks | Large, complex, or changing topologies |
β A router can use both static and dynamic routing simultaneously.
πΉ Part 2: Types of Dynamic Routing Protocols
1οΈβ£ Interior Gateway Protocols (IGPs)
Used within a single Autonomous System (AS).
βΆ By Algorithm:
| Algorithm | Description | Protocols |
|---|---|---|
| Distance-Vector | Routers exchange known routes and hop counts without a complete network map. | RIP, EIGRP |
| Link-State | Routers share link info, build a full network map (LSDB), and compute best paths. | OSPF, IS-IS |
2οΈβ£ Exterior Gateway Protocols (EGPs)
Used between Autonomous Systems (e.g., enterprise to ISP).
| Algorithm | Description | Protocol |
|---|---|---|
| Path-Vector | Selects routes based on AS-paths (AS-to-AS logic). | BGP |
πΉ Part 3: Understanding Route Selection
2 Core Meanings of "Route Selection":
Routing Table Population: Choosing which route(s) to insert into the routing table (only the best per destination is kept).
Packet Forwarding Decision: Using the routing table to decide how to forward individual packets.
πΉ Part 4: Routing Table Population Logic
When multiple routes to the same destination exist, routers use:
1οΈβ£ Administrative Distance (AD)
Determines the trustworthiness of a source protocol.
| Route Source | AD (Lower = Better) |
|---|---|
| Directly Connected | 0 |
| Static Route | 1 |
| External BGP | 20 |
| EIGRP | 90 |
| OSPF | 110 |
| IS-IS | 115 |
| RIP | 120 |
| Internal BGP | 200 |
| Unusable | 255 |
β AD is only compared when multiple protocols provide routes to the same destination.
2οΈβ£ Metric
Used when multiple routes from the same protocol exist.
| Protocol | Metric Type | Description |
|---|---|---|
| RIP | Hop Count | Fewer hops = better |
| OSPF | Cost | Lower bandwidth = higher cost |
| EIGRP | Composite | Uses bandwidth, delay (and others if configured) |
π Lower metric is always preferred.
3οΈβ£ Equal-Cost Multi-Path (ECMP)
If multiple routes to the same destination from the same protocol have equal metrics, they are all installed in the routing table for load balancing.
4οΈβ£ Floating Static Routes
A static route with higher AD than a dynamic route (e.g., AD 111 vs OSPF AD 110) is used as a backup, inserted only if the preferred route fails.
πΉ Part 5: Packet Forwarding Logic
After routing table population:
- π§ Forwarding Rule: Choose the most specific route (longest prefix match) for the destination IP.
- β AD and Metric are NOT used during packet forwarding.
- β
Example:
- Destination: 10.0.1.5
- Match:
- 10.0.0.0/8 (Generic)
- 10.0.1.0/24 β (More specific β Used)
πΉ Part 6: Activating Routing Protocols
π₯ Enabling Routing on Interfaces (OSPF Example)
1
2
router ospf 1
network 192.168.1.0 0.0.0.255 area 0
π Understanding Wildcard Masks
Wildcard mask β Subnet mask Wildcard mask inverts the subnet mask.
| Subnet Mask | Wildcard Mask |
|---|---|
| 255.255.255.0 (/24) | 0.0.0.255 |
| 255.255.255.252 (/30) | 0.0.0.3 |
Binary Logic:
0= bit must match1= bit can vary
π― OSPF network Command Tasks:
- Interface Matching: Finds interfaces with IPs matching the
network+wildcard. - OSPF Activation: Enables OSPF on those interfaces.
- Prefix Advertisement: Router advertises the actual interface subnet, not the network command range.
π§ Pro Tip:
To control precisely which interface runs OSPF:
1
network 192.168.1.1 0.0.0.0 area 0
This ensures only that interface is affected.
π Final Notes for Interview & Exam Readiness
β Know All AD Values β Compare Metric Logic of RIP, OSPF, and EIGRP β Understand ECMP & Floating Static Routes β Be clear on the difference between Routing Table Population and Packet Forwarding β Master OSPF network command & wildcard mask behavior
- In enterprise networks, OSPF and EIGRP dominate for internal routing.
- BGP is essential for Internet routing and multi-ISP connections.
- Floating static routes are key for backup WAN paths.
- Always test routing configurations using tools like:
show ip routeshow ip protocolsshow ip protocols
β Summary Checklist
| Concept | Must Know? |
|---|---|
| Difference: Static vs Dynamic Routing | β |
| Types of Routing Protocols (IGP, EGP) | β |
| AD & Metric Logic | β |
| ECMP | β |
| Floating Static Routes | β |
| Longest Prefix Match (Forwarding) | β |
| OSPF Network Command & Wildcard | β |