09 IP Routing Basics
09 IP Routing Basics
Record
Course Code Product Product Version Course Version
Page 0 Copyright © 2020 Huawei Technologies Co., Ltd. All rights reserved.
IP Routing Basics
Page 1 Copyright © 2020 Huawei Technologies Co., Ltd. All rights reserved.
Foreword
● There are typically multiple IP subnets on a typical data communication network. Layer
3 devices are required to exchange data between these IP subnets. These devices
have the routing capability and can forward data across subnets.
● Routing is the basic element of data communication networks. It is the process of
selecting paths on a network along which packets are sent from a source to a
destination.
● This course introduces the basic concepts of routing.
Page 2 Copyright © 2020 Huawei Technologies Co., Ltd. All rights reserved.
Objectives
● On completion of this course, you will be able to:
Understand the basic principles of routers.
Page 3 Copyright © 2020 Huawei Technologies Co., Ltd. All rights reserved.
Contents
1. Overview of IP Routing
▪ Basic Concepts of Routing
▫ Route-based Forwarding
3. Static Routing
4. Dynamic Routing
5. Advanced Routing Features
Page 4 Copyright © 2020 Huawei Technologies Co., Ltd. All rights reserved.
Background: Inter-Subnet Communication
Page 5 Copyright © 2020 Huawei Technologies Co., Ltd. All rights reserved.
Routes
● Routes are the path information used to guide packet forwarding.
● A routing device is a network device that forwards packets to a destination subnet based on routes. The most common
routing device is a router.
Router R4
Data R1 R2 R3
N M
Gateway Gateway
Destination-based forwarding
Page 6 Copyright © 2020 Huawei Technologies Co., Ltd. All rights reserved.
Routing Information
Outbound
subnet.
Destination/Mask Next Hop
Interface
● The information identifies the destination subnet and
[Link]/24 GE0/0/0 [Link]
specifies the path for forwarding data packets.
Page 7 Copyright © 2020 Huawei Technologies Co., Ltd. All rights reserved.
IP Routing Table
[Link]/8 Outbound
Destination/Mask Next Hop
Interface
R4 • Routers discover routes using multiple
[Link]/8 [Link] GE0/0 methods.
[Link]/30
[Link]/8 [Link] GE0/1
[Link]/8 [Link] GE0/2 • A router selects the optimal route and installs
… it in its IP routing table.
GE0/2
[Link]/30 [Link] GE0/2
[Link]/30 • The router forwards IP packets based on
[Link]/32 [Link] GE0/2
GE0/0 GE0/1 routes in the IP routing table.
[Link]/30 R2 [Link]/30
• Routers manage path information by
managing their IP routing tables.
[Link]/30 [Link]/30
R1 R3
[Link]/8 [Link]/8
Page 8 Copyright © 2020 Huawei Technologies Co., Ltd. All rights reserved.
Contents
1. Overview of IP Routing
▫ Basic Concepts of Routing
▫ Route-based Forwarding
3. Static Routing
4. Dynamic Routing
5. Advanced Routing Features
Page 9 Copyright © 2020 Huawei Technologies Co., Ltd. All rights reserved.
How to Obtain Routing Information
• A router forwards packets based on its IP routing table. To implement route-based packet forwarding, the router
needs to obtain routes. The following describes the common methods of obtaining routes.
GE0/0/0
[Link]/24 [Link]/24
GE0/0/1
[Link]/24
GE0/0/1
Dynamic routing
protocol
GE0/0/2 OSPF
Outbound
Protocol Destination/Mask
Interface Outbound Outbound
Protocol Destination/Mask Protocol Destination/Mask
Direct [Link]/24 GE0/0/0 Interface Interface
Direct [Link]/24 GE0/0/1 Static [Link]/24 GE0/0/1 OSPF [Link]/24 GE0/0/2
Page 10 Copyright © 2020 Huawei Technologies Co., Ltd. All rights reserved.
Direct Routes (1)
Direct Routes
• A direct route is automatically generated by a
device and points to a local directly-connected
network.
GE0/0/0
[Link]/24 • When a router is the last hop router, IP packets to
[Link]/24 [Link]/24
GE0/0/1
RT [Link]/24 be forwarded will match a direct route and the
B
router will directly forward the IP packet to the
destination host.
Direct routes in the IP routing table of RTB • When a direct route is used for packet forwarding,
Destination/M Outbound the destination IP address of a packet to be
Protocol Next Hop
ask Interface
forwarded and the IP address of the router‘s
[Link]/24 Direct [Link] GE0/0/0
outbound interface are in the same subnet.
[Link]/24 Direct [Link] GE0/0/1
Page 11 Copyright © 2020 Huawei Technologies Co., Ltd. All rights reserved.
Direct Routes (2)
Direct routes
GE0/0/0 GE0/0/1
[Link]/24 [Link]/24 • Not all the direct routes generated for interfaces are
GE0/0/0 GE0/0/1 installed in the IP routing table. Only the direct
RT [Link]/24 RT [Link]/24 RT
A B C routes of which the physical status and protocol
status of interfaces are up are installed in the IP
routing table.
Direct routes in the IP routing table of RTB
Outbound
Destination/Mask Protocol Next Hop
Interface
[Link]/24 Direct [Link] G0/0/1
• When GE0/0/0 goes down, the direct route for this interface is not
installed in the IP routing table.
Page 12 Copyright © 2020 Huawei Technologies Co., Ltd. All rights reserved.
Contents
1. Overview of IP Routing
▫ Basic Concepts of Routing
▫ Route-based Forwarding
3. Static Routing
4. Dynamic Routing
5. Advanced Routing Features
Page 13 Copyright © 2020 Huawei Technologies Co., Ltd. All rights reserved.
Examining the IP Routing Table
<Quidway> display ip routing-table
Route Flags: R - relay, D - download to fib
------------------------------------------------------------------------------------------------------Routing
Tables: Public
Destinations : 6 Routes : 6
Page 14 Copyright © 2020 Huawei Technologies Co., Ltd. All rights reserved.
Fields in the IP Routing Table
● Destination/Mask: indicates the destination network address and mask of a specific route. The subnet address of a
destination host or router is obtained through the AND operation on the destination address and mask. For example, if
the destination address is [Link] and the mask is [Link], the IP address of the subnet to which the host or
router belongs is [Link].
● Proto (Protocol): indicates the protocol type of the route, that is, the protocol through which a router learns the route.
● Pre (Preference): indicates the routing protocol preference of the route. There may be multiple routes to the same
destination, which have different next hops and outbound interfaces. These routes may be discovered by different
routing protocols or be manually configured. A router selects the route with the highest preference (with the lowest
preference value) as the optimal route.
● Cost: indicates the cost of the route. When multiple routes to the same destination have the same preference, the route
with the lowest cost is selected as the optimal route.
● NextHop: indicates the local router’s next-hop address of the route to the destination network. This field specifies the
next-hop device to which packets are forwarded.
● Interface: indicates the outbound interface of the route. This field specifies the local interface through which the local
router forwards packets.
Page 15 Copyright © 2020 Huawei Technologies Co., Ltd. All rights reserved.
Route Preference - Basic Concepts
Comparing Route Preferences • When a router obtains routes to the same destination
subnet from different routing protocols (these routes
Routes
have the same destination network address and
mask), the router compares the preferences of these
routes and prefers the route with the lowest
Destination Different Installed in the IP
subnet/mask routing table
preference value.
Same
• A lower preference value indicates a higher
preference.
Higher Preference
Preference • The route with the highest preference is installed in
the IP routing table.
Page 16 Copyright © 2020 Huawei Technologies Co., Ltd. All rights reserved.
Route Preference - Comparison Process
Comparing Route Preferences
Dynamic routing
protocol [Link]/30 • RTA discovers two routes to [Link]/30, one is an
OSPF
[Link]/30 OSPF route and the other a static route. In this
[Link]/30
case, RTA compares the preferences of the two
RTA routes and selects the route with the lowest
[Link]/30 [Link]/30
preference value.
• Each routing protocol has a unique preference.
Route entries of RTA
• OSPF has a higher preference. Therefore, the
Destination/Mask Protocol Preference Next Hop
OSPF route is installed in the IP routing table.
[Link]/30 Static 60 [Link] Installed in
the IP
[Link]/30 OSPF 10 [Link] routing
table
Page 17 Copyright © 2020 Huawei Technologies Co., Ltd. All rights reserved.
Metric - Comparison Process
Metric comparison
• RTA learns two routes with the same destination
Dynamic routing
protocol [Link]/30 address ([Link]/30) and preference through
OSPF
Cost=10 Cost=10 [Link]/30 OSPF. In this case, RTA needs to compare the
[Link]/30
Cost=10 metrics of the two routes.
RTA
[Link]/30 [Link]/30
• The two routes have different metrics. The
OSPF route with the next hop being [Link]
has a lower metric (with the cost 10), so it is
Route entries of RTA
installed in the IP routing table.
Destination/Mask Protocol Cost Next Hop
[Link]/30 OSPF 20 [Link] Installed
in the IP
[Link]/30 OSPF 10 [Link] routing
table
Page 18 Copyright © 2020 Huawei Technologies Co., Ltd. All rights reserved.
Route Preference - Common Default Values
● The following table lists the default preference values of common route types:
Page 19 Copyright © 2020 Huawei Technologies Co., Ltd. All rights reserved.
Metric - Basic Concepts
Comparing Metrics • When a router discovers multiple routes to the
same destination network through the same
Routes
routing protocol, the router selects the optimal
route based on the metrics of these routes if these
Different
Destination/mask
Installed in the routes have the same preference.
IP routing table
• The metric of a route indicates the cost of reaching
Same
the destination address of the route.
Higher preference
Preference
• Common metrics include the hop count,
bandwidth, delay, cost, load, and reliability.
Same
preference • The route with the lowest metric is installed in the
Lower metric IP routing table.
Metric
• The metric is also known as the cost.
Page 20 Copyright © 2020 Huawei Technologies Co., Ltd. All rights reserved.
Contents
1. Overview of IP Routing
▫ Basic Concepts of Routing
▪ Route-based Forwarding
3. Static Routing
4. Dynamic Routing
5. Advanced Routing Features
Page 21 Copyright © 2020 Huawei Technologies Co., Ltd. All rights reserved.
Longest Matching
● When a router receives an IP packet, it compares the destination IP address of the packet with all routing
entries in the local routing table bit by bit until the longest matching entry is found. This is the longest
matching mechanism.
Bit-by-bit matching
Destination IP
172.16.2.
address 172. 16. 00000010 00000001
1
M
is
[Link] m
Routing entry 1 172. 16. 00000001 x x x x x x x axtc
[Link] h
Lo
ng
[Link] e s
Routing entry 2 172. 16. 00000010 x x x x x x xt xma
[Link] tc
h
No
t th
e
[Link] m lo
Routing entry 3 172. 16. xxxxxxxx xxxx x txchx nxges
a
[Link] t
Page 22 Copyright © 2020 Huawei Technologies Co., Ltd. All rights reserved.
Example of Longest Matching (1)
Example of Longest Matching
DATA
longest matching rule, the route with the 24-bit
mask is preferred to guide the forwarding of
[Link]/30 packets destined for [Link].
IP routing table of RTA
Destination/Mask Next Hop
[Link]/16 [Link]
[Link]/24 [Link] Match
[Link]/24 [Link]
Page 23 Copyright © 2020 Huawei Technologies Co., Ltd. All rights reserved.
Example of Longest Matching (2)
Example of Longest Matching
Destination IP [Link]/30
address:
[Link]
RTA
[Link]/30 • According to the longest matching rule, only the route
Data to [Link]/24 in the IP routing table matches the
destination IP address [Link]. Therefore, this
[Link]/30
route is used to forward packets destined for
IP routing table of RTA
Page 24 Copyright © 2020 Huawei Technologies Co., Ltd. All rights reserved.
Route-based Forwarding Process
Outbound
Destination/Mask Next Hop
Interface
Destination [Link]/24 [Link] GE0/0
IP address:
[Link]/24 [Link] GE0/1
[Link]
[Link]/24 [Link] GE0/0
[Link]/24 [Link] GE0/1
IP routing table of R2
Data
Gateway Gateway
GE0/1 GE0/0 GE0/0 GE0/1 GE0/0 GE0/1
[Link]/24 [Link]/24 [Link]/24 [Link]/24
[Link] [Link] [Link] [Link] [Link] [Link]
R1 R2 R3
Page 25 Copyright © 2020 Huawei Technologies Co., Ltd. All rights reserved.
Summary of the IP Routing Table
• When a router obtains routes to the same destination subnet with the same mask from different routing
protocols, the router prefers the route with the lowest preference value of these routing protocols. If these
routes are learned from the same routing protocol, the router prefers the route with the lowest cost. In
summary, only the optimal route is installed in the IP routing table.
• When a router receives a packet, it searches its IP routing table for the outbound interface and next hop
based on the destination IP address of the packet. If it finds a matching routing entry, it forwards the packet
according to the outbound interface and next hop specified by this entry. Otherwise, it discards the packet.
• Packets are forwarded hop by hop. Therefore, all the routers along the path from the source to the
destination must have routes destined for the destination. Otherwise, packet loss occurs.
• Data communication is bidirectional. Therefore, both forward and backward routes must be available.
Page 26 Copyright © 2020 Huawei Technologies Co., Ltd. All rights reserved.
Contents
1. Overview of IP Routing
2. Static Routing
3. Dynamic Routing
4. Advanced Routing Features
Page 27 Copyright © 2020 Huawei Technologies Co., Ltd. All rights reserved.
Application Scenarios of Static Routes
• Static routes are manually configured by network
Static Routes
administrators, have low system requirements, and
apply to simple, stable, and small networks.
Destined for • The disadvantage of static routes is that they cannot
[Link]/24 GE0/0/0 GE0/0/1
[Link]/24 [Link]/24 automatically adapt to network topology changes and
GE0/0/0 GE0/0/1 so require manual intervention.
RT [Link]/24 RT [Link]/24 RT
A B C
• RTA needs to forward the packets with the
destination address [Link]/24. However, the IP
Destination Protocol Next Hop
routing table of RTA has only one direct route, which
[Link] Static [Link]
does not match [Link]/24. In this case, a static
[Link] Direct [Link]
route needs to be manually configured so that the
packets sent from RTA to [Link]/24 can be
forwarded to the next hop [Link].
Page 28 Copyright © 2020 Huawei Technologies Co., Ltd. All rights reserved.
Static Route Configuration
● Specify a next-hop IP address for a static route.
● Specify both the outbound interface and next hop for a static route.
Page 29 Copyright © 2020 Huawei Technologies Co., Ltd. All rights reserved.
Configuration Example
GE0/0/0 S1/0/0
[Link]/24 [Link]/24
GE0/0/0 S1/0/0 Configure RTA.
RT [Link]/24 RT [Link]/24 RT
A B C [RTA] ip route-static [Link] [Link] [Link]
Page 30 Copyright © 2020 Huawei Technologies Co., Ltd. All rights reserved.
Default Routes
• Default routes are used only when packets to be forwarded do not match any routing entry in an IP routing
table.
• In an IP routing table, a default route is the route to network [Link] (with the mask [Link]), namely,
[Link]/0.
RTA needs to forward packets
to a subnet that is not directly
connected to it and forwards
the packets to [Link].
[Link]/24
RT RT [Link]/24
A GE0/0/0 GE0/0/0 B
[Link]/24 [Link]/24
[Link] .
[Link] .
[Link]/24
Page 31 Copyright © 2020 Huawei Technologies Co., Ltd. All rights reserved.
Application Scenarios of Default Routes
● Default routes are typically used at the egress of an enterprise network. For example, you can configure a
default route on an egress device to enable the device to forward IP packets destined for any address on
the Internet.
Enterprise
network RT
A [Link]/24 Internet
GE0/0/1 GE0/0/0 [Link]
PC [Link] [Link]
[Link]
Gateway: [Link]
Page 32 Copyright © 2020 Huawei Technologies Co., Ltd. All rights reserved.
Contents
1. Overview of IP Routing
2. Static Routing
3. Dynamic Routing
4. Advanced Routing Features
Page 33 Copyright © 2020 Huawei Technologies Co., Ltd. All rights reserved.
Overview of Dynamic Routing
Static Routing Dynamic Routing
• To use static routes on • Dynamic routes can be
Static routing any device, you must Dynamic routing automatically discovered
manually configure OSPF and learned.
them. • Dynamic routes can
• Static routes cannot adapt to topology
adapt to link changes. changes.
• When the network scale expands, it becomes increasingly • Dynamic routing protocols automatically discover and
complex to manually configure static routes. In addition, when generate routes, and update routes when the topology
the network topology changes, static routes cannot adapt to changes. These protocols effectively reduce the workload of
these changes in a timely and flexible manner. network administrators and are widely used on large
networks.
Page 34 Copyright © 2020 Huawei Technologies Co., Ltd. All rights reserved.
Classification of Dynamic Routing Protocols
Classification by the application scope
Page 35 Copyright © 2020 Huawei Technologies Co., Ltd. All rights reserved.
Contents
1. Overview of IP Routing
2. Static Routing
3. Dynamic Routing
4. Advanced Routing Features
Page 36 Copyright © 2020 Huawei Technologies Co., Ltd. All rights reserved.
Equal-Cost Route
Route Recursion Floating Route
Route Summarization
Page 37 Copyright © 2020 Huawei Technologies Co., Ltd. All rights reserved.
Equal-Cost Route
Route Recursion Floating Route
Route Summarization
GE0/0/0 GE0/0/1
[Link]/24 [Link]/24
[Link]/24
GE0/0/0 GE0/0/1
RT [Link]/24 RT [Link]/24 RT
A B C
Destination/M Outbound
Next Hop
ask Interface
[RTA] ip route-static [Link] 24 [Link]
Recursio
[Link]/24 [Link] GE0/0/0
n [Link]/24 [Link] GE0/0/0
[RTA] ip route-static [Link] 24 [Link]
Configure a route to [Link], with the next hop pointing to [Link] on the directly connected network.
In this way, RTA can recurse the route with the destination [Link]/24 to the route with the destination
[Link].
Page 38 Copyright © 2020 Huawei Technologies Co., Ltd. All rights reserved.
Equal-Cost Route
Route Recursion Floating Route
Route Summarization
Equal-Cost Route
● When there are equal-cost routes in the IP routing table, a router forwards IP packets to be sent to the
destination subnet through all valid outbound interfaces and next hops in the equal-cost routes, achieving
load balancing.
Page 39 Copyright © 2020 Huawei Technologies Co., Ltd. All rights reserved.
Equal-Cost Route
Route Recursion Floating Route
Route Summarization
Page 40 Copyright © 2020 Huawei Technologies Co., Ltd. All rights reserved.
Equal-Cost Route
Route Recursion Floating Route
Route Summarization
RT RT
B B
. 0/24
.1
2 0.1 [Link]/30
for [Link]/30
ed
stin [Link]/30 [Link]/30
De
[Link]/30 [Link]/30
RTA's IP routing table when the primary link is available RTA's IP routing table when the primary link fails
Destination Next Hop Preference Destination Next Hop Preference
[Link] [Link] 60 [Link] [Link] 70
Page 41 Copyright © 2020 Huawei Technologies Co., Ltd. All rights reserved.
Equal-Cost Route
Route Recursion Floating Route
Route Summarization
CIDR
• Classless Inter-Domain Routing (CIDR) uses IP addresses and masks to identify networks and subnets. CIDR replaces
the previous addressing architecture of classful network design (such as classes A, B, and C addresses).
• CIDR is based on variable length subnet mask (VLSM). CIDR uses prefixes of any lengths to divide the address space
with continuous IP addresses. Multiple address segments with continuous prefixes can be summarized into a network,
effectively reducing the number of routing entries.
Page 42 Copyright © 2020 Huawei Technologies Co., Ltd. All rights reserved.
Equal-Cost Route
Route Recursion Floating Route
Route Summarization
[Link]/24
Page 43 Copyright © 2020 Huawei Technologies Co., Ltd. All rights reserved.
Equal-Cost Route
Route Recursion Floating Route
Route Summarization
[Link]/24
[Link]/24
RT RT • Route summarization is an approach of summarizing
...
A [Link] B ...
routes with the same prefix into one summary route to
[Link] ...
[Link]/24 minimize the IP routing table size and improve device
resource usage.
Page 44 Copyright © 2020 Huawei Technologies Co., Ltd. All rights reserved.
Equal-Cost Route
Route Recursion Floating Route
Route Summarization
[Link]/24 1 1 0 000 0 0 1 0 1 0 1 0 0 0 0 0 0 0 0 0 1 0 0 0 0 0 0 0 0 0
[Link]/22 1 1 0 000 0 0 1 0 1 0 1 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0
• To summarize routes to multiple continuous network segments into one summary route that just includes these
network segments, ensure that the mask length of the summary route is as long as possible.
• The key to achieve this is to convert the destination addresses of specific routes into binary numbers and then find
out the identical bits in these binary numbers.
Page 45 Copyright © 2020 Huawei Technologies Co., Ltd. All rights reserved.
Equal-Cost Route
Route Recursion Floating Route
Route Summarization
[Link]/24
[Link]/24 RT RT
... B [Link] A
Internet
... [Link]
...
1 2
[Link]/24
Page 46 Copyright © 2020 Huawei Technologies Co., Ltd. All rights reserved.
Equal-Cost Route
Route Recursion Floating Route
Route Summarization
[Link]/24
[Link]/24 RT RT
... B [Link] A
Internet
...
... [Link]
[Link]/24
Page 47 Copyright © 2020 Huawei Technologies Co., Ltd. All rights reserved.
Equal-Cost Route
Route Recursion Floating Route
Route Summarization
[Link]
RT
[Link]/24
C
[Link]/24
...
[Link]/24
• To simplify the configuration, an administrator may configure a static summary route on RTA to allow RTA to reach network
segments [Link]/24 to [Link]/24 of RTB. However, this summary route also includes the network segments of RTC. As
a result, RTA forwards the traffic destined for network segments of RTC to RTB, causing data packet loss. This problem is caused
by inaccurate route summarization. To resolve this problem, the summary route must be as accurate as possible; that is, it just
covers all specific routes that are to be summarized, with no extra route included.
Page 48 Copyright © 2020 Huawei Technologies Co., Ltd. All rights reserved.
Equal-Cost Route
Route Recursion Floating Route
Route Summarization
[Link]/24 0 0 0 010 1 0 0 0 0 0 0 0 0 1 0 0 0 0 0 0 0 1 0 0 0 0 0 0 0 0
[Link]/24 0 0 0 010 1 0 0 0 0 0 0 0 0 1 0 0 0 0 0 0 1 0 0 0 0 0 0 0 0 0
[Link]/24 0 0 0 0101 0 0 0 0 0 0 0 0 1 0 0 0 0 0 0 1 1 0 0 0 0 0 0 0 0
/22
ip route-static [Link] 24 [Link]
ip route-static [Link] 24 [Link]
ip route-static [Link] 22 [Link]
ip route-static [Link] 24 [Link]
Page 49 Copyright © 2020 Huawei Technologies Co., Ltd. All rights reserved.
Quiz
1. How does a router select the optimal route?
2. How do I configure a floating route?
3. What is the summary route for routes to [Link]/24, [Link]/24, and [Link]/24?
Page 50 Copyright © 2020 Huawei Technologies Co., Ltd. All rights reserved.
Summary
● This section presents the basic concepts of routes, how routes instruct routers to
forward IP packets, common route attributes, and default routes (special static routes).
● In addition, this section describes advanced routing features including route recursion,
floating routes, and equal-cost routes, which are widely used on live networks.
Page 51 Copyright © 2020 Huawei Technologies Co., Ltd. All rights reserved.
Thank You
[Link]
Page 52 Copyright © 2020 Huawei Technologies Co., Ltd. All rights reserved.