Routing & OSPF MODULE 03
0 / 16 topics
How Routing Works
Routers forward packets between networks using a routing table

When a router receives a packet, it checks the destination IP against its routing table, finds the longest prefix match, and forwards the packet out the appropriate interface.

Longest Prefix Match: The most specific route (highest prefix length) always wins. /28 beats /24 beats /0.
Sample Routing Table (show ip route)
CodeNetworkAD/MetricNext Hop / Interface
C192.168.1.0/240/0directly connected, Gi0/0
L192.168.1.1/320/0local, Gi0/0
S10.0.0.0/81/0via 192.168.1.254
O172.16.0.0/16110/2via 10.1.1.2, Gi0/1
S*0.0.0.0/01/0via 209.165.200.2
C = Connected L = Local S = Static O = OSPF R = RIP S* = Default route
Administrative Distance
Router's preference when multiple protocols know the same route

Lower AD = more trustworthy. If a route is learned by two different protocols, the one with the lower AD is installed in the routing table.

SourceAD Value
Connected interface0
Static route1
EIGRP summary5
OSPF110
RIP120
Unknown / Unreachable255
Floating static route: Set AD higher than the dynamic protocol (e.g. AD 115 for a static backup to an OSPF route). It only activates if OSPF fails.
Static Routing
Manually configured routes — no routing protocol needed
When to use: Stub networks (one path only), small topologies, default routes to the internet, or as backup routes.
Static Route Syntax
R1(config)# ip route network mask {next-hop-IP | exit-interface} [AD] # Via next-hop IP (recommended) R1(config)# ip route 10.0.0.0 255.0.0.0 192.168.1.254 # Via exit interface (point-to-point only) R1(config)# ip route 10.0.0.0 255.0.0.0 GigabitEthernet0/1 # Default route (gateway of last resort) R1(config)# ip route 0.0.0.0 0.0.0.0 209.165.200.2 # Floating static (AD=115, backup to OSPF) R1(config)# ip route 10.0.0.0 255.0.0.0 192.168.1.254 115
OSPFv2 Concepts
Open Shortest Path First — link-state routing protocol

OSPF routers build a complete map of the network (LSDB) and use Dijkstra's SPF algorithm to calculate the shortest path. Metric = cost (reference BW ÷ interface BW).

OSPF Neighbor Adjacency States
1
Down
2
Init
3
2-Way
4
ExStart
5
Exchange
6
Loading
7
Full ✓
Hello interval10s (broadcast) / 30s (NBMA)
Dead interval4× Hello (40s / 120s)
Reference BW100 Mbps (default)
Cost = 100,000,000 ÷ BW (bps)
DR/BDR electionHighest priority, then highest Router ID
Router ID priorityManual → Loopback → Highest active IP
OSPFv2 Configuration
Single-area OSPF setup on a Cisco router
Basic OSPF Configuration
R1(config)# router ospf 1 R1(config-router)# router-id 1.1.1.1 # Advertise networks (wildcard mask) R1(config-router)# network 192.168.1.0 0.0.0.255 area 0 R1(config-router)# network 10.1.1.0 0.0.0.3 area 0 # Passive interface (don't send Hellos) R1(config-router)# passive-interface GigabitEthernet0/0 # Advertise default route into OSPF R1(config-router)# default-information originate # Adjust reference bandwidth (match network) R1(config-router)# auto-cost reference-bandwidth 1000
OSPF Verification Commands
# View OSPF neighbor table R1# show ip ospf neighbor Neighbor ID Pri State Dead Time Interface 2.2.2.2 1 Full/DR 00:00:34 Gi0/1 3.3.3.3 1 Full/BDR 00:00:38 Gi0/1 # View OSPF-learned routes R1# show ip route ospf # Check OSPF process details R1# show ip ospf R1# show ip ospf interface brief # View link-state database R1# show ip ospf database

Routing & OSPF Drills

Multiple choice questions on static routing, OSPF concepts, and verification.

0
Correct
0
Wrong
0
Streak 🔥
60s
QUESTION 1 · ROUTING

Packet Tracer Labs

Step-by-step routing configuration walkthroughs.

Routing Topology Diagrams

Routing Cheatsheet

Static Route Commands
# Standard static route R1(config)# ip route 192.168.2.0 255.255.255.0 10.0.0.2 # Default route (quad-zero) R1(config)# ip route 0.0.0.0 0.0.0.0 209.165.200.2 # Floating static (backup, higher AD) R1(config)# ip route 192.168.2.0 255.255.255.0 10.0.0.2 115 # Verify routing table R1# show ip route R1# show ip route static R1# ping 192.168.2.1 R1# traceroute 192.168.2.1
OSPF Configuration
# Enable OSPF process R1(config)# router ospf 1 R1(config-router)# router-id 1.1.1.1 # Advertise networks R1(config-router)# network 192.168.1.0 0.0.0.255 area 0 R1(config-router)# network 10.1.1.0 0.0.0.3 area 0 # Suppress Hellos on LAN-facing ports R1(config-router)# passive-interface Gi0/0 # Set interface cost manually R1(config-if)# ip ospf cost 10 # Set OSPF priority (DR election) R1(config-if)# ip ospf priority 100
OSPF Verification
# Neighbor table (must reach Full) R1# show ip ospf neighbor # OSPF-learned routes only R1# show ip route ospf # Process info (Router ID, Area, SPF) R1# show ip ospf # Per-interface OSPF info R1# show ip ospf interface brief R1# show ip ospf interface Gi0/1 # Full link-state database R1# show ip ospf database # Clear OSPF process (use carefully!) R1# clear ip ospf process
Key Concepts Quick Reference
OSPF AD110
Static AD1
OSPF metricCost (ref BW ÷ link BW)
Hello / Dead10s / 40s (broadcast)
Multicast Hello224.0.0.5 (all OSPF)
Multicast LSU224.0.0.6 (DR/BDR)
DR electionHighest priority → Router ID
Default priority1 (0 = never DR)
Backbone areaArea 0
SPF algorithmDijkstra's

Interactive Calculators

Tools to speed up exam calculations.

OSPF Cost Calculator
Cost = Reference BW ÷ Interface BW (min cost = 1)
1
OSPF Cost
Common interface costs (ref=100 Mbps)
Ethernet (10M)10
FastEthernet (100M)1
GigabitEthernet (1G)1 ⚠ same as FE!
With ref=1000M: GE1 · FE = 10 · 10M = 100
Fix: set auto-cost reference-bandwidth 1000 so GE costs 1 and FE costs 10.
AD / Route Type Reference
Administrative Distance cheat sheet
Route SourceAD
Connected0
Static route1
EIGRP summary5
External BGP20
EIGRP internal90
OSPF110
IS-IS115
RIP120
Unreachable255

Topic Checklist

Track your progress through routing concepts.

0%
Complete