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

Detailed explanation of static route and default route

2025-01-19 Update From: SLTechnology News&Howtos shulou NAV: SLTechnology News&Howtos > Servers >

Share

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

Understand the concept of routing, the concept of routing table. Learn how to manually configure routes, that is, the configuration of static and default routes. One: how the router works 1.1 routing explanation

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

Routing: the forwarding process from the source host to the destination host.

Routing technology: in order to improve the network access speed as much as possible, it is necessary to have a method to determine the best path from the source host to the destination host, so as to forward data.

1.2 how routers work

The router can be understood as the transit station of the Internet, and the packets in the network are forwarded to the destination network through a router.

The router forwards the packet by looking at the routing table to choose the best path to the destination network, which refers to the address of an interface of the router or the next-hop router. That is, check the destination network segment of the routing table and select the corresponding interface to go out.

The "destination address is unreachable" is displayed in the process of forwarding the packet: if the destination address of the packet is not found in the routing table, it is forwarded to the default interface or returns the "destination address unreachable" message to the user according to the configuration of the router.

Second, the formation of routing table 2.1 routing table interpretation

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

2.2 formation of routing tables

We understand it through directly connected and non-directly connected segments.

Directly connected network segment: when we configure the IP address of the interface on the router and the interface status is "UP", the directly connected route entry appears in the routing table.

In GNS3 software, we can practice it. The network segment of R3--R1 is 192.168.10.0, and that of R1--R2 is 192.168.20.0.

Non-directly connected network segment: look at the following picture! Network segments that are not directly connected to the router are not directly connected. Non-directly connected network segments are written into the routing table, which we need to achieve through static or dynamic routes.

Static route and default route 3.1 static route interpretation

Static routes are manually configured by the administrator and are one-way (if you want to achieve two-way communication, static routes must be configured on both sides of the communication), which lacks flexibility.

3.2 default route interpretation

The default route is a special static route. When the router cannot find the routing entry of the destination network in the routing table, the router sends the request to the default routing interface. If there is no default route, packets with destination addresses that do not match the route entry in the routing table are discarded.

3.3 problem: priority of rout

When there is both a static route and a default route in the routing table, the static route has the highest priority and will be forwarded immediately if it is matched. If there is no static route, it will be forwarded by the default route.

3.4 comparison between switching and routing

Fourth: the encapsulation process of the packet forwarded by the router

4.1 introduction to the environment

There are two initialization hosts in different network segments (only know their own IP and MAC addresses and other people's IP addresses, but do not know other people's MAC addresses), two initialized routers (only know their own IP and MAC addresses and other people's IP addresses, but do not know other people's MAC addresses).

4.2 the encapsulation process of packets forwarded by a router

Router forwarding principle: IP is the same, MAC is always changing.

The first process: to achieve the interconnection between host An and host B, because the two hosts are not in the same network segment, so the packet sent by host A to host B must go through the router, so it needs to be forwarded by router A. However, because they are all initialization machines, host A does not know the MAC address of router A's E0 interface, so host A needs to broadcast requests through ARP to obtain the MAC address of router A's E0 interface. At this point, in the packet sent by host A to host B, the source IP is 192.168.1.2, the source MAC is 00-11-12-21-11-11, the destination IP is 192.168.2.2, and the destination MAC is 00-11-12-21-22-22, and the destination MAC becomes the MAC of the E0 interface of host A.

The second process: after the E0 interface of router A receives the data frame, the MAC header of the data frame is unsealed, and the destination ip address is found to be 192.168.2.2, so router A will look up its own routing table and forward the packet to the E1 interface. Here, it is found that the MAC of router B's E1 interface cannot find the destination, so the packet is discarded.

The third process: now you need to know the MAC of router B's E1 interface and require router A to send an ARP broadcast request. After getting the MAC of router B's E1 interface, host A sends the packet again.

The fourth process: the packet arrives at the E1 interface of router B, unencapsulates it first, checks that the destination IP corresponds to its own routing table, and sends the data out of its own E0 interface. At this point, it is found that the MAC of host B is not known, so the packet is dropped again.

The fifth process: router B broadcasts through ARP to get the MAC of host B, then host A sends data packets again and can directly reach host B.

One question: why do ARP requests made by host An only get the MAC of router A's E0 interface?

A: ARP is a broadcast, each interface on the router is a broadcast domain, and the router is isolated for broadcasting, so ARP cannot pass through the router.

V: configuration of static routes and default routes 5.1 static route configuration

Network: destination network address

Mask: subnet mask

Address: the interface address of the next-hop router through which the destination network is reached

Interface: the local interface address that reaches the destination network

5.2 default route configuration

"0.0.0.0 0.0.0.0": represents any network, that is, packets destined for any network are forwarded to the next router interface address specified by the command.

Address: the interface address of the next-hop router through which the destination network segment is reached.

5.3 next-hop address

The receiving port address of the interconnected device.

5.4 static routing experiment I wrote a separate blog and am interested in checking it out for myself.

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