Routing Basics and Longest Prefix Match
Key Takeaways
- Hosts send traffic directly only when the destination is in the same local subnet; otherwise they use a default gateway.
- Routers choose routes using the routing table, longest prefix match, administrative distance, and metric concepts.
- Longest prefix match means the most specific matching route wins.
- A default route is the least specific route and is used only when no more specific route matches.
- Network+ routing questions often require checking subnet membership, gateway reachability, route specificity, and missing return paths.
Routing moves packets between IP networks. A host first decides whether the destination is local. If local, it sends directly on the LAN. If remote, it sends the packet to its default gateway.
| Concept | Meaning | Exam clue |
|---|---|---|
| Default gateway | Router used for off-subnet destinations | Host cannot reach other networks |
| Routing table | List of known destination prefixes and next hops | Route lookup question |
| Static route | Manually configured route | Small network or specific path |
| Dynamic route | Learned through routing protocol | OSPF, BGP, EIGRP, RIP context |
| Metric | Preference within a routing protocol | Lower cost or better path |
| Administrative distance | Trust ranking between route sources | Static vs dynamic source comparison |
| Default route | 0.0.0.0/0 or ::/0 | Route of last resort |
Local or Remote Decision
A host uses its own IP address and mask to decide whether a destination is in the same subnet.
| Host | Destination | Decision |
|---|---|---|
| 192.168.10.25/24 | 192.168.10.80 | Local delivery |
| 192.168.10.25/24 | 192.168.11.80 | Send to default gateway |
| 10.1.5.130/25 | 10.1.5.20 | Send to default gateway because they are different /25 subnets |
| 2001:db8:10::25/64 | 2001:db8:10::80 | Same /64 by prefix |
Longest Prefix Match
Routers choose the most specific matching route. Specific means the route has the longest prefix length. A /24 is more specific than a /16. A /32 host route is more specific than both.
| Route in table | Matches 10.1.2.55? | Specificity |
|---|---|---|
| 0.0.0.0/0 | Yes | Least specific |
| 10.0.0.0/8 | Yes | Broad |
| 10.1.0.0/16 | Yes | More specific |
| 10.1.2.0/24 | Yes | Most specific in this list |
| 10.1.3.0/24 | No | Different subnet |
If all listed routes are available, traffic to 10.1.2.55 uses 10.1.2.0/24 because it is the longest matching prefix. The default route is used only if no specific route matches.
Routing Troubleshooting
| Symptom | Check |
|---|---|
| Host reaches local subnet but not internet | Default gateway, gateway reachability, NAT, upstream route |
| One subnet reaches another, but replies fail | Return route, firewall state, asymmetric path |
| Traffic takes unexpected path | More specific route, metric, policy routing |
| VPN tunnel is up but app fails | Local route, remote route, firewall, overlapping CIDR |
| Cloud peering exists but no traffic | Route tables and security filters on both sides |
PBQ-Style Thinking
Scenario: A router has routes for 10.0.0.0/8 through Router A, 10.2.0.0/16 through Router B, and 10.2.5.0/24 through Router C. A packet to 10.2.5.99 goes to Router C. A packet to 10.2.9.99 goes to Router B. A packet to 10.9.9.9 goes to Router A. This is longest prefix match in action.
Scenario: A branch subnet 192.168.40.0/24 can initiate traffic to a data center, but data center servers cannot reply. The branch route exists on the branch edge, but the data center core lacks a route back to 192.168.40.0/24. Add or advertise the return route and check firewalls.
Routing Protocol Context
Network+ expects conceptual recognition, not advanced vendor configuration.
| Protocol | High-level idea |
|---|---|
| OSPF | Interior gateway protocol using link-state concepts and cost |
| BGP | Exterior gateway protocol used between autonomous systems and large routing domains |
| RIP | Older distance-vector protocol with hop count limits |
| EIGRP | Advanced distance-vector protocol associated with Cisco environments |
| Static routing | Manual route entries, predictable but less scalable |
Route choice can involve route specificity, administrative distance, and metrics. Longest prefix match is the core concept: first find the most specific matching destination prefix, then use tie-breakers when needed.
A router has matching routes 10.0.0.0/8, 10.1.0.0/16, and 10.1.2.0/24 for destination 10.1.2.55. Which route is selected?
A host can reach devices in its own subnet but cannot reach any remote networks. Which setting should be checked first?
Which routes are default routes? Choose two.
Select all that apply