How routers forward packets
Every router builds a routing table from three sources: directly connected routes, static routes you configure by hand, and dynamic routes learned via a routing protocol. When a packet arrives, the router does a longest prefix match - it picks the route with the most specific (longest) matching subnet mask, not just the first match it finds. If there is no match at all and no default route (0.0.0.0/0), the packet is dropped and the router should send back an ICMP destination unreachable message.
Administrative distance - who do you trust
When two different sources offer a route to the same destination, the router picks the one with the lowest administrative distance (AD). Learn these: connected = 0, static = 1, EIGRP internal = 90, OSPF = 110, RIP = 120, and anything unreachable/unknown = 255 (never installed). A common exam trap: metric only breaks ties WITHIN the same protocol - AD decides between protocols first.
Static vs dynamic routing
Static routes are simple, predictable and use zero CPU/bandwidth for calculation, but do not adapt if the network changes - you must edit them manually. Dynamic routing protocols (OSPF, EIGRP, RIP) automatically discover and adapt to topology changes but add complexity and overhead. A default static route (ip route 0.0.0.0 0.0.0.0 <next-hop>) is the classic 'gateway of last resort' used on stub networks like a small branch office.
OSPF essentials
OSPF is a link-state protocol using Dijkstra's SPF algorithm, AD 110, and cost as its metric (cost = reference bandwidth ÷ interface bandwidth, default reference 100 Mbps on older IOS). Routers become neighbours by exchanging Hello packets (default 10s on broadcast links, 30s on NBMA) and must agree on: area ID, subnet mask, hello/dead timers, and authentication type. Area 0 is always the backbone - every other area must connect back to it, directly or via a virtual link.
Inter-VLAN routing and gateways
Devices in different VLANs cannot talk without a router or Layer 3 switch. Router-on-a-stick uses one physical interface split into sub-interfaces (each tagged with dot1Q encapsulation for its VLAN) - cheap but limited by the single link's bandwidth. A Layer 3 switch with SVIs (switched virtual interfaces) is the enterprise standard - faster and scales better.
Common mistakes to avoid
- Confusing administrative distance (trust between protocols) with metric (best path within a protocol).
- Forgetting that longest prefix match always wins over a shorter, less specific route - even a static route.
- Mixing up classful summarisation with proper subnetting - CCNA expects VLSM, not old classful thinking.
- Forgetting the default route needs a valid, reachable next-hop or exit interface, or it will not install.
- Assuming a routing protocol is enabled just by turning it on - networks/interfaces must be explicitly advertised (e.g. network statements in OSPF).
What does a router do when two routes to the same destination come from different protocols?
It compares administrative distance and installs the route from the source with the lowest AD.
tap to reveal
What is the administrative distance of a directly connected route?
0 - the most trusted source, always preferred.
tap to reveal
What is the administrative distance of a static route?
1.
tap to reveal
What is OSPF's administrative distance?
110.
tap to reveal
What is RIP's administrative distance?
120.
tap to reveal
What happens when a router has two routes with different prefix lengths that both match the destination?
It always chooses the route with the longest (most specific) prefix match, regardless of AD or metric.
tap to reveal
How do you configure a default static route on a Cisco router?
ip route 0.0.0.0 0.0.0.0 <next-hop-ip-or-exit-interface>
tap to reveal
What algorithm does OSPF use to calculate best paths?
Dijkstra's Shortest Path First (SPF) algorithm.
tap to reveal
What four things must OSPF neighbours agree on to form an adjacency?
Area ID, subnet mask, hello/dead timers, and authentication type.
tap to reveal
What is the default OSPF Hello interval on a broadcast link?
10 seconds (dead interval is 40 seconds, 4x hello).
tap to reveal
Why is OSPF Area 0 special?
It is the mandatory backbone area - every other area must connect to it directly or via a virtual link.
tap to reveal
What is router-on-a-stick and what must each sub-interface have?
Using one physical interface with multiple VLAN sub-interfaces for inter-VLAN routing; each sub-interface needs encapsulation dot1Q <vlan-id>.
tap to reveal
What is an SVI and why is it preferred over router-on-a-stick?
A Switched Virtual Interface on a Layer 3 switch (interface vlan X) - preferred because it is not bandwidth-limited by a single trunk link.
tap to reveal
What happens if a packet has no matching route and no default route exists?
The router drops the packet and should send back an ICMP destination unreachable message.
tap to reveal
How is OSPF cost calculated?
Reference bandwidth divided by interface bandwidth - lower cost is more preferred.
tap to reveal