01-3 - Routing Basics
01-3 - Routing Basics
01-3 - Routing Basics
Page 0 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?
Page 1 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
Gateway Gateway
Destination-based forwarding
Page 2 Copyright © 2020 Huawei Technologies Co., Ltd. All rights reserved.
Routing Information
Page 3 Copyright © 2020 Huawei Technologies Co., Ltd. All rights reserved.
IP Routing Table
14.0.0.0/8 Outbound
Destination/Mask Next Hop
Interface
R4
• Routers discover routes using multiple
11.0.0.0/8 2.2.2.2 GE0/0
1.1.1.2/30 methods.
13.0.0.0/8 3.3.3.2 GE0/1
14.0.0.0/8 1.1.1.2 GE0/2 • A router selects the optimal route and
…
GE0/2
1.1.1.0/30 1.1.1.1 GE0/2
installs it in its IP routing table.
1.1.1.1/30
1.1.1.1/32 127.0.0.1 GE0/2 • The router forwards IP packets based on
GE0/0 GE0/1
3.3.3.1/30
routes in the IP routing table.
2.2.2.1/30 R2
• Routers manage path information by
R1 R3
11.0.0.0/8 13.0.0.0/8
Page 4 Copyright © 2020 Huawei Technologies Co., Ltd. All rights reserved.
Contents
1. Overview of IP Routing
▫ Basic Concepts of Routing
▫ Route-based Forwarding
2. Static Routing
3. Dynamic Routing
Page 5 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
20.1.1.0/24 30.1.1.0/24
GE0/0/1
10.1.1.0/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 10.1.1.0/24 GE0/0/0 Interface Interface
Static 30.1.1.0/24 GE0/0/1 OSPF 40.1.1.0/24 GE0/0/2
Direct 20.1.1.0/24 GE0/0/1
Page 6 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
GE0/0/0 network.
10.0.0.2/24
10.0.0.0/24
GE0/0/1
20.1.1.0/24 • When a router is the last hop router, IP packets
RTB 20.1.1.2/24 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 RTB • When a direct route is used for packet
Destination/M Outbound forwarding, the destination IP address of a
Protocol Next Hop
ask Interface
packet to be forwarded and the IP address of the
10.0.0.0/24 Direct 10.0.0.2 GE0/0/0
router‘s outbound interface are in the same
20.1.1.0/24 Direct 20.1.1.2 GE0/0/1
subnet.
Page 7 Copyright © 2020 Huawei Technologies Co., Ltd. All rights reserved.
Direct Routes (2)
Direct routes
GE0/0/0 GE0/0/1
10.0.0.2/24 20.1.1.3/24
• Not all the direct routes generated for interfaces
GE0/0/0 GE0/0/1
RTA 10.0.0.1/24 RTB 20.1.1.2/24 RTC 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 routing table.
Direct routes in the IP routing table of RTB
Outbound
Destination/Mask Protocol Next Hop
Interface
20.1.1.0/24 Direct 20.1.1.2 G0/0/1
• When GE0/0/0 goes down, the direct route for this interface is
not installed in the IP routing table.
Page 8 Copyright © 2020 Huawei Technologies Co., Ltd. All rights reserved.
Contents
1. Overview of IP Routing
▫ Basic Concepts of Routing
▫ Route-based Forwarding
2. Static Routing
3. Dynamic Routing
Page 9 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 10 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 1.1.1.1 and the mask is 255.255.255.0, the IP address of the subnet to which
the host or router belongs is 1.1.1.0.
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 11 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
Routes (these routes have the same destination network
address and mask), the router compares the
Different
preferences of these routes and prefers the route
Destination Installed in the IP
subnet/mask routing table with the lowest preference value.
Same • A lower preference value indicates a higher
Higher Preference preference.
Preference
• The route with the highest preference is installed in
the IP routing table.
Page 12 Copyright © 2020 Huawei Technologies Co., Ltd. All rights reserved.
Route Preference - Comparison Process
Comparing Route Preferences
Dynamic routing
protocol 20.1.1.2/30 • RTA discovers two routes to 10.0.0.0/30, one is
OSPF
10.0.0.0/30
20.1.1.1/30
an OSPF route and the other a static route. In
this case, RTA compares the preferences of the
RTA
30.1.1.1/30 30.1.1.2/30 two routes and selects the route with the lowest
preference value.
• Each routing protocol has a unique preference.
IP routing table of RTA
• OSPF has a higher preference. Therefore, the
Destination/Mask Protocol Preference Next Hop
10.0.0.0/30 Static 60 30.1.1.2 Installed OSPF route is installed in the IP routing table.
in the IP
10.0.0.0/30 OSPF 10 20.1.1.2 routing
table
Page 13 Copyright © 2020 Huawei Technologies Co., Ltd. All rights reserved.
Metric - Comparison Process
Metric comparison
Page 14 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 15 Copyright © 2020 Huawei Technologies Co., Ltd. All rights reserved.
Metric - Basic Concepts
Comparing Metrics • When a router discovers multiple routes to the
Routes
same destination network through the same
routing protocol, the router selects the optimal
route based on the metrics of these routes if
Different
Installed in the
Destination/mask IP routing table these routes have the same preference.
Page 16 Copyright © 2020 Huawei Technologies Co., Ltd. All rights reserved.
Contents
1. Overview of IP Routing
▫ Basic Concepts of Routing
▪ Route-based Forwarding
2. Static Routing
3. Dynamic Routing
Page 17 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.1
address 172. 16. 00000010 00000001
Page 18 Copyright © 2020 Huawei Technologies Co., Ltd. All rights reserved.
Example of Longest Matching (1)
Example of Longest Matching
Destination IP 10.1.1.2/30
address:
• There are two routes to 192.168.2.2 in the IP
192.168.2.2
RTA
routing table of RTA, one has the 16-bit mask
20.1.1.2/30 and the other has the 24-bit mask. According to
DATA the longest matching rule, the route with the 24-
bit mask is preferred to guide the forwarding of
30.1.1.2/30
packets destined for 192.168.2.2.
IP routing table of RTA
Destination/Mask Next Hop
192.168.0.0/16 10.1.1.2
192.168.2.0/24 20.1.1.2 Match
192.168.3.0/24 30.1.1.2
Page 19 Copyright © 2020 Huawei Technologies Co., Ltd. All rights reserved.
Example of Longest Matching (2)
Example of Longest Matching
Destination IP 10.1.1.2/30
address:
192.168.3.2
RTA
20.1.1.2/30
• According to the longest matching rule, only the
Data
route to 192.168.3.0/24 in the IP routing table
matches the destination IP address 192.168.3.2.
30.1.1.2/30
IP routing table of RTA Therefore, this route is used to forward packets
Destination/Mask Next Hop destined for 192.168.3.2.
192.168.0.0/16 10.1.1.2
192.168.2.0/24 20.1.1.2
192.168.3.0/24 30.1.1.2 Match
Page 20 Copyright © 2020 Huawei Technologies Co., Ltd. All rights reserved.
Route-based Forwarding Process
Outbound
Destination/Mask Next Hop
Interface
Destination 20.0.1.0/24 20.0.1.2 GE0/0
IP address:
30.0.1.0/24 30.0.1.1 GE0/1
40.0.1.2
10.0.1.0/24 20.0.1.1 GE0/0
40.0.1.0/24 30.0.1.2 GE0/1
IP routing table of R2
Data
Gateway Gateway
GE0/1 GE0/0 GE0/0 GE0/1 GE0/0 GE0/1
10.0.1.0/24 20.0.1.0/24 30.0.1.0/24 40.0.1.0/24
10.0.1.1 20.0.1.1 20.0.1.2 30.0.1.1 30.0.1.2 40.0.1.1
R1 R2 R3
Page 21 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 22 Copyright © 2020 Huawei Technologies Co., Ltd. All rights reserved.
Contents
1. Overview of IP Routing
2. Static Routing
3. Dynamic Routing
Page 23 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 small networks.
Destined for
20.1.1.0/24 GE0/0/0 GE0/0/1 • The disadvantage of static routes is that they
10.0.0.2/24 20.1.1.3/24
cannot automatically adapt to network topology
GE0/0/0 GE0/0/1
RTA 10.0.0.1/24 RTB 20.1.1.2/24 RTC changes and so require manual intervention.
Page 25 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 0.0.0.0 (with the mask 0.0.0.0), namely,
0.0.0.0/0. RTA needs to forward
packets to a subnet that is
not directly connected to it
and forwards the packets to
10.0.0.2.
192.168.1.0/24
RTA RTB 192.168.2.0/24
GE0/0/0 GE0/0/0
10.0.0.0/24 192.168.3.0/24
10.0.0.1 .
10.0.0.2 .
192.168.254.0/24
Page 26 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
1.2.3.0/24 Internet
GE0/0/1 GE0/0/0 1.2.3.254
PC 192.168.1.254 1.2.3.4
192.168.1.100
Gateway: 192.168.1.254
Page 27 Copyright © 2020 Huawei Technologies Co., Ltd. All rights reserved.
Contents
1. Overview of IP Routing
2. Static Routing
3. Dynamic Routing
Page 28 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
manually configure OSPF discovered 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, generate routes, and update routes when the topology
when the network topology changes, static routes cannot changes. These protocols effectively reduce the workload
adapt to these changes in a timely and flexible manner. of network administrators and are widely used on large
networks.
Page 29 Copyright © 2020 Huawei Technologies Co., Ltd. All rights reserved.
Classification of Dynamic Routing Protocols
Classification by the application scope
Page 30 Copyright © 2020 Huawei Technologies Co., Ltd. All rights reserved.
Contents
1. Overview of IP Routing
2. Static Routing
3. Dynamic Routing
Page 31 Copyright © 2020 Huawei Technologies Co., Ltd. All rights reserved.
Equal-Cost Route
Route Recursion Floating Route
Route Summarization
Page 32 Copyright © 2020 Huawei Technologies Co., Ltd. All rights reserved.
Equal-Cost Route
Route Recursion Floating Route
Route Summarization
GE0/0/0 GE0/0/1
10.0.0.2/24 20.1.1.3/24
30.1.2.0/24
GE0/0/0 GE0/0/1
RTA 10.0.0.1/24 RTB 20.1.1.2/24 RTC
Destination/M Outbound
Next Hop
ask Interface
[RTA] ip route-static 30.1.2.0 24 20.1.1.3
Recursion
30.1.2.0/24 20.1.1.3 GE0/0/0
20.1.1.0/24 10.0.0.2 GE0/0/0
[RTA] ip route-static 20.1.1.0 24 10.0.0.2
Configure a route to 20.1.1.3, with the next hop pointing to 10.0.0.2 on the directly connected network.
In this way, RTA can recurse the route with the destination 30.1.2.0/24 to the route with the destination
10.0.0.2.
Page 33 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 34 Copyright © 2020 Huawei Technologies Co., Ltd. All rights reserved.
Equal-Cost Route
Route Recursion Floating Route
Route Summarization
Page 35 Copyright © 2020 Huawei Technologies Co., Ltd. All rights reserved.
Equal-Cost Route
Route Recursion Floating Route
Route Summarization
RTB RTB
10.1.1.2/30 10.1.1.2/30
20.0.0.0/30 20.0.0.0/30
10.1.1.1/30 10.1.1.1/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
20.0.0.0 10.1.1.2 60 20.0.0.0 10.1.2.2 70
Page 36 Copyright © 2020 Huawei Technologies Co., Ltd. All rights reserved.
Thank You
www.huawei.com
Page 37 Copyright © 2020 Huawei Technologies Co., Ltd. All rights reserved.