Chapter 11: Static and Dynamic Routing
Learning Objectives
By the end of this chapter, you will be able to: - Configure and troubleshoot static routing - Understand routing table concepts and administrative distance - Implement default routes and route summarization - Compare static and dynamic routing approaches - Design routing solutions for different network scenarios
Routing Fundamentals
What is Routing?
Routing is the process of selecting paths in a network along which to send network traffic. Routers use routing tables to determine the best path to forward packets toward their destination.
Key Routing Concepts
- Routing Table: Database containing network destinations and next-hop information
- Administrative Distance: Trustworthiness rating of routing information sources
- Metric: Value used to determine the best path when multiple routes exist
- Next Hop: The next router in the path toward the destination
- Route Summarization: Combining multiple routes into a single advertisement
Routing Table Structure
# Example routing table output
Router# show ip route
Codes: L - local, C - connected, S - static, R - RIP, M - mobile, B - BGP
D - EIGRP, EX - EIGRP external, O - OSPF, IA - OSPF inter area
N1 - OSPF NSSA external type 1, N2 - OSPF NSSA external type 2
E1 - OSPF external type 1, E2 - OSPF external type 2
i - IS-IS, su - IS-IS summary, L1 - IS-IS level-1, L2 - IS-IS level-2
ia - IS-IS inter area, * - candidate default, U - per-user static route
o - ODR, P - periodic downloaded static route, H - NHRP, l - LISP
+ - replicated route, % - next hop override
Gateway of last resort is 192.168.1.1 to network 0.0.0.0
S* 0.0.0.0/0 [1/0] via 192.168.1.1
10.0.0.0/8 is variably subnetted, 4 subnets, 2 masks
C 10.1.1.0/24 is directly connected, GigabitEthernet0/0/0
L 10.1.1.1/32 is directly connected, GigabitEthernet0/0/0
S 10.2.2.0/24 [1/0] via 10.1.1.2
S 10.3.3.0/24 [1/0] via 10.1.1.3Static Routing
Static Route Configuration
Static routes are manually configured routes that don’t change unless manually modified.
Basic Static Route Lab
# Static routing lab topology
name: static-routing-lab
prefix: static
topology:
nodes:
r1:
kind: cisco_iosxe
image: cisco/iosxe:latest
mgmt-ipv4: 172.20.20.10
startup-config: |
hostname Router1
!
interface GigabitEthernet0/0/0
ip address 10.1.1.1 255.255.255.0
no shutdown
!
interface GigabitEthernet0/0/1
ip address 192.168.1.1 255.255.255.0
no shutdown
!
r2:
kind: cisco_iosxe
image: cisco/iosxe:latest
mgmt-ipv4: 172.20.20.11
startup-config: |
hostname Router2
!
interface GigabitEthernet0/0/0
ip address 10.1.1.2 255.255.255.0
no shutdown
!
interface GigabitEthernet0/0/1
ip address 192.168.2.1 255.255.255.0
no shutdown
!
r3:
kind: cisco_iosxe
image: cisco/iosxe:latest
mgmt-ipv4: 172.20.20.12
startup-config: |
hostname Router3
!
interface GigabitEthernet0/0/0
ip address 10.1.1.3 255.255.255.0
no shutdown
!
interface GigabitEthernet0/0/1
ip address 192.168.3.1 255.255.255.0
no shutdown
!
pc1:
kind: linux
image: alpine:latest
mgmt-ipv4: 172.20.20.21
exec:
- ip addr add 192.168.1.10/24 dev eth1
- ip route add default via 192.168.1.1
pc2:
kind: linux
image: alpine:latest
mgmt-ipv4: 172.20.20.22
exec:
- ip addr add 192.168.2.10/24 dev eth1
- ip route add default via 192.168.2.1
pc3:
kind: linux
image: alpine:latest
mgmt-ipv4: 172.20.20.23
exec:
- ip addr add 192.168.3.10/24 dev eth1
- ip route add default via 192.168.3.1
links:
# Router interconnections
- endpoints: ["r1:eth1", "r2:eth1"]
- endpoints: ["r1:eth1", "r3:eth1"] # Multi-access network
# PC connections
- endpoints: ["r1:eth2", "pc1:eth1"]
- endpoints: ["r2:eth2", "pc2:eth1"]
- endpoints: ["r3:eth2", "pc3:eth1"]Configuring Static Routes
# Deploy the lab
containerlab deploy -t static-routing-lab.yml
# Connect to Router1 and configure static routes
docker exec -it clab-static-r1 cli
# Configure static routes on R1
configure terminal
ip route 192.168.2.0 255.255.255.0 10.1.1.2
ip route 192.168.3.0 255.255.255.0 10.1.1.3
exit
# Verify routing table
show ip route
# Test connectivity
ping 192.168.2.10
ping 192.168.3.10Static Route Types
Standard Static Routes
# Basic static route syntax
ip route <destination_network> <subnet_mask> <next_hop_ip>
# Examples
ip route 192.168.2.0 255.255.255.0 10.1.1.2
ip route 10.0.0.0 255.0.0.0 172.16.1.1Default Routes
# Default route (gateway of last resort)
ip route 0.0.0.0 0.0.0.0 <next_hop_ip>
# Example
ip route 0.0.0.0 0.0.0.0 192.168.1.1Floating Static Routes
Backup routes with higher administrative distance:
# Primary route (AD = 1)
ip route 192.168.2.0 255.255.255.0 10.1.1.2
# Backup route (AD = 5)
ip route 192.168.2.0 255.255.255.0 10.1.1.3 5Interface-Based Static Routes
# Route pointing to an interface (for point-to-point links)
ip route 192.168.2.0 255.255.255.0 Serial0/0/0
# Fully specified route (interface + next-hop)
ip route 192.168.2.0 255.255.255.0 Serial0/0/0 10.1.1.2Advanced Static Routing Lab
# Advanced static routing with redundancy
name: advanced-static-routing
prefix: adv-static
topology:
nodes:
# Core routers
core-r1:
kind: cisco_iosxe
image: cisco/iosxe:latest
mgmt-ipv4: 172.20.20.10
startup-config: |
hostname Core-Router-1
!
interface GigabitEthernet0/0/0
description To-Core-R2-Primary
ip address 10.1.1.1 255.255.255.252
no shutdown
!
interface GigabitEthernet0/0/1
description To-Core-R2-Backup
ip address 10.1.2.1 255.255.255.252
no shutdown
!
interface GigabitEthernet0/0/2
description To-Branch-R1
ip address 10.2.1.1 255.255.255.252
no shutdown
!
interface Loopback0
ip address 1.1.1.1 255.255.255.255
!
! Static routes with redundancy
ip route 2.2.2.2 255.255.255.255 10.1.1.2
ip route 2.2.2.2 255.255.255.255 10.1.2.2 5
ip route 192.168.10.0 255.255.255.0 10.2.1.2
ip route 0.0.0.0 0.0.0.0 10.1.1.2
ip route 0.0.0.0 0.0.0.0 10.1.2.2 5
!
core-r2:
kind: cisco_iosxe
image: cisco/iosxe:latest
mgmt-ipv4: 172.20.20.11
startup-config: |
hostname Core-Router-2
!
interface GigabitEthernet0/0/0
description To-Core-R1-Primary
ip address 10.1.1.2 255.255.255.252
no shutdown
!
interface GigabitEthernet0/0/1
description To-Core-R1-Backup
ip address 10.1.2.2 255.255.255.252
no shutdown
!
interface GigabitEthernet0/0/2
description To-Internet
ip address 203.0.113.1 255.255.255.252
no shutdown
!
interface Loopback0
ip address 2.2.2.2 255.255.255.255
!
! Static routes
ip route 1.1.1.1 255.255.255.255 10.1.1.1
ip route 1.1.1.1 255.255.255.255 10.1.2.1 5
ip route 192.168.10.0 255.255.255.0 10.1.1.1
ip route 192.168.10.0 255.255.255.0 10.1.2.1 5
ip route 0.0.0.0 0.0.0.0 203.0.113.2
!
branch-r1:
kind: cisco_iosxe
image: cisco/iosxe:latest
mgmt-ipv4: 172.20.20.12
startup-config: |
hostname Branch-Router-1
!
interface GigabitEthernet0/0/0
description To-Core-R1
ip address 10.2.1.2 255.255.255.252
no shutdown
!
interface GigabitEthernet0/0/1
description LAN-Interface
ip address 192.168.10.1 255.255.255.0
no shutdown
!
! Static routes
ip route 0.0.0.0 0.0.0.0 10.2.1.1
!
internet-sim:
kind: linux
image: alpine:latest
mgmt-ipv4: 172.20.20.100
exec:
- ip addr add 203.0.113.2/30 dev eth1
- ip route add 0.0.0.0/0 via 203.0.113.1
branch-pc:
kind: linux
image: alpine:latest
mgmt-ipv4: 172.20.20.20
exec:
- ip addr add 192.168.10.10/24 dev eth1
- ip route add default via 192.168.10.1
links:
# Core router connections (redundant)
- endpoints: ["core-r1:eth1", "core-r2:eth1"]
- endpoints: ["core-r1:eth2", "core-r2:eth2"]
# Branch connection
- endpoints: ["core-r1:eth3", "branch-r1:eth1"]
# Internet connection
- endpoints: ["core-r2:eth3", "internet-sim:eth1"]
# Branch LAN
- endpoints: ["branch-r1:eth2", "branch-pc:eth1"]Administrative Distance
Administrative Distance (AD) determines the trustworthiness of routing information sources. Lower AD values are preferred.
Default Administrative Distances
| Route Source | Administrative Distance |
|---|---|
| Connected Interface | 0 |
| Static Route | 1 |
| EIGRP | 90 |
| OSPF | 110 |
| RIP | 120 |
| External EIGRP | 170 |
| Unknown | 255 (unreachable) |
Configuring Administrative Distance
# Static route with custom AD
ip route 192.168.1.0 255.255.255.0 10.1.1.2 150
# Modify AD for routing protocols
router ospf 1
distance 95
router eigrp 100
distance eigrp 85 155Route Summarization
Route summarization reduces routing table size by combining multiple routes into a single advertisement.
Manual Route Summarization
# Instead of advertising individual subnets:
# 192.168.1.0/24
# 192.168.2.0/24
# 192.168.3.0/24
# 192.168.4.0/24
# Advertise summary route:
ip route 192.168.0.0 255.255.252.0 10.1.1.2Summarization Lab Example
# Route summarization lab
name: route-summarization
topology:
nodes:
hub-router:
kind: cisco_iosxe
image: cisco/iosxe:latest
startup-config: |
hostname Hub-Router
!
interface GigabitEthernet0/0/0
ip address 10.1.1.1 255.255.255.0
no shutdown
!
! Summary route instead of individual routes
ip route 192.168.0.0 255.255.252.0 10.1.1.2
!
spoke-router:
kind: cisco_iosxe
image: cisco/iosxe:latest
startup-config: |
hostname Spoke-Router
!
interface GigabitEthernet0/0/0
ip address 10.1.1.2 255.255.255.0
no shutdown
!
interface GigabitEthernet0/0/1
ip address 192.168.1.1 255.255.255.0
no shutdown
!
interface GigabitEthernet0/0/2
ip address 192.168.2.1 255.255.255.0
no shutdown
!
interface GigabitEthernet0/0/3
ip address 192.168.3.1 255.255.255.0
no shutdown
!
! Individual routes back to hub
ip route 0.0.0.0 0.0.0.0 10.1.1.1
!
links:
- endpoints: ["hub-router:eth1", "spoke-router:eth1"]Dynamic Routing Overview
Dynamic routing protocols automatically discover and maintain routing information.
Types of Dynamic Routing Protocols
Distance Vector Protocols
- RIP (Routing Information Protocol)
- EIGRP (Enhanced Interior Gateway Routing Protocol)
Characteristics: - Share routing tables with neighbors - Use hop count or composite metrics - Prone to routing loops - Slower convergence
Link State Protocols
- OSPF (Open Shortest Path First)
- IS-IS (Intermediate System to Intermediate System)
Characteristics: - Share link state information - Build topology database - Use SPF algorithm - Faster convergence - More CPU and memory intensive
Comparison: Static vs Dynamic Routing
| Aspect | Static Routing | Dynamic Routing |
|---|---|---|
| Configuration | Manual | Automatic |
| Scalability | Poor | Good |
| Convergence | None | Fast |
| Resource Usage | Low | Higher |
| Security | High | Medium |
| Maintenance | High | Low |
| Flexibility | Low | High |
When to Use Static Routing
- Small networks with few routers
- Stub networks with single exit point
- Security-critical environments
- Bandwidth-constrained links
- Default routes to ISPs
When to Use Dynamic Routing
- Large networks with many routers
- Redundant paths requiring automatic failover
- Frequently changing topologies
- Load balancing requirements
- Complex network designs
Routing Troubleshooting
Common Routing Issues
Missing Routes
# Symptoms
ping fails to remote networks
traceroute shows incomplete path
# Diagnosis
show ip route
show ip route <destination>
# Resolution
Add missing static routes
Verify next-hop reachabilityRouting Loops
# Symptoms
High CPU utilization
Packets with decreasing TTL
Intermittent connectivity
# Diagnosis
traceroute shows repeating hops
show ip route shows conflicting routes
# Resolution
Verify route summarization
Check administrative distances
Implement route filteringSuboptimal Routing
# Symptoms
Poor performance
Unexpected path selection
# Diagnosis
show ip route
traceroute analysis
show ip route <destination> longer-prefixes
# Resolution
Adjust administrative distances
Modify route metrics
Implement policy routingDiagnostic Commands
Essential Routing Commands
# Routing table
show ip route
show ip route summary
show ip route <network>
# Interface status
show ip interface brief
show interfaces
# Connectivity testing
ping <destination>
traceroute <destination>
telnet <destination> <port>
# Route verification
show ip route <destination> longer-prefixes
show ip cef <destination>Advanced Troubleshooting
# Debug routing (use carefully)
debug ip routing
debug ip packet
# Route monitoring
show ip route summary
show ip route profile
# Interface statistics
show interfaces <interface> | include (input|output) rate
show interfaces <interface> countersPractical Routing Scenarios
Scenario 1: Hub-and-Spoke with Backup
# Hub-and-spoke with backup connectivity
name: hub-spoke-backup
topology:
nodes:
hub:
kind: cisco_iosxe
image: cisco/iosxe:latest
startup-config: |
hostname Hub
!
interface GigabitEthernet0/0/0
description Primary-to-Spoke1
ip address 10.1.1.1 255.255.255.252
no shutdown
!
interface GigabitEthernet0/0/1
description Primary-to-Spoke2
ip address 10.1.2.1 255.255.255.252
no shutdown
!
interface GigabitEthernet0/0/2
description Backup-Link
ip address 10.1.3.1 255.255.255.252
no shutdown
!
! Primary routes
ip route 192.168.1.0 255.255.255.0 10.1.1.2
ip route 192.168.2.0 255.255.255.0 10.1.2.2
! Backup routes (higher AD)
ip route 192.168.1.0 255.255.255.0 10.1.3.2 5
ip route 192.168.2.0 255.255.255.0 10.1.3.2 5
!
spoke1:
kind: cisco_iosxe
image: cisco/iosxe:latest
startup-config: |
hostname Spoke1
!
interface GigabitEthernet0/0/0
description Primary-to-Hub
ip address 10.1.1.2 255.255.255.252
no shutdown
!
interface GigabitEthernet0/0/1
description LAN
ip address 192.168.1.1 255.255.255.0
no shutdown
!
interface GigabitEthernet0/0/2
description Backup-to-Spoke2
ip address 10.1.3.2 255.255.255.252
no shutdown
!
! Default route via hub
ip route 0.0.0.0 0.0.0.0 10.1.1.1
! Backup default route
ip route 0.0.0.0 0.0.0.0 10.1.3.1 5
!
spoke2:
kind: cisco_iosxe
image: cisco/iosxe:latest
startup-config: |
hostname Spoke2
!
interface GigabitEthernet0/0/0
description Primary-to-Hub
ip address 10.1.2.2 255.255.255.252
no shutdown
!
interface GigabitEthernet0/0/1
description LAN
ip address 192.168.2.1 255.255.255.0
no shutdown
!
! Default route via hub
ip route 0.0.0.0 0.0.0.0 10.1.2.1
!
links:
- endpoints: ["hub:eth1", "spoke1:eth1"]
- endpoints: ["hub:eth2", "spoke2:eth1"]
- endpoints: ["hub:eth3", "spoke1:eth3"] # Backup linkScenario 2: Load Balancing
# Equal-cost load balancing
startup-config: |
! Multiple equal-cost paths
ip route 192.168.10.0 255.255.255.0 10.1.1.2
ip route 192.168.10.0 255.255.255.0 10.1.2.2
! Enable load balancing
maximum-paths 4Best Practices
Static Routing Best Practices
- Documentation: Maintain accurate network diagrams and route tables
- Consistency: Use consistent naming and addressing schemes
- Redundancy: Implement backup routes with appropriate AD
- Summarization: Use route summarization to reduce table size
- Security: Implement route filtering and access controls
Route Management
- Change Control: Document all routing changes
- Testing: Test routes in lab before production
- Monitoring: Monitor routing table size and convergence
- Backup: Maintain configuration backups
- Automation: Use scripts for repetitive tasks
Performance Considerations
- Route Table Size: Monitor and optimize table size
- Convergence Time: Minimize convergence delays
- CPU Usage: Monitor routing process CPU utilization
- Memory Usage: Track routing table memory consumption
- Bandwidth: Consider routing protocol overhead
Summary
Static and dynamic routing serve different purposes in network design. Static routing provides simplicity and security for small networks and specific use cases, while dynamic routing offers scalability and automatic adaptation for larger, more complex networks. Understanding both approaches and their appropriate applications is essential for effective network design.
Key concepts covered: - Static route configuration and types - Administrative distance and route selection - Route summarization techniques - Comparison of static vs dynamic routing - Troubleshooting methodologies - Practical implementation scenarios
In the next chapter, we’ll dive deep into OSPF, one of the most important dynamic routing protocols for enterprise networks.
Review Questions
- What are the advantages and disadvantages of static routing?
- How does administrative distance affect route selection?
- When would you use floating static routes?
- What are the benefits of route summarization?
- How do you troubleshoot routing connectivity issues?
Hands-on Exercises
Exercise 1: Basic Static Routing
- Deploy the static routing lab topology
- Configure static routes on all routers
- Test connectivity between all networks
- Verify routing tables and trace packet paths
Exercise 2: Redundant Static Routes
- Implement the advanced static routing lab
- Configure primary and backup routes
- Test failover by disabling primary links
- Monitor route table changes during failover
Exercise 3: Route Summarization
- Create a network with multiple subnets
- Implement route summarization
- Compare routing table sizes before and after
- Test connectivity to verify summarization works
Exercise 4: Troubleshooting Scenarios
- Create various routing problems (missing routes, loops)
- Practice diagnostic commands and procedures
- Develop systematic troubleshooting approaches
- Document solutions and prevention strategies