Skip to main content
AD Academy
CCNA — Cisco Networking Fundamentals
Beginner14 minLast updated: Topic 4 of 12

Routing: Static, OSPF and Default Route

How a router chooses a route, routing table, static and dynamic routing.

Not read

What you will learn here

  • How a router picks a path for a packet
  • How to read a routing table
  • When to use static routes vs OSPF

Worth reading first:IPv4 Addresses and Subnetting

A Router receives a packet, checks the destination address against the routing table, and chooses the most suitable route (Longest Prefix Match). If there is no match — the packet is dropped, unless a Default Route is configured.

What determines which route wins

A packet arrives with a destination IP. Step 1: Longest Prefix Match — the most specific route wins. Step 2: Administrative Distance — with equal prefixes, the more trusted source wins (Connected 0, Static 1, OSPF 110, RIP 120). Step 3: metric within the same protocol, which in OSPF is bandwidth-based cost. With no match at all the Default Route is used, otherwise the packet is dropped.

Short and clear

  • A router always picks the longest prefix match: /32 beats /24, and /24 beats /0.
  • If the same route comes from several sources, administrative distance decides: static (1) beats OSPF (110).
  • Still tied? The protocol's own metric (cost) breaks it.
  • No match at all? The packet goes to the default route (0.0.0.0/0) — or is dropped if none exists.

Real-life exampleDestination 10.1.1.5: the table holds 0.0.0.0/0, 10.0.0.0/8 and 10.1.1.0/24 — the router picks the /24 as the most specific.

  • Longest Prefix Match — a more specific route (/32) overrides a general one (/24).
  • Administrative Distance — Connected=0, Static=1, EIGRP=90, OSPF=110, RIP=120.
  • Metric — within the same protocol: in OSPF by Cost (bandwidth).
! Static Routing and Default Route
Router(config)# ip route 10.20.0.0 255.255.255.0 192.168.1.2
Router(config)# ip route 0.0.0.0 0.0.0.0 192.168.1.1

! Basic OSPF
Router(config)# router ospf 1
Router(config-router)# network 192.168.10.0 0.0.0.255 area 0
Router(config-router)# network 192.168.20.0 0.0.0.255 area 0

! Checks
Router# show ip route
Router# show ip ospf neighbor
Router# traceroute 10.20.0.5
bash
Architecture and Theory — Under the Hood

Router selects a route based on three rules in this order: (1) Longest Prefix Match, (2) Administrative Distance — how reliable the information source is, (3) Metric within the same protocol.

Packet -> 10.1.5.20
Routing Table:
  0.0.0.0/0    via ISP        AD 1
  10.0.0.0/8   via OSPF       AD 110
  10.1.5.0/24  via Static     AD 1   <== Chosen (Most specific)
text
  • is checked before Metric, but only after Longest Prefix Match — a static /32 route will always beat an OSPF /24.
  • Metric: OSPF = Cost (based on bandwidth), RIP = Hop Count, EIGRP = Bandwidth+Delay.
  • Default Route (0.0.0.0/0) = 'Anything unknown — send there'.
  • Floating Static: static route with a high (e.g., 200) as a backup to the dynamic route.
Practical Configuration (CLI)
! Static + Default
R(config)# ip route 10.1.5.0 255.255.255.0 10.0.0.2
R(config)# ip route 0.0.0.0 0.0.0.0 203.0.113.1
! Floating static (backup)
R(config)# ip route 10.1.5.0 255.255.255.0 10.0.9.2 200

! Basic OSPF
R(config)# router ospf 1
R(config-router)# router-id 1.1.1.1
R(config-router)# network 10.0.0.0 0.0.0.255 area 0
R(config-router)# passive-interface gi0/1
R(config-router)# default-information originate
bash
Real-world Scenarios in an Organization
  • Branch with primary line + LTE backup: dynamic primary route, floating static on LTE.
  • Default route towards the ISP, and specific routes for internal networks.
  • Passive-interface on all user-facing interfaces — do not advertise OSPF towards hosts.
Troubleshooting
R# show ip route
R# show ip route 10.1.5.20     ! Which route is actually chosen
R# show ip protocols
R# traceroute 10.1.5.20
R# ping 10.1.5.20 source gi0/1
bash
  • There's a forward path but no return (Asymmetric / missing Return Route) — classic issue.
  • Next-hop unreachable → Route not installed in the table.
  • Two identical routes from different protocols → The one with the lower wins.
Glossary and Quick Command Line
  • : C=0, S=1, eBGP=20, EIGRP=90, OSPF=110, RIP=120
  • ip route <net> <mask> <next-hop> []
  • show ip route | show ip protocols | traceroute

Check yourself

Which protocol has a lower (preferred) Administrative Distance?

What does the 0.0.0.0/0 route do?

Was this page helpful?