PracticeBlogFlashcardsEspañol

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.
Last updated: April 2026

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.

ConceptMeaningExam clue
Default gatewayRouter used for off-subnet destinationsHost cannot reach other networks
Routing tableList of known destination prefixes and next hopsRoute lookup question
Static routeManually configured routeSmall network or specific path
Dynamic routeLearned through routing protocolOSPF, BGP, EIGRP, RIP context
MetricPreference within a routing protocolLower cost or better path
Administrative distanceTrust ranking between route sourcesStatic vs dynamic source comparison
Default route0.0.0.0/0 or ::/0Route 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.

HostDestinationDecision
192.168.10.25/24192.168.10.80Local delivery
192.168.10.25/24192.168.11.80Send to default gateway
10.1.5.130/2510.1.5.20Send to default gateway because they are different /25 subnets
2001:db8:10::25/642001:db8:10::80Same /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 tableMatches 10.1.2.55?Specificity
0.0.0.0/0YesLeast specific
10.0.0.0/8YesBroad
10.1.0.0/16YesMore specific
10.1.2.0/24YesMost specific in this list
10.1.3.0/24NoDifferent 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

SymptomCheck
Host reaches local subnet but not internetDefault gateway, gateway reachability, NAT, upstream route
One subnet reaches another, but replies failReturn route, firewall state, asymmetric path
Traffic takes unexpected pathMore specific route, metric, policy routing
VPN tunnel is up but app failsLocal route, remote route, firewall, overlapping CIDR
Cloud peering exists but no trafficRoute 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.

ProtocolHigh-level idea
OSPFInterior gateway protocol using link-state concepts and cost
BGPExterior gateway protocol used between autonomous systems and large routing domains
RIPOlder distance-vector protocol with hop count limits
EIGRPAdvanced distance-vector protocol associated with Cisco environments
Static routingManual 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.

Test Your Knowledge

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
B
C
D
Test Your Knowledge

A host can reach devices in its own subnet but cannot reach any remote networks. Which setting should be checked first?

A
B
C
D
Test Your KnowledgeMulti-Select

Which routes are default routes? Choose two.

Select all that apply

0.0.0.0/0
::/0
192.168.1.0/24
10.1.2.3/32