Network Security Internet Technology Development Database Servers Mobile Phone Android Software Apple Software Computer Software News IT Information

In addition to Weibo, there is also WeChat

Please pay attention

WeChat public account

Shulou

The principle and configuration of static routing-- Theory

2025-03-29 Update From: SLTechnology News&Howtos shulou NAV: SLTechnology News&Howtos > Servers >

Share

Shulou(Shulou.com)06/02 Report--

The principle and configuration of static routing-- Theory

Goal: to understand the principles of routing

Learn to configure static and default routes

Learning content:

① routing principle

How the ② Router works

The formation of ③ routing table

④ static and default rout

The encapsulation process of packets forwarded by ⑤ routers

I. routing principle

The router works in the network layer of the OSI reference model, and its important role is to choose the best path for the data treasure and finally deliver it to the destination.

In a network with only one network segment, packets can easily reach the destination host from the source host. However, if a computer wants to communicate with a computer that is not on its own network segment, the packet may have to go through many routers. As shown in the figure, the network segment of host An and host B is separated by many routers, and the communication between host An and host B will pass through these intermediate routers, which is a very important problem-how to choose the path to the destination. There are many paths for packets to choose from from A to B, but it is clear that one of these paths is the fastest at some point.

Therefore, in order to improve the network access speed as much as possible, there needs to be a method to determine the best path from the source host to the target host, so as to forward the data, which is the routing technology.

Second, the working principle of the router

First, let's take a look at how the router works. For ordinary users, only the local area network can be accessed. Computers in the local area network can communicate with Internet by setting a default gateway on PC. In fact, the default gateway set on PC is the IP address of the router ethernet port. If the computer in the LAN wants to communicate with the outside computer, just submit the request to the Ethernet port of the router, and the router will do the rest of the work. Therefore, it can be said that the router is the transit station of the Internet, and the packets in the network are forwarded to the destination network through a router.

So how does the router forward the packet?

In fact, there is a routing table inside each router, just like the map we use to travel. This routing table contains all the destination network addresses that the router knows, as well as the best path to these networks through this router. This best path refers to an interface on the router or the address of the next-hop router.

It is because of the existence of the routing table that the router can forward packets efficiently.

As shown in the figure, let's briefly explain the process by which the router chooses the best path (here we abbreviated the network segment 192.168.1.0 and24 to 1.0, and the same applies to other network segments):

1. Host 1.1 sends data DATA to host 4.1, because the IP address is not on the same network segment, so the host user sends the packet to network router An of this network segment.

two。 When router A receives the packet, it first looks at the destination IP address in the IP header of the packet and looks for its own routing table. It is found that the destination address of the packet DATA is 4.1, belonging to the 4.0 network segment, the S0 interface, so router A sends the packet out of interface S0.

3. Similarly, after receiving a packet from router A, router B first looks at the destination IP address and its own routing table. At the same time, the packet is sent out of the network segment 4.0 ~ E0 interface.

4. The final host 4.1 receives the packet.

This is how routers work!

Third, the formation of routing table

The routing table is a collection of route entries maintained in the router, and the router chooses the path according to the routing table.

So how is the routing table formed?

① directly connected network segment, in popular words, is the network segment that grows on your own body. When the IP address is configured, the port is in the UP state, thus forming a directly connected network segment.

② network segments are not directly connected, while for non-directly connected network segments, static or dynamic routes are required to add the network segments to the routing table.

As shown in the figure:

Static routes and default routes

① static rout

Static routes are fixed routes that are manually configured by the administrator in the router.

Its disadvantage is its lack of flexibility, but it allows precise control over the behavior of routing, and it is one-way.

Therefore, generally speaking, static routes are used in networks with small scale and relatively fixed topology.

As shown in the figure:

② default rout

A default route is a special static route that a router can make when there is no entry in the routing table that matches the destination address of the packet. If there is no default route, packets whose destination address does not match the table entry in the routing table will be discarded.

