Explain how routers make forwarding decisions using routing tables
Configure static routes and default routes
Compare distance-vector and link-state routing protocols
Describe RIP, OSPF, and their key characteristics
Understand administrative distance and metric-based path selection
What Routers Do
A router connects different networks and forwards packets between them based on their destination IP address. When a packet arrives, the router examines the destination IP, consults its routing table, and forwards the packet to the next hop or directly to the destination network.
Routers operate at OSI Layer 3. Each router interface belongs to a different network (different subnet). Unlike switches, routers do not forward broadcasts -- each interface is a separate broadcast domain.
The Routing Table
Every router maintains a routing table that lists known destination networks and how to reach them. Entries are populated by directly connected networks, static routes, and dynamic routing protocols.
/* Example routing table (Cisco IOS) */Router# show ip route
Codes: C - connected, S - static, O - OSPF, R - RIP
Gateway of last resort is 10.0.0.1 to network 0.0.0.0
C 192.168.1.0/24 is directly connected, GigabitEthernet0/0
C 10.0.0.0/30 is directly connected, Serial0/0/0
S 172.16.0.0/16 [1/0] via 10.0.0.1
O 192.168.2.0/24 [110/20] via 10.0.0.1, 00:05:12, Serial0/0/0
S* 0.0.0.0/0 [1/0] via 10.0.0.1
/* [admin distance/metric] -- lower is preferred */
Static Routes
Static routes are manually configured by an administrator. They never change unless modified. Ideal for small networks, stub networks, or as a backup to dynamic routing.
/* Static route syntax */Router(config)# ip route [destination network][mask][next-hop IP or exit interface]/* Example: Route to 172.16.0.0/16 via next-hop 10.0.0.1 */Router(config)# ip route 172.16.0.0 255.255.0.010.0.0.1/* Default route (gateway of last resort) */Router(config)# ip route 0.0.0.0 0.0.0.010.0.0.1/* Floating static route (backup with higher AD) */Router(config)# ip route 172.16.0.0 255.255.0.010.0.1.15// AD of 5 means this route is only used if the primary (AD 1) fails
Administrative Distance
When multiple routing sources provide routes to the same destination, the router uses Administrative Distance (AD) to determine which source to trust. Lower AD = more trustworthy.
Route Source
Default AD
Directly Connected
0
Static Route
1
EIGRP Summary
5
eBGP
20
EIGRP (internal)
90
OSPF
110
IS-IS
115
RIP
120
EIGRP (external)
170
iBGP
200
Unknown / Unreachable
255
AD vs Metric:
AD selects between different routing protocols (OSPF vs RIP). Metric selects between different paths within the SAME protocol (two OSPF routes to the same destination). They solve different problems.
Dynamic Routing Protocols
Dynamic routing protocols automatically discover networks, calculate best paths, and adapt to topology changes. They fall into two categories:
Distance-VectorRouters share their entire routing table with directly connected neighbors. Path selection based on hop count or composite metric. Examples: RIP, EIGRP. Think "routing by rumor."
Link-StateRouters build a complete map of the network topology, then independently calculate shortest paths. More CPU/memory, but faster convergence. Examples: OSPF, IS-IS.
RIP -- Routing Information Protocol
RIP is the simplest distance-vector protocol. It uses hop count as its metric (maximum 15 hops -- 16 is unreachable). RIPv2 supports CIDR and VLSM. It sends full routing table updates every 30 seconds via multicast (224.0.0.9).
/* RIP Configuration */Router(config)# router rip
Router(config-router)# version 2
Router(config-router)# network 192.168.1.0Router(config-router)# network 10.0.0.0Router(config-router)# no auto-summary
/* RIP Limitations:
- Max 15 hops (not suitable for large networks)
- Slow convergence (hold-down timers, 180s)
- Periodic full-table broadcasts consume bandwidth
- No concept of link speed in metric (hop count only) */
OSPF -- Open Shortest Path First
OSPF is a link-state protocol that builds a complete topology map using Link-State Advertisements (LSAs). It uses Dijkstra's Shortest Path First (SPF) algorithm to calculate the best route. Metric is based on interface cost (derived from bandwidth).
OSPF AreasLarge OSPF networks are divided into areas to reduce LSA flooding. Area 0 (backbone) is mandatory. All other areas must connect to it.
DR/BDR ElectionOn multi-access segments, OSPF elects a Designated Router (DR) and Backup DR to reduce adjacency count. Highest priority or Router ID wins.
Routing Decision Process
When a packet arrives, the router follows this decision process:
1. Extract destination IP from the packet header
2. Perform longest prefix match against the routing table
// /28 is preferred over /24 for the same destination3. If multiple sources match, choose lowest Administrative Distance
4. If same AD, choose lowest metric
5. If equal cost paths exist, load-balance (ECMP)
6. If no match found, use default route (0.0.0.0/0)
7. If no default route, drop the packet and send ICMP Destination Unreachable
Key Takeaways
Routers forward packets between networks using routing tables