Study guide
Route Preference and Longest Match
Huawei Certified ICT Associate - Datacom HCIA-Datacom H12-811 V1.0
Track your progress as you read
Finished sections get a check mark.
1 Introduction
About HCIA-Datacom H12-811 V1.0 Study Strategies and Exam Logistics
2 Chapter 1: Network Models and Ethernet Fundamentals
OSI and TCP/IP Models Ethernet Technology and MAC Addressing Data Forwarding and Campus Network Lifecycle
3 Chapter 2: IPv4 Addressing and Transport Protocols
IPv4 Addressing and Subnetting ARP and ICMP TCP and UDP Principles Common Ports and Application Protocols
4 Chapter 3: Huawei VRP Basics and Device Management
VRP CLI Views and Core Commands Configuration Save, Reset, and File System SSH, Telnet, and Console Access Display Commands and Basic Troubleshooting
5 Chapter 4: Ethernet Switching and VLANs
Switch Forwarding and MAC Address Tables VLAN Concepts and Segmentation Access, Trunk, and Hybrid Link Types VLANIF and Inter-VLAN Routing
6 Chapter 5: STP, RSTP/MSTP, and Link Aggregation
STP Concepts and Election RSTP and MSTP Eth-Trunk Static and LACP Stacking Basics for Campus Switches
7 Chapter 6: IP Routing Fundamentals
RIB, FIB, and Forwarding Decisions Static and Default Routes on VRP Route Preference and Longest Match Floating Static Routes and Blackhole Routes
8 Chapter 7: OSPF Fundamentals
OSPF Areas and Router Types Neighbor States and Adjacency LSA Types and LSDB DR/BDR Election and VRP OSPF Configuration
9 Chapter 8: ACLs and AAA
Basic and Advanced ACLs traffic-filter Application and Matching Order AAA with Local, RADIUS, and HWTACACS
10 Chapter 9: DHCP, NAT, and Network Services
DHCP Server, Relay, and Snooping NAT, Easy IP, and NAT Server FTP, TFTP, DNS, NTP, HTTP Basics
11 Chapter 10: WLAN Basics
WLAN Architecture: AC, AP, and Fit Mode CAPWAP Tunnels and Forwarding Modes WPA2, WPA3, and WLAN Security Basics Basic WLAN Configuration Concepts
12 Chapter 11: WAN Basics
WAN Concepts and Encapsulation PPP Authentication: PAP and CHAP PPPoE Basics and Client Configuration
13 Chapter 12: IPv6 Fundamentals
IPv6 Address Types and Format Neighbor Discovery and ICMPv6 Stateful and Stateless DHCPv6 IPv6 Static Routes on VRP
14 Chapter 13: SDN and NFV Fundamentals
SDN and NFV Fundamentals
15 Chapter 14: Network Management and O&M
Network Management, O&M, and Automation Basics
Route Preference and Longest Match
Key Takeaways Explain This Topic AI
Huawei preference is the trust ranking of a route’s source: lower preference is better and wins among routes to the same prefix.
Common default preferences: Direct 0, OSPF 10, Static 60, RIP 100, OSPF ASE 150, IBGP 255—memorize these for H12-811.
Longest-prefix match always runs first; preference never overrides a more specific destination mask.
Within the same protocol source, cost/metric selects among equal-preference candidates; do not confuse cost with preference.
You can set a custom preference on a static route to make it primary or backup relative to another static or to interact deliberately with dynamic routing designs.
Last updated: July 2026
Two different questions the router must answer
Students often mash selection rules into one vague idea of “best route.” HCIA scores higher when you split the problem:
- Which prefix matches this destination IP? → Longest-prefix match
- Which source’s route for that prefix should we trust? → Preference (Pre)
- Which of the remaining equal candidates is best? → Cost/metric (and platform tie-breakers)
This section drills preference tables and the interaction with longest match until the order is automatic under exam pressure.
Longest-prefix match (again, because items keep testing it)
Given destination IP D , collect all routes whose network address and mask cover D . Choose the route with the largest mask length (most specific). That route’s next hop is used regardless of whether another covering prefix has a “better” preference number.
- Destination IP Candidate A Candidate B Winner
- 10.1.1.8 10.1.1.0/24 Pre 60 10.0.0.0/8 Pre 10 /24
- 10.2.0.5 10.2.0.0/16 Pre 60 0.0.0.0/0 Pre 60 /16
- 203.0.113.9 203.0.113.0/24 Pre 60 0.0.0.0/0 Pre 10 (OSPF default style) /24 if present
- 198.51.100.2 only 0.0.0.0/0 — Default
Summarization intentionally installs shorter prefixes. That is useful for scaling, but it also means a stray more-specific route elsewhere can steal traffic for a subset of the summary. Operators use that on purpose (traffic engineering) or hit it by accident (asymmetric leaks).
Huawei preference: lower wins
Preference on Huawei VRP is the analog of Cisco administrative distance . It expresses how much the router trusts the protocol source of a route to a given prefix.
- Rule Statement
- Direction Smaller preference value = more preferred
- Scope Compared for the same destination prefix (same mask)
- Not A global “always prefer OSPF over any static anywhere” regardless of mask
If two routes both offer exactly 192.168.1.0/24 , Pre 10 beats Pre 60. If one offers /24 and one offers /16 , longest match already picked the /24 before preference compared them as peers.
Default preference values to memorize for HCIA
Huawei training materials emphasize this common set (values you should know cold):
- Protocol / source Default preference Trust level (conceptual)
- Direct 0 Highest—on-link
- OSPF 10 Highly trusted IGP
- Static 60 Manual; medium trust
- RIP 100 Less trusted than OSPF/static defaults
- OSPF ASE (external) 150 OSPF external routes less trusted than internal OSPF
- IBGP 255 Least trusted in this list
Notes that keep you out of trouble:
Direct 0 explains why you cannot casually “override” a connected network with a normal static without unusual design—connected wins on the same prefix length at Pre 0.
OSPF 10 vs Static 60 means that if OSPF and static both install the same prefix, OSPF wins by default . To force a static to win, raise OSPF’s effective competitiveness (not typical at HCIA) or lower the static’s preference below 10 (for example preference 5)—a deliberate design choice.
OSPF ASE 150 reminds you that not all OSPF-looking routes share preference 10 . Externals are different.
IBGP 255 is nearly “last resort” among the listed sources; enterprise exit selection often depends on policy beyond HCIA depth, but the number appears in preference tables.
Different Huawei documents may list additional protocol preferences (EBGP, other IGPs). For H12-811, nail the common table above first.
Seeing preference in the CLI <Huawei> display ip routing-table
Locate the Pre column. Compare only among rows that share the same Destination/Mask . Then look at Cost for metric within that selection context. <Huawei> display ip routing-table protocol static
<Huawei> display ip routing-table protocol ospf
Protocol filters help you see candidates that lost selection (depending on platform display behavior for inactive routes). Even when only active routes show, knowing defaults lets you predict winners before lab verification.
Cost is not preference
- Attribute Answers Example
- Preference (Pre) Which source is trusted more? Static 60 vs OSPF 10
- Cost Which path is better within comparable selection? OSPF cost 5 vs cost 20
Two OSPF routes to the same /24 both have Pre 10; the lower OSPF cost wins (or ECMP if costs equal and multipath allowed). A static with Pre 60 does not “use cost 0 to beat OSPF”—preference already eliminated it if OSPF offers the same prefix at Pre 10.
Exam trap wording: “lowest cost always wins.” False if preference differs or if longest match already chose another prefix.
Customizing static preference
Static routes accept an explicit preference: [Huawei] ip route-static 192.168.80.0 255.255.255.0 10.1.1.2 preference 40
[Huawei] ip route-static 192.168.80.0 255.255.255.0 10.1.1.6 preference 80
- Static Pre Role
- Via 10.1.1.2 40 Primary (lower Pre)
- Via 10.1.1.6 80 Backup floating static
Both lines can exist in configuration; only the best preference for that prefix is selected for active use (assuming next hops resolve). When the primary next hop fails, the backup can install. That is the core of floating static routes detailed in the next section.
To make a static beat OSPF for the same prefix (rare but taught for understanding): [Huawei] ip route-static 192.168.80.0 255.255.255.0 10.1.1.2 preference 5
Pre 5 is better than OSPF’s 10 → static wins for that identical prefix. Production designs must consider what happens when you hide OSPF’s path this way—often you only do it for carefully controlled exceptions.
- Worked scenarios (train like the exam)
- Scenario A — Same prefix, different sources
Table offers:
- 10.10.10.0/24 OSPF Pre 10 Cost 15 NextHop A
- 10.10.10.0/24 Static Pre 60 Cost 0 NextHop B
Active path: OSPF via A. Static remains configuration backup only if it cannot win (or may show as inactive depending on display). Traffic uses A.
- Scenario B — Different prefixes
- 10.10.10.0/24 Static Pre 60 via B
- 10.10.0.0/16 OSPF Pre 10 via A
Packet to 10.10.10.5 → static /24 via B (longest match). Packet to 10.10.20.5 → OSPF /16 via A .
- Scenario C — Default vs specific
- 0.0.0.0/0 Static Pre 60 via edge
- 172.16.0.0/16 OSPF Pre 10 via core
Packet to 172.16.5.5 → OSPF /16. Packet to 8.8.8.8 → default static (if no more specific ISP routes).
Scenario D — OSPF internal vs ASE (conceptual)
If an internal OSPF route (Pre 10) and an OSPF external (ASE Pre 150) both somehow target the same prefix length, internal preference wins . Exact external origination is deeper OSPF content; the preference numbers still matter when reading tables.
- Decision flowchart you can redraw from memory Packet destination D
- |
- v
- Find all covering prefixes in routing table
- |
- v
- Pick longest mask ---------------------> use that prefix
- |
- v
Multiple routes for THAT prefix?
- no -> use the only route
- yes -> lowest Preference wins
- |
- v
- still tied? -> lowest Cost / multipath rules
- |
- v
- Resolve next hop / ARP / forward
If you can reproduce this flowchart, preference trick questions lose their power.
Preference direction: Huawei vs “higher is better” myths
Some tools and human conversations say “higher priority.” On Huawei preference , lower numeric value wins . Floating static backups use higher preference values (worse trust) so they stay standby. If you reverse this—setting backup to preference 10 and primary to 100—you invert production traffic. The next section builds entirely on that directionality.
Compare with cost: lower cost is also better, but cost is not preference. Two numbers, two meanings, same “lower is better” direction for both—yet they apply at different steps.
Practical verification checklist
Identify destination IP in the question.
List matching prefixes and masks .
Circle the longest mask.
If multiple sources for that mask, compare Pre (defaults if not stated).
If still tied, compare Cost .
Read next hop/interface; sanity-check reachability.
Exam traps
Reversing preference direction (thinking 60 beats 10).
Using preference to override a longer prefix.
Mixing OSPF 10 with OSPF ASE 150 as if identical.
Assuming static always wins because “admin configured it.”
Forgetting Direct 0 beats essentially everything on the same prefix.
Comparing cost across different protocols as if preference did not exist.
What mastery looks like
You glance at a three-row routing table excerpt and immediately say which row forwards a given packet—and you can explain the losing rows without hand-waving. That skill transfers directly to OSPF troubleshooting and to floating static design next.