The characteristic of the default route is that when only one path can reach other networks, the default route will greatly simplify the configuration of the router, reduce the workload of the administrator, and improve the network performance.

As shown in the figure: (the stub network is: this network has only one unique path to other networks)

Fifth, the encapsulation process of packets forwarded by a router

We use the following figure to simulate the packet forwarding encapsulation process and explain the steps:

At the network layer, 1.Host An encapsulates messages from the upper layer into IP packets, the header of which contains the source address and destination address. The source address is the native address 192.168.1.2 and the destination address is Host B 192.168.2.2. At this point, it is found that the destination address is not on the same network segment as the local address, so packets destined for Host B need to be forwarded by router A.

2.Host An obtains the default gateway router An E0 through an ARP broadcast request with the MAC address 00-11-12-21-22-22. Host An encapsulates the IP packet into an Ethernet data frame at the data link layer. The source MAC address at the head of the Ethernet data frame is 00-11-12-21-11-11, and the destination MAC address is the MAC address 00-11-12-21-22-22 of the gateway E0 port. At this point, router A splits according to the data frames received, looks up its own routing table, finds the routing table entry that matches the IP address, reencapsulates it, and sends it to the next-hop address E1 interface.

3. When the Ethernet frame is reencapsulated on the E1 interface router A, the source MAC address is the E1 port MAC address 00-11-12-21-33-33 of router A, and the destination MAC address is the E1 port MAC address 00-11-12-21-44-44 of router B connected to it.

4. When router B receives a data frame from the E1 port, it also removes the encapsulation of the data link layer, checks the destination IP address, matches it with the routing table, and forwards the packet to the E0 interface according to the next hop information in the routing table. Router B discovers that the destination network segment is directly connected to its own E0 interface. Through ARP broadcast, router B obtains the MAC address 00-11-12-21-66-66 of the Host B Ethernet port. Router B then encapsulates the IP packet into an Ethernet frame, the source MAC address is the MAC address 00-11-12-21-55-55 of router B's E0 port, and the destination MAC address is the MAC address 00-11-12-21-66-66 of Host B. After encapsulation, the Ethernet frame is sent from the E0 interface to Host B.

Therefore, generally through the above four steps for packet forwarding and encapsulation, we can draw a rule: the IP address is always the same, the MAC address is always changing!

Switching domain routing comparison

-routing works at the network layer

Forward data according to the routing Table

Route selection

Routing Forwardin

-switching works at the data link layer

Forward data according to the MAC address Table

Hardware forwarding

Attached:

The methods that need to be used to debug the network:

1. Layer-by-layer check:

Check from the physical layer and check the port status to troubleshoot problems such as interface cables

Check whether the configuration of IP address and routing is correct.

two。 Segmented inspection:

Divide the network into small segments and eliminate errors one by one

Summary Overview

1. The router works in the network layer of the OSI reference model, and its important role is to choose the best path for the data treasure and finally deliver it to the destination. The routing table is a collection of route entries maintained in the router, and the router chooses the path according to the routing table.

two。 Static routes are unidirectional. If you want to achieve communication between both parties, you must configure a two-way static route on both sides of the communication.

3. A default route is a special static route that a router can make when there is no entry in the routing table that matches the destination address of the packet. If there is no default route, packets whose destination address does not match the table entry in the routing table will be discarded.

4. In the process of configuring routing, the network should be checked in layers and segments when troubleshooting. Hierarchical inspection can first be checked from the physical layer, while segmented inspection divides the network into multiple segments and eliminates errors segment by segment.

The experimental case of static routing principle and configuration can refer to the previous blog: https://blog.51cto.com/14481836/2427239.

Welcome to subscribe "Shulou Technology Information " to get latest news, interesting things and hot topics in the IT industry, and controls the hottest and latest Internet news, technology news and IT industry trends.

Views: 0

*The comments in the above article only represent the author's personal views and do not represent the views and positions of this website. If you have more insights, please feel free to contribute and share.

Share To

Servers

Wechat

© 2024 shulou.com SLNews company. All rights reserved.

12
Report