12 Routing Principle
12 Routing Principle
Routing Principle
Main Content
Routing Principle
Routing Principle
• Default Route
• In the exercise of the previous chapter, SW 1 and SW 2 each have only one port to connect to
the external network (each interconnected with SW 3 only). In this case, a default route can
be configured to route all data to SW 3 to simplify the configuration.
A default route can be configured on each of SW 1 and SW 2 to replace the two static routes:
SW1(config)#ip route 0.0.0.0 0.0.0.0 10.1.1.2
SW2(config)#ip route 0.0.0.0 0.0.0.0 10.1.1.5
0.0.0.0 0.0.0.0 indicates that all data is matched.
SW1# sh ip route
SW1#sh ip route
… 192.168.1.0/24
Gateway of last resort is no set
C 10.0.0.0/30 is directly connected, VLAN 800
C 10.0.0.2/32 is local host. SW 2 SW 3
C 10.0.0.4/30 is directly connected, GigabitEthernet 0/25
C 10.0.0.6/32 is local host. 10.0.0.1 10.0.0.5
S 192.168.1.0/26 [1/0] via 10.0.0.5
S 192.168.1.0/24 [1/0] via 10.0.0.1 Gi0/24 Gi0/25
C 192.168.3.0/24 is directly connected, VLAN 800 SW 1
C 192.168.3.1/32 is local host.
Routing Principle
• Routing Table
• Route type
• A route type identifies the protocol used for generating a route. For details, see the descriptions in Codes.
• For example, configured static routes are marked with "S". A route marked with "*" indicates a default route.
Ruijie#sh ip route
• For example, in this route, the subnet ID and the subnet mask indicate the IP address
range of 192.168.1.0 to 192.168.1.255. When the device receives a packet with its
destination IP address within this range, the device forwards the packet via this routing
entry.
Routing Principle
• Routing Table
• Administrative Distance (AD): A route generated from a protocol is assigned with a number that
identifies the route priority and this number is called AD. When the same route (having the same
subnet ID and the same subnet mask) is generated from a different routing protocol, a routing
entry with the minimum AD is preferred.
• Metric: A metric identifies the path cost required for transmission from the local device to the
destination network segment. A lower metric indicates a higher priority of a routing entry. Note
that the metric is compared only when the ADs are the same (routes are generated from the same
routing protocol). The metrics of routing entries with different ADs (routes are generated from
different routing protocols) are incomparable.
O 192.168.1.0/24 [110/2] via 192.168.250.1, 00:01:53, GigabitEthernet 0/24
• The table below lists default ADs of routing protocols supported by Ruijie device.
(A default AD of a protocol varies with a vendor.)
Routing Flag AD
Protocol
Direct route C 0
protocol
Static route S 1
protocol
RIP R 120
OSPF O 110
IS-IS I 115
EBGP B 20
IBGP B 200
Routing Principle
• Routing Table
• Next-hop IP address
• If data matches the subnet ID and subnet mask of a route, the data is forwarded to the next-
hop IP address specified in the route. A next-hop IP address refers to the IP address of a
forwarding device before data reaches the destination address.
• A condition for loading a routing entry to the routing table is that the next hop is reachable.
That is, the local interface and the interface of the connected peer device must be up in the
same network segment. Otherwise, it is deemed that the next hop is unreachable and the
routing entry cannot be loaded to the routing table.
Routing Principle
• Routing and forwarding rules
• A layer-3 switch matches the destination IP address of a received packet with entries in the routing table and selects
a routing entry according to the following rules for forwarding:
• Prerequisite: The next hop must be reachable. Otherwise, the routing entry cannot be loaded to the routing table.
• 1. If routing entries are different (their subnet ID and subnet masks are not completely the same):
• They are all displayed in the routing table and an entry with the longest match of the subnet mask is preferred.
• 2. If routing entries are the same (their subnet ID and subnet masks are completely the same):
• (1) If a device generates multiple routing entries with the same subnet mask via multiple routing protocols,
only the entry with the minimum AD is displayed in the routing table.
• (2) If there are multiple entries with the minimum AD, only the entry with the minimum metric is displayed in
the routing table.
• (3) If there are multiple entries with the minimum AD and minimum metric, these entries are displayed in the
routing table and are selected for data forwarding in load balancing mode.
Routing Principle
• Routing and forwarding rules
• Longest match
• If a packet destined for a destination IP address matches multiple routes, the entry with the
longest mask match (more refined) is preferred.
• For example, if the destination IP address of a packet is 192.168.1.10 and two routes are
matched, the next hop of the packet is 192.168.250.5 because the routing entry learned via
RIP has a longer mask match (25).
Routing Principle
• Routing and forwarding rules
• Load balancing
• After ADs and metrics are compared, if multiple same routing entries with the longest match (the subnet IDs, masks, ADs, and
metrics are the same and only the next-hop IP addresses are different) match the destination IP address of a received packet,
the received packet and subsequent packets (with the same destination IP address) are "evenly" forwarded through different
output interfaces based on different next-hop IP addresses.
Gi0/24 Gi0/25
IP Header S: 192.168.4.10
D: 192.168.1.10
IP packet
• The ADs of static routes can be modified for route backup. As shown in the figure below, two static
routes destined for the network segment 192.168.1.0/24 are configured on SW 1 and the two routes
are pointed to different next hops (SW 2 and SW 3). The AD of one static route is changed to 100. Only
the routing entry with the smaller AD is loaded to the routing table according to the preferred route
selection principle.
192.168.1.0/24 interface gi 0/24
no switchport
ip add 10.0.0.2 255.255.255.252
SW2 SW3
interface gi 0/25
no switchport
ip add 10.0.0.6 255.255.252
Gi0/24 Gi0/25
SW1 ip route 192.168.1.0 255.255.255.0 10.0.0.1
ip route 192.168.1.0 255.255.255.0 10.0.0.5 100
SW1#sh ip route
… AD
Gateway of last resort is no set
C 10.0.0.0/30 is directly connected, VLAN 800
C 10.0.0.2/32 is local host.
C 10.0.0.4/30 is directly connected, GigabitEthernet 0/25
C 10.0.0.6/32 is local host.
S 192.168.1.0/24 [1/0] via 10.0.0.1 Only one static route is displayed in the routing
C 192.168.3.0/24 is directly connected, VLAN 800 table.
C 192.168.3.1/32 is local host.
Routing Principle
• Static Floating Route
• When the next hop of a routing entry with a smaller AD becomes unreachable
due to a line or device fault, the routing entry is removed from the routing table.
Instead, the routing entry with a larger AD is loaded to the routing table. In this
way, path and device backup are implemented.
192.168.1.0/24
Ruijie#sh ip interface brief
SW2 SW3 Interface IP-Address(Pri) OK? Status
GigabitEthernet 0/24 10.0.0.2/30 YES DOWN
GigabitEthernet 0/25 10.0.0.6/30 YES UP
Gi0/24 Gi0/25
SW1
SW1#sh ip route
…
Gateway of last resort is no set The static route with the AD of 100 is
C 10.0.0.4/30 is directly connected, GigabitEthernet 0/25 displayed in the routing table.
C 10.0.0.6/32 is local host.
S 192.168.1.0/24 [100/0] via 10.0.0.5
The configuration above implements the backup function. When the master
link malfunctions, the route is switched and data is switched to the backup
link. Such static routes are called static floating routes.
Routing Principle
• Summary
• After learning this chapter, Tom understood the meaning of every item in the routing table and mastered the
forwarding rules of the routing table, longest match, load balancing, and floating route.
• Tom finally understood why the ping operation failed even if routes were configured. Then, Tom modified the routes
and the network became reachable.
• Exercises
• What is the sequence for searching for and matching routing entries during data forwarding?
• What is the prerequisite for loading routing entries to the routing table?
• There are two same routes: One is learned via RIP, with the metric of 3, and the other is learned via OSPF, with the
metric of 5. Which route is preferred?
• 1. Which of the following entries for 192.168.1.0/24 will be displayed in the routing table?
• 2. Which of the following entries for 192.168.1.0/24 will be displayed in the routing table?
O 192.168.1.0/24 [110/2] via 192.168.250.1, 00:01:53, GigabitEthernet 0/24
O 192.168.1.0/24 [110/5] via 192.168.250.5, 00:01:53, GigabitEthernet 0/25
R 192.168.1.0/24 [120/1] via 192.168.250.9, 00:02:07, GigabitEthernet 0/26
• 3. When a packet with the destination IP address of 192.168.1.160 is received, which of the following
entries will be matched and used for forwarding the packet? Give your reasons.
S 192.168.1.0/16 [130/0] via 10.0.0.1
O 192.168.1.0/24 [110/2] via 192.168.250.1, 00:01:53, GigabitEthernet 0/24
O 192.168.1.0/24 [110/2] via 192.168.250.5, 00:01:53, GigabitEthernet 0/25
R 192.168.1.0/25 [120/1] via 192.168.250.9, 00:02:07, GigabitEthernet 0/26
THANKS
Ruijie Networks Co., Ltd.
Address: Floor 11, East Wing, Zhongyipengao Plaza, No. 29 Fuxing Road, Haidian District, Beijing, China
Post Code: 100036
Tel: (8610) 5171-5996
Fax: (8610) 5171-5872
www.ruijienetworks.com