Abstract: Follow the message, from the Windows host through the router to the Linux host for a stroll.
This article is shared by huawei Cloud community “Packet’s Wonderful Journey on Different Devices”. The author of the original article is playing the wind pipe with the drum.
Introduction to the
In the figure above, HostA packets are forwarded to HostB, and the packets are sent from the local gateway to HostB through router RouterA.
Host A: Windows Host.
Router A: Router B.
Host B: Linux Host.
Let’s start with the routing table for Host A and look at the routing tables for different locations on the network. Before looking at the routing table, let’s first understand the concept of routing, which is the most basic element of data communication network. Routing information is the path information guiding packet sending, and the routing process is the process of packet relay and forwarding.
A router or host selects routes based on a routing table. Each router or host has at least one routing table.
The routing table of the host stores routes configured by IP addresses and direct routes generated by interfaces.
The routing table of a router stores the routes discovered by various routing protocols. Based on the source, the routes in the routing table are classified into the following types:
-
Routes discovered by link layer protocols (also called interface routes or direct routes).
-
Static routes manually configured by the network administrator.
-
Dynamic routing Routes discovered by dynamic routing protocols.
Route on Host A
Configuration: The IPV4 address, subnet mask, and default gateway must be configured on the host.
Gateway is also called internetwork connector or protocol converter. The gateway implements network interconnection above the network layer. In terms of simplicity, the gateway is a setting for forwarding routes. If the next hop of a route is a gateway, the next hop of the route is a router, not a host.
View Windows in routing table:
The first route is automatically generated by the configured default gateway. The mask is 0.0.0.0, and the next hop is the default gateway.
A gateway route is a route whose next hop is a gateway. A gateway route is not a routing protocol. A routing protocol is a rule for maintaining a routing table between routers, discovering routes, generating routing tables, and guiding packet forwarding.
Routes with a mask of 0.0.0.0 are referred to as default routes. To understand the default routes, you need to know the longest matching principle in route forwarding, and bitwise matching in route search. If a route does not match from front to back, it indicates a failure. In short, the route with the longest mask is a forwarding route. Each layer will find 0.0.0.0, which is the default route, by looking up the IP branch. Let those routes that cannot find a non-zero address finally have a forwarding place.
The first route is a default gateway route. If the destination IP address of the packet is not the local IP address, the packet is directly forwarded from the default gateway.
The destination IP address of the packet is 10.1.1.1, which is not the local IP address. By default, the packet is discarded from the gateway.
Route on Router A
The router has two tables, one is the routing table on the control plane, and the other is the forwarding table on the forwarding plane. To facilitate understanding of forwarding, we specially look at the forwarding table of Huawei routers.
In the forwarding table, the outgoing interface GE1/1/1 can be configured as
interfaceGE1/1/1
IP address10.1.1.10 255.255.255.0
10.1.1.0/24 is a route on the network segment. The destination address is the combination of the IP address and mask, and the next hop is the IP address configured on the interface (it has no forwarding significance but only display significance). Forwards the packets whose destination IP addresses are on the same network segment from the specified interface.
10.1.1.10/32 is the host route, the destination ADDRESS is the IP address of the interface, and the mask of all host routes is 32 bits. The next hop is the loopback address 127.0.0.1, indicating that the local device has the IP address 1.1.1.1. IP packets destined for 1.1.1.1 need to be sent to the local device for processing. The host route is used to receive packets destined for the local device.
10.1.1.255/32 is a subnet broadcast route. The algorithm is xOR between an IP address and a reversed mask. Broadcast address specified by the IP protocol All Layer 3 interfaces on the local network segment need to receive packets from this address.
After receiving the packet, RouterA searches the forwarding table based on the longest matching rule, finds the route on network segment 10.1.1.0, and forwards the packet through GE1/1/1.
Route on Host B
Host B is a Linux operating system that has many similarities with Windows hosts
1. Gateway routing: This configuration is required for Linux
Interface configuration on Linux
On ETH0, the IP address is 10.172.153.72 and the mask length is 24
Viewing the Routing Table
The host route generated by the interface route was not found in the routing table. Procedure
This is where Linux systems differ from routing and Windows. If the IP address is a local IP address, the match is made directly without checking the routing table.
Another interesting phenomenon is that in the Linux table, the gateway is 0.0.0.0, indicating that the packet needs to be searched inside the host. When forwarding the packet, the host searches for the ARP form with the destination address. If the corresponding MAC address cannot be found, the packet is discarded.
Click to follow, the first time to learn about Huawei cloud fresh technology ~