IP Technology Basics · Topic 3 of 5
IP Routing, Direct and Static Routes
Learn the Huawei routing table, route preference values, longest match, direct and static routes, default, floating and summary routes for HCIA-Datacom.
- 6 min
- Default preferences: Direct 0, OSPF 10, Static 60, RIP 100, OSPF ASE 150, BGP 255.
- Longest match decides forwarding, preference decides between sources, cost decides inside one protocol.
- A direct route needs an IP address and an interface that is up at both the physical and protocol layer.
What it is
IP routing is how a router chooses where to send a packet. It looks up the destination address in its routing table and forwards the packet out of the matching interface toward the next hop.
Routes come from three sources: direct routes (networks on the router's own interfaces), static routes (typed by an administrator) and dynamic routes (learned by a protocol such as OSPF).
How it works
Reading the routing table
<Huawei> display ip routing-table
Route Flags: R - relay, D - download to fib
------------------------------------------------------------------------------
Routing Tables: Public
Destinations : 5 Routes : 5
Destination/Mask Proto Pre Cost Flags NextHop Interface
0.0.0.0/0 Static 60 0 RD 10.0.12.2 GigabitEthernet0/0/0
10.0.12.0/24 Direct 0 0 D 10.0.12.1 GigabitEthernet0/0/0
10.0.12.1/32 Direct 0 0 D 127.0.0.1 GigabitEthernet0/0/0
127.0.0.0/8 Direct 0 0 D 127.0.0.1 InLoopBack0
192.168.2.0/24 OSPF 10 2 D 10.0.12.2 GigabitEthernet0/0/0
| Column | Meaning |
|---|---|
| Destination/Mask | The destination network and prefix length |
| Proto | Where the route came from |
| Pre | Preference of the source, lower wins |
| Cost | Metric inside one protocol, lower wins |
| Flags | R means the next hop is resolved through another route, D means installed in the FIB |
| NextHop, Interface | Where the packet goes next |
How the best route is chosen
The router uses three rules, in this order of purpose:
- Longest match at forwarding time. Of all routes that contain the destination, the one with the longest mask is used.
- Preference when several sources offer the same prefix. The lowest value is installed.
- Cost when one protocol has several paths to the same prefix. The lowest cost wins, and equal costs give load balancing.
| Route source | Default preference on Huawei |
|---|---|
| Direct | 0 |
| OSPF (internal) | 10 |
| IS-IS | 15 |
| Static | 60 |
| RIP | 100 |
| OSPF ASE and OSPF NSSA (external) | 150 |
| IBGP and EBGP | 255 |
Huawei preference is the equivalent of what other vendors call administrative distance, but the values differ. A static route (60) beats a RIP route (100) but loses to an internal OSPF route (10).
Direct routes
A direct route appears automatically when an interface has an IP address and both its physical and protocol states are up. If the interface goes down, the route disappears. The router also installs a /32 host route for its own interface address with next hop 127.0.0.1.
Static routes
[Huawei] ip route-static 192.168.2.0 255.255.255.0 10.0.12.2
[Huawei] ip route-static 192.168.3.0 24 GigabitEthernet0/0/1 10.0.13.3
The mask may be dotted or a length. On a point to point link such as a PPP serial interface, the outbound interface alone is enough. On Ethernet, which is a broadcast network, give the next hop address, because the router must know whose MAC address to resolve.
Static routes are simple and use no bandwidth, but they do not react to topology changes. They suit small networks, stub sites and default routes.
Advanced routing features
| Feature | How it is built | Why |
|---|---|---|
| Default route | ip route-static 0.0.0.0 0 10.0.12.2 | Matches every destination with no better route, prefix length 0 |
| Equal cost load balancing | Two static routes to the same prefix, same preference, different next hops | Traffic is shared across both links |
| Floating static route | A second static route with a higher preference value | Backup path, installed only when the main route is gone |
| Summary route | One route covering several contiguous networks | Smaller tables, for example 192.168.0.0/22 for 192.168.0.0 to 192.168.3.0 /24 |
| Route recursion | A next hop that is not directly connected | The router resolves it through another route, shown with the R flag |
A floating backup looks like this:
[Huawei] ip route-static 192.168.2.0 24 10.0.12.2
[Huawei] ip route-static 192.168.2.0 24 10.0.13.3 preference 70
Only the route with preference 60 appears in the routing table. If GigabitEthernet0/0/0 fails, its direct route and the static route through 10.0.12.2 disappear, and the preference 70 route takes over.
A worked example
R1 has routes 10.1.0.0/16 by OSPF, 10.1.1.0/24 by static route and 0.0.0.0/0 by static route. A packet arrives for 10.1.1.20.
All three routes contain the address, but 10.1.1.0/24 has the longest mask, so the static route is used. A packet for 10.1.9.9 uses the /16 OSPF route, and a packet for 8.8.8.8 uses the default route.
How the exam asks about this
- "Which route source has the default preference 60 on a Huawei router?" → Static routes.
- "A router learns 10.0.0.0/8 from OSPF and 10.1.0.0/16 from a static route. Which one forwards a packet to 10.1.2.3?" → The static route, because longest match decides forwarding.
- "How do you make a static route a backup for another route to the same network?" → Give it a larger preference value, such as
preference 70.
What to remember for the exam
- Default preferences: Direct 0, OSPF 10, Static 60, RIP 100, OSPF ASE 150, BGP 255.
- Longest match decides forwarding, preference decides between sources, cost decides inside one protocol.
- A direct route needs an IP address and an interface that is up at both the physical and protocol layer.
- On Ethernet, a static route should name the next hop IP address.
- A floating static route has a higher preference value and stays out of the table until the main route fails.
A lower preference value is better. Raising the preference number makes a route less preferred, not more.
Common mistakes
Comparing preference across different prefixes. Preference only breaks ties for the same destination and mask. 10.1.1.0/24 and 10.1.0.0/16 are different routes, and longest match picks between them.
Using Cisco administrative distances. Huawei static routes are 60, not 1, and OSPF is 10, not 110. Questions about Huawei devices expect Huawei values.
Expecting static routes to fail over by themselves. A static route is removed only when its next hop becomes unreachable or the outbound interface goes down. A failure further along the path is not detected.
Check yourself
What does the R flag in
display ip routing-tablemean?The route is a relay route whose next hop was resolved through another route (recursion).
Which command adds a default route toward next hop 10.0.12.2?
ip route-static 0.0.0.0 0 10.0.12.2, entered in the system view.Two static routes to 192.168.5.0/24 have the same preference and different next hops. What happens?
Both are installed and the router load balances traffic across the two next hops.
Topic 3 of 5 in IP Technology Basics
Test yourself on IP Technology Basics
The full Huawei HCIA-Datacom H12-811 question bank has 600 questions, with timed practice exams and an explanation for every answer.
This study guide is independent and is not affiliated with, endorsed by, or sponsored by Huawei. Vendor names, certification names and exam codes are trademarks of their respective owners and are used for identification only.