05 IP Routing Basics
05 IP Routing Basics
age 2 Copyright © 2020 Huawei Technologies Co., Ltd. All rights reserved.
Forewor
d
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.
age 3 Copyright © 2020 Huawei Technologies Co., Ltd. All rights reserved.
Objective
s
On completion of this course, you will be able to:
Understand the basic principles of routers.
Know how routers select optimal routes.
Understand the contents of routing tables.
Master advanced routing features.
age 4 Copyright © 2020 Huawei Technologies Co., Ltd. All rights reserved.
Content
s
1. Overview of IP Routing
▪ Basic Concepts of Routing
▫ Route-based Forwarding
2. Static Routing
3. Dynamic Routing
4. Advanced Routing Features
age 5 Copyright © 2020 Huawei Technologies Co., Ltd. All rights reserved.
Background: Inter-Subnet
Communication
M
• An IP address uniquely identifies a node
on a network. Each IP address belongs to
a unique subnet, and each subnet may
belong to a different area of the network.
N
• To implement IP addressing, subnets in
different areas need to communicate with
How to communicate
each other.
with the network M?
age 6 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.
A routing device maintains an IP routing table that stores routing information.
Route-based Packet Forwarding
Router R4
Data R1 R2 R3
N M
Gatewa Gateway
y
Destination-based forwarding
age 7 Copyright © 2020 Huawei Technologies Co., Ltd. All rights reserved.
Routing Information
A route contains the following information:
Destination: identifies a destination subnet.
[Link]
[Link]/24
Mask: identifies a subnet together with a
destination IP address.
GE0/0/0
[Link]
Outbound interface: indicates the interface
through which a data packet is sent out of the
local router.
IP routing table
Next hop: indicates the next-hop address used
Destination/ Outbound Next by the router to forward the data packet to the
Mask Interface Hop
destination subnet.
[Link]/24 GE0/0/0 [Link]
The information identifies the destination
subnet and specifies the path for forwarding
age 8 Copyright © 2020 Huawei Technologies Co., Ltd. All rights reserved. data packets.
IP Routing Table
[Link]/8 Destination/
Next Hop
Outbound
Mask Interface
R4
• Routers discover routes using multiple
[Link]/8 [Link] GE0/0
[Link]/3 methods.
0 [Link]/8 [Link] GE0/1
[Link]/8 [Link] GE0/2 • A router selects the optimal route and
…
GE0/2 [Link]/30 [Link] GE0/2
installs it in its IP routing table.
[Link]/3
0 [Link]/32 [Link] GE0/2 • The router forwards IP packets based on
GE0/0 GE0/1 routes in the IP routing table.
[Link]/30 R2 [Link]/3
0 • Routers manage path information by
managing their IP routing tables.
[Link]/3 [Link]/30
0
R1 R3
[Link]/8 [Link]/8
age 9 Copyright © 2020 Huawei Technologies Co., Ltd. All rights reserved.
Content
s
1. Overview of IP Routing
▫ Basic Concepts of Routing
▫ Route-based Forwarding
2. Static Routing
3. Dynamic Routing
4. Advanced Routing Features
age 10 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
GE0/0/2 protocol
OSPF
Destination/ Outbound
Protocol
Mask Interface Destination/ Outbound Outboun
Protocol Destination/
Direct [Link]/24 GE0/0/0 Mask Interface Protocol d
Mask
Static [Link]/24 GE0/0/1 Interface
Direct [Link]/24 GE0/0/1
OSPF [Link]/24 GE0/0/2
age 11 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-
GE0/0/0 connected network.
[Link]/24
[Link]/24
GE0/0/1
[Link]/24 • When a router is the last hop router, IP
RTB [Link]/24
packets to be forwarded will match a direct
route and the router will directly forward the
IP packet to the destination host.
Direct routes in the IP routing table of • When a direct route is used for packet
RTB
Destination Next Outbound forwarding, the destination IP address of a
Protocol
/Mask Hop Interface
packet to be forwarded and the IP address of
[Link]/24 Direct [Link] GE0/0/0
the router‘s outbound interface are in the
[Link]/24 Direct [Link] GE0/0/1
same subnet.
age 12 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
GE0/0/0 GE0/0/1
RTA [Link]/24 RTB [Link]/24 RTC interfaces are installed in the IP routing
table. Only the direct routes of which the
physical status and protocol status of
interfaces are up are installed in the IP
Direct routes in the IP routing table of RTB
routing table.
Destination/ Outbound
Protocol Next Hop
Mask Interface
[Link]/24 Direct [Link] G0/0/1
age 13 Copyright © 2020 Huawei Technologies Co., Ltd. All rights reserved.
Content
s
1. Overview of IP Routing
▫ Basic Concepts of Routing
▫ Route-based Forwarding
2. Static Routing
3. Dynamic Routing
4. Advanced Routing Features
age 14 Copyright © 2020 Huawei Technologies Co., Ltd. All rights reserved.
Examining the IP Routing Table
<Huawei> display ip routing-table
Route Flags: R - relay, D - download to fib
------------------------------------------------------------------------------------------------------
Routing Tables: Public
Destinations : 6 Routes : 6
age 15 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.
age 16 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
Routes protocols (these routes have the same
destination network address and mask), the
Different
router compares the preferences of these
Destination Installed in the
subnet/mask IP routing table routes and prefers the route with the lowest
Same preference value.
Higher Preference
• A lower preference value indicates a higher
Preference
preference.
• The route with the highest preference is
installed in the IP routing table.
age 17 Copyright © 2020 Huawei Technologies Co., Ltd. All rights reserved.
Route Preference - Comparison
Process
Comparing Route Preferences
Dynamic
routing [Link]/3 • RTA discovers two routes to [Link]/30, one
protocol0
[Link]/30
OSPF
[Link]/3
is an OSPF route and the other a static
0 route. In this case, RTA compares the
RTA
[Link]/ [Link]/ preferences of the two routes and selects
30 30
the route with the lowest preference value.
• Each routing protocol has a unique
Route entries of RTA
preference.
Destination/
Protocol Preference Next Hop
Mask
Installed • OSPF has a higher preference. Therefore,
[Link]/30 Static 60 [Link] in the IP
routing the OSPF route is installed in the IP routing
[Link]/30 OSPF 10 [Link]
table table.
age 18 Copyright © 2020 Huawei Technologies Co., Ltd. All rights reserved.
Metric - Comparison Process
Metric comparison
age 19 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:
age 20 Copyright © 2020 Huawei Technologies Co., Ltd. All rights reserved.
Metric - Basic Concepts
Comparing Metrics • When a router discovers multiple routes to
Routes
the same destination network through the
same routing protocol, the router selects the
optimal route based on the metrics of these
Different Installed in
Destination/mask the IP routing routes if these routes have the same
table
preference.
Same
• The metric of a route indicates the cost of
Higher
Preference preference reaching the destination address of the
route.
Same
preference • Common metrics include the hop count,
Lower bandwidth, delay, cost, load, and reliability.
Metric metric
• The route with the lowest metric is installed
in the IP routing table.
age 21 Copyright © 2020 Huawei Technologies Co., Ltd. All rights reserved.
• The metric is also known as the cost.
Content
s
1. Overview of IP Routing
▫ Basic Concepts of Routing
▪ Route-based Forwarding
2. Static Routing
3. Dynamic Routing
4. Advanced Routing Features
age 22 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
[Link] 0000001 0000000
address 172. 16.
0 1
M
is
[Link] 0000000 m
Routing entry 1 172. 16. xxxxx x xatx
1 ch
[Link] Lo
ng
0000001 es
[Link] 172. 16. x x x x x x xt mx
Routing entry 2 0 at
[Link] c h
N
o
lo t t
[Link] 172. 16. xxxxxxxx xx xmx nxgex hxe x
Routing entry 3 at st
[Link] ch
age 23 Copyright © 2020 Huawei Technologies Co., Ltd. All rights reserved.
Example of Longest Matching (1)
Example of Longest Matching
Destination IP [Link]/30
address:
• There are two routes to [Link] in the IP
[Link]
RTA
routing table of RTA, one has the 16-bit
[Link]/30 mask and the other has the 24-bit mask.
DATA According to the longest matching rule, the
route with the 24-bit mask is preferred to
[Link]/30
guide the forwarding of packets destined for
IP routing table of RTA [Link].
Destination/Mask Next Hop
[Link]/16 [Link]
[Link]/24 [Link] Match
[Link]/24 [Link]
age 24 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
Data
the route to [Link]/24 in the IP routing
table matches the destination IP address
[Link]/30
IP routing table of [Link]. Therefore, this route is used to
RTA
Destination/Mask Next Hop forward packets destined for [Link].
[Link]/16 [Link]
[Link]/24 [Link]
[Link]/24 [Link] Match
age 25 Copyright © 2020 Huawei Technologies Co., Ltd. All rights reserved.
Route-based Forwarding Process
Destination/ Outbound
Next Hop
Mask 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 Gatewa
Gatewa
GE0/1 y GE0/0 GE0/1 GE0/0 y GE0/1
GE0/0
[Link]/24 [Link]/24 [Link]/24 [Link]/24
30.0.1. 30.0.1. 40.0.1.
[Link] [Link] [Link]
1 2 1
R1 R2 R3
IP routing table of IP routing table of
R1 R3
Destination/ Outbound Destination/ Outbound
Next Hop Next Hop
Mask Interface Mask Interface
[Link]/24 [Link] GE0/1 [Link]/24 [Link] GE0/1
[Link]/24 [Link] GE0/0 [Link]/24 [Link] GE0/0
[Link]/24 [Link] GE0/0 [Link]/24 [Link] GE0/0
[Link]/24 [Link] GE0/0 [Link]/24 [Link] GE0/0
age 26 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.
age 27 Copyright © 2020 Huawei Technologies Co., Ltd. All rights reserved.
Content
s
1. Overview of IP Routing
2. Static Routing
3. Dynamic Routing
4. Advanced Routing Features
age 28 Copyright © 2020 Huawei Technologies Co., Ltd. All rights reserved.
Application Scenarios of Static Routes
Static Routes • Static routes are manually configured by
network administrators, have low system
requirements, and apply to simple, stable, and
Destined for small networks.
[Link]/24 GE0/0/0 GE0/0/1
[Link]/24 [Link]/2
4
• The disadvantage of static routes is that they
GE0/0/0 GE0/0/1
RTA [Link]/2 RTB [Link]/2 RTC cannot automatically adapt to network
4 4
topology changes and so require manual
intervention.
Destination Protocol Next Hop
[Link] Static [Link]
• RTA needs to forward the packets with the
[Link] Direct [Link] destination address [Link]/24. However, the
IP routing table of RTA has only one direct
route, which does not match [Link]/24. In
this case, a static route needs to be manually
age 29 Copyright © 2020 Huawei Technologies Co., Ltd. All rights reserved. configured so that the packets sent from RTA
Static Route Configuration
Specify a next-hop IP address for a static route.
[Huawei] ip route-static ip-address { mask | mask-length } nexthop-address
Specify an outbound interface for a static route.
[Huawei] ip route-static ip-address { mask | mask-length } interface-type interface-number
Specify both the outbound interface and next hop for a static route.
[Huawei] ip route-static ip-address { mask | mask-length } interface-type interface-number [ nexthop-
address ]
When creating a static route, you can specify both the outbound interface and next hop. Alternatively,
you can specify either the outbound interface or next hop, depending on the interface type:
For a point-to-point interface (such as a serial interface), you must specify the outbound interface.
For a broadcast interface (for example, an Ethernet interface) or a virtual template (VT) interface, you
must specify the next hop.
age 30 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.
RTA [Link]/24 RTB [Link]/24 RTC
[RTA] ip route-static [Link] [Link]
[Link]
Destined for Destined for
[Link]/24 [Link]/24
Configure RTC.
• Configure static routes on RTA and RTC for [RTC] ip route-static [Link] [Link]
communication between [Link]/24 and [Link]/24. S1/0/0
age 31 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
RTA RTB [Link]/24
GE0/0/0 GE0/0/0
[Link]/24 [Link]/24
[Link] .
[Link] .
[Link]/24
age 32 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 RTA
[Link]/24 Internet
GE0/0/1 GE0/0/0 [Link]
PC [Link] [Link]
[Link]
Gateway: [Link]
age 33 Copyright © 2020 Huawei Technologies Co., Ltd. All rights reserved.
Content
s
1. Overview of IP Routing
2. Static Routing
3. Dynamic Routing
4. Advanced Routing Features
age 34 Copyright © 2020 Huawei Technologies Co., Ltd. All rights reserved.
Overview of Dynamic Routing
Static Routing Dynamic Routing
• To use static routes • Dynamic routes can
on any device, you Dynamic routing be automatically
Static must manually discovered and
routing configure them. OSPF
learned.
• Static routes cannot • Dynamic routes can
adapt to link adapt to topology
changes. changes.
• When the network scale expands, it becomes • Dynamic routing protocols automatically discover
increasingly complex to manually configure static and generate routes, and update routes when the
routes. In addition, when the network topology changes, topology changes. These protocols effectively reduce
static routes cannot adapt to these changes in a timely the workload of network administrators and are
and flexible manner. widely used on large networks.
age 35 Copyright © 2020 Huawei Technologies Co., Ltd. All rights reserved.
Classification of Dynamic Routing
Protocols
Classification by the application scope
age 36 Copyright © 2020 Huawei Technologies Co., Ltd. All rights reserved.
Content
s
1. Overview of IP Routing
2. Static Routing
3. Dynamic Routing
4. Advanced Routing Features
age 37 Copyright © 2020 Huawei Technologies Co., Ltd. All rights reserved.
Route
Equal-Cost
Route Recursion Floating Route Summarizatio
Route
n
age 38 Copyright © 2020 Huawei Technologies Co., Ltd. All rights reserved.
Route
Equal-Cost
Route Recursion Floating Route Summarizatio
Route
n
GE0/0/0 GE0/0/1
[Link]/24 [Link]/24
[Link]/2
GE0/0/0 GE0/0/1 4
RTA [Link]/24 RTB [Link]/24 RTC
age 39 Copyright © 2020 Huawei Technologies Co., Ltd. All rights reserved.
Route
Equal-Cost
Route Recursion Floating Route Summarizatio
Route
n
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.
age 40 Copyright © 2020 Huawei Technologies Co., Ltd. All rights reserved.
Route
Equal-Cost
Route Recursion Floating Route Summarizatio
Route
n
RTB RTB
. 0/24
. 1
20.1
fo r [Link]/30 [Link]/30
n ed
s ti [Link]/30 [Link]/30
De
[Link]/30 [Link]/30
age 42 Copyright © 2020 Huawei Technologies Co., Ltd. All rights reserved.
Route
Equal-Cost
Route Recursion Floating Route Summarizatio
Route
n
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.
192. 168. 0 0 0 0 1 1 0 0 0 0 0 0 0 0 0 0 [Link]/22
age 43 Copyright © 2020 Huawei Technologies Co., Ltd. All rights reserved.
Route
Equal-Cost
Route Recursion Floating Route Summarizatio
Route
n
[Link]/24
[Link]/2
RTB's IP routing
RTA 4 table
[Link]/2 To route traffic to the directly connected network
[Link]/24 segments of RTA, RTB must have routes to these
4
[Link]/2 network segments. If a static route is manually
4 configured for each network segment, the
[Link]/2 configuration workload will be heavy and RTB's IP
RTB routing table will have a large number of routing
4
[Link]/2 entries.
4
[Link]/2
4
age 44 Copyright © 2020 Huawei Technologies Co., Ltd. All rights reserved.
Route
Equal-Cost
Route Recursion Floating Route Summarizatio
Route
n
[Link]/24
[Link]/24
RTA RTB
... • Route summarization is an approach of
[Link] ...
[Link] ... summarizing routes with the same prefix into one
[Link]/24
summary route to minimize the IP routing table
size and improve device resource usage.
age 45 Copyright © 2020 Huawei Technologies Co., Ltd. All rights reserved.
Route
Equal-Cost
Route Recursion Floating Route Summarizatio
Route
n
[Link]/2 1 1 0 0 0 0 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
2 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.
age 46 Copyright © 2020 Huawei Technologies Co., Ltd. All rights reserved.
Route
Equal-Cost
Route Recursion Floating Route Summarizatio
Summarization (1)
Routing Loop
[Link]/24
[Link]/24 RTB RTA
... [Link] Internet
... [Link]
...
1 2
[Link]/24
age 47 Copyright © 2020 Huawei Technologies Co., Ltd. All rights reserved.
Route
Equal-Cost
Route Recursion Floating Route Summarizatio
Summarization (2)
Solution for Preventing Routing Loops
[Link]/24
[Link]/24 RTB RTA
... [Link] Internet
...
... [Link]
[Link]/24
age 48 Copyright © 2020 Huawei Technologies Co., Ltd. All rights reserved.
Route
Equal-Cost
Route Recursion Floating Route Summarizatio
Route
n
[Link]
RTC
[Link]/24
[Link]/24
...
[Link]/24
/22
ip route-static [Link] 24
[Link]
ip route-static [Link] 22 [Link]
ip route-static [Link] 24
[Link]
ip route-static [Link] 24
[Link] Accurately calculate the
summarized network address and
mask to ensure accurate route
summarization.
age 50 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?
age 51 Copyright © 2020 Huawei Technologies Co., Ltd. All rights reserved.
Summar
y
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.
age 52 Copyright © 2020 Huawei Technologies Co., Ltd. All rights reserved.
Thank You
[Link]
age 53 Copyright © 2020 Huawei Technologies Co., Ltd. All rights reserved.