Route Selection Practice: Longest Prefix, AD and Metric
Practise how a router picks a route: longest prefix first, then administrative distance, then metric. Each problem is a new routing table and packet, in Cisco IOS or Junos format, and Check my answer names the slip.
Tap the route R1 uses.
Every route R1 has learned, before it installs one per prefix. [AD/metric] follows each prefix. Codes: C connected, L local, S static, D EIGRP, D EX external EIGRP, O OSPF, O IA OSPF inter area, R RIP, B BGP, * default.
Every route R1 has learned. [protocol/preference] follows each prefix, and a lower preference wins. Route ages and the active route marker are left out.
Practise the exams
Routing table questions show up in CCNA, ENARSI and JNCIA-Junos. Start with the free real exam questions, then get the full pack.
Route selection FAQ
Does a lower administrative distance beat a longer prefix?
No. Administrative distance only decides which route is installed when several sources offer the same prefix. When a packet is forwarded, the longest matching prefix wins among the installed routes, so AD never overrides it. Cisco's example: with D 192.168.32.0/26, R 192.168.32.0/24 and O 192.168.32.0/19 installed, a packet to 192.168.32.1 uses the /26 and a packet to 192.168.32.100 uses the /24.
What are the default administrative distances on a Cisco router?
Connected 0, static 1, EIGRP summary route 5, external BGP 20, internal EIGRP 90, IGRP 100, OSPF 110, IS-IS 115, RIP 120, EGP 140, ODR 160, external EIGRP 170, internal BGP 200 and unknown 255. A route with AD 255 is not installed. Lower is preferred.
What are the default route preferences in Junos?
Directly connected 0, static 5, OSPF internal 10, IS-IS level 1 internal 15, IS-IS level 2 internal 18, RIP 100, aggregate 130, OSPF AS external 150 and BGP 170, among others. Junos calls administrative distance the route preference, and the lowest value becomes the active route.
When does the metric decide?
Only between paths from the same routing protocol to the same prefix. Each protocol uses its own metric, so an OSPF cost and a RIP hop count are never compared: AD decides between protocols. Within one protocol the lowest metric wins, and equal metrics share the traffic. The drill never shows an equal-cost tie.
When does a router use the default route?
Only when no more specific route matches. 0.0.0.0/0 matches every address, but its prefix length is 0, so any other match is longer. With no match and no default route, the packet is dropped. The drill assumes ip classless, where a router simply uses the longest match it can find.
How do I read [110/20] in show ip route?
The first number is the administrative distance and the second is the metric, so [110/20] is OSPF (AD 110) with a metric of 20. The letter in front is the route source: C connected, L local, S static, D EIGRP, D EX external EIGRP, O OSPF, O IA OSPF inter area, R RIP and B BGP; an asterisk marks a candidate default route.
Why does the drill show two routes for the same prefix?
It lists every route R1 has learned, so you can do the AD and metric steps yourself. On a Cisco router, show ip route only lists the route that won for each prefix. Junos show route lists every route and marks the active one with + or *, which the drill hides.
Which exam topics does this cover?
CCNA 200-301 v2.0 topic 3.1, "Interpret a routing table to identify the next hop for a packet (routing protocol, prefix/mask, administrative distance, metric, and default route)", and v1.1 topic 3.2, longest prefix match, administrative distance and routing protocol metric. ENARSI 300-410 topic 1.1 is troubleshooting administrative distance, and JNCIA-Junos covers routing tables, routing versus forwarding tables and route preference.
Sources
- Cisco, Configure Route Selection for Routers (document 8651): AD when routes are installed, the lowest metric within one protocol, equal metrics load balanced, longer prefixes always preferred when forwarding, the ip classless example.
- Cisco, Understand Administrative Distance (document 15986, updated 20 July 2026): the default AD table, [administrative distance/metric] in show ip route, the route codes, and that AD does not override longest prefix match.
- Juniper (HPE Networking documentation), Understanding Route Preference Values (Administrative Distance) and Route Preferences Overview: the default preference table and active route selection.
- Juniper, show route and show route protocol command references: the output format, including [protocol, preference] and "a lesser value is preferred" for every metric except BGP LocalPref.
- IETF, RFC 1812, Requirements for IP Version 4 Routers, section 5.2.4.3: Basic Match and Longest Match.
- Cisco exam topics: CCNA 200-301 v2.0 (3.1), CCNA 200-301 v1.1 (3.2) and ENARSI 300-410 v1.1 (1.1). Juniper, JNCIA-Junos exam objectives (Routing Fundamentals).
- Checked 20 November 2026: the drill reproduces the worked examples in Cisco documents 8651 and 15986 and in RFC 1812, and every generated problem has exactly one right answer under these rules. The 6-route tables, next hops and metrics are made up for practice.
Checked 20 November 2026 against Cisco and Juniper documentation and RFC 1812.
- DrillOSPF practicePick the DR and BDR, find the router ID and work out the lowest cost path.
- DrillJunos routing policy and firewall filter practiceRoute-filter match types, policy chains and firewall filter terms.
- DrillCisco ACL practiceFind the line a packet matches and write standard and extended ACLs.