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

Analysis on the principle and configuration Theory of static routing

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

Share

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

[TOC]

Introduction: static routing is the first entry protocol in the network foundation.

​, we need to find out the context and understand the routing network segment.

Talk about the content:

1. How routers work

two。 The formation of routing table

3. Static and default routes (focus)

4. The encapsulation process of packets forwarded by a router

5. Configuration of static and default rout

1. How routing works 1.1 Overview of routin

It refers to the process of forwarding data from the source host to the destination host, that is, the process of addressing the logical address; routing can help you choose the shortest path.

The device that can forward the packet to the correct destination and choose the best path in the forwarding process is the router

1.2 how routers work

Forward data according to the routing table

Among them, the routing table is the key

two。 The formation of routing table

1. The routing table is a collection of route entries maintained in the router; the router makes path choices according to the routing table.

two。 There are directly connected and non-directly connected segments in the routing table.

Directly connected network segment: the router port is configured with an IP address and port UP status, resulting in a directly connected route

Non-directly connected network segment: a network segment that is not directly connected to a router is an undirectly connected network segment

(each port of a router represents a network segment; there are as many different network segments as there are ports, that is, how many directly connected network segments)

It can be understood like this: for every router, what grows on the router itself is the directly connected network segment, and if it does not grow on itself, it is the non-directly connected network segment.

3. For non-directly connected network segments, static or dynamic routes are required to add the network segments to the routing table

What is manually equipped is a static route

3. Static and default routes (focus)

1) static routing: it is manually configured by the administrator and is one-way, so it needs to be configured on other routers; therefore, it lacks flexibility and can only be used in small networks.

2) default route:

B means there is a default route, and the corresponding interface in the entry of the default route is the S0 interface of 192.168.2.2.

When there is one and only one path to another route, it is the default route.

3) priority of rout

When both a static route and a default route exist in the routing table, the static route has the highest priority and will be forwarded as soon as it matches.

If no static route is matched, it is forwarded according to the default route

4. The encapsulation process of packets forwarded by a router

The broadcast can not get through the router, and setting up the router is also one of the physical segmentation methods of broadcasting.

In the de-encapsulation process of the packet forwarded by the router, following the change of the source and destination address, ip change, mac is always changing * * the three-layer forwarding principle of the first interconnection between hosts between different network segments * *: (environment: the devices are connected for the first time, and the routing table has been configured)

. Host A goes to ping host B, knowing that the ip address of host B is 192.168.2.2, the data is divided into data segments, the data segments become packets, and the packets encapsulate data frames. The source IP of the data frame is 192.168.1.2, the source MAC is 00-11-12-21-11-11 (hereinafter referred to as 11), the destination IP is 192.168.2.2, and the destination MAC is the E0 port network card of Route A.

two。 Because this is the first connection, host A does not know the E0 port network card number of router A, and the data cannot be encapsulated, so host A sends an ARP broadcast frame to the E0 interface of route A (the source IP and source MAC of the broadcast frame are both host A, the destination IP is the IP of E0 port of route A, and the destination MAC is FF-FF-FF-FF-FF-FF).

3. Route A receives the broadcast frame through the E0 port and finds that the destination MAC is FF-FF-FF--FF-FF-FF. It will disassemble the MAC header and find that the destination IP is itself. It will give feedback to the broadcast frame, that is, send a unicast frame in the form of unicast (source IP address is 192.168.1.1, source MAC address: 00-11-12-21-22-22 (hereinafter referred to as 22) destination IP address 192.168.1.2 The target MAC is 11) to host A, and record the MAC address of host An in its own MAC table. When host A receives the MAC address, it meets the four elements. The E0MAC address of route An is recorded in its own MAC table, and the transmission of data frames can begin. Host An adds the destination MAC address and sends it to Route A.

4. Route A receives this data frame from port E0, looks at the destination MAC and finds that it is itself, then it disassembles the MAC header, reveals the IP address, looks at the network segment where the destination IP is located, compares it with its own routing table, finds the corresponding interface E1, starts MAC sealing and forwarding, the source IP address host A, the source MAC address is the MAC address 00-11-12-21-33-33 of the E1 port of route A (hereinafter referred to as 33), and the destination IP is host B. The destination MAC is the MAC address of the E1 port of route B. However, because of the first connection, the mac address table of Route A does not have the MAC address of the E1 port of Route B, so there is no corresponding destination address, so the data will be discarded this time.

5. Route A senses that it does not have the MAC address of route B's E1 interface and will actively send ARP broadcasts to it. In the broadcast frame, the source IP and source MAC addresses are themselves, the destination IP is the IP address of route B's E1 interface, and the destination MAC is FF-FF-FF-FF-FF-FF. Route B receives this broadcast frame and finds that the destination MAC is FF-FF-FF-FF-FF-FF. It will take apart the MAC header and learn to record the source MAC address (that is, the MAC address of the E1 port of Route A). When it finds that the destination IP address is itself, it will give feedback to the broadcast frame, that is, it will send a unicast frame in the form of unicast (the source IP address is 10.1.1.2). Source MAC address: 00-11-12-21-33-33 (hereinafter referred to as 33) destination IP address 10.1.1.1, destination MAC is 00-11-12-21-33-33) to the E1 port of Route A

6. Route A now looks at the broadcast frame, gets the MAC address of the E1 interface of Route B, and records it in its MAC table. At this time, the second PING packet sent by host An is sent again, because route A knows the MAC address of the E1 interface of route B, which meets the four elements and will be sent smoothly to the E1 port of route B. When the E1 interface of route B sees that the destination MAC is itself, it will take it apart to reveal the destination IP address. Route B compares the IP address 192.168.2.2 with its own routing table and finds that the corresponding network segment interface is E0, so it will encapsulate the data. Because it is the first connection, route B does not know the MAC address of host B, so the operation cannot be performed, and the second PING packet will be discarded here.

7. Route B sends a broadcast frame (source IP address is 192.168.2.1, source MAC address: 00-11-12-21-55-55, destination IP address 192.168.2.2, destination MAC address FF-FF-FF-FF-FF-FF) to host B, which receives the broadcast frame, records the source MAC address, removes the MAC header and finds that the destination IP address is itself. The unicast sends a thin frame (source IP address is 192.168.2.2, source MAC address: 00-11-12-21-66-66 destination IP address 192.168.2.1, destination MAC is 00-11-12-21-55-55).

8. When route B receives the unicast frame, it records the source MAC address, that is, the MAC address of host B. at this time, the third PING arrives, and route B meets the four elements, so it can forward the PING packet to host B. when host B receives and sends back, it is interconnected.

Three elements should be kept in mind when configuring a network card: ip, subnet mask, and gateway.

DA refers to the target ip,SA refers to the source IP

Comparison between switching and routing

ARP is a kind of broadcast, static route is a protocol, and DHCP is also a broadcast

The forwarding efficiency of the switch is higher than that of the route. the more routing tables, the lower the forwarding efficiency.

There is an address translation table in the router

5. Configuration of static and default rout

The default route is a directly connected network segment, and a directly connected network segment is not necessarily a default route

Static route: add non-directly connected network segment IP route network (network number, which refers to the identity of this network segment) mask (subnet mask) {} + + next-hop address (that is, the corresponding interface address)

Each interface on the router is a broadcast domain, and each interface on the switch is a collision domain

Each interface on the router is a broadcast domain

Each interface on the switch is a collision domain

Static routes are unidirectional and require two-way configuration

Configure instance one

Configuration instance two

R1 is the default route at this point

The next blog is a small experiment of using four routers to interconnect three hosts in different network segments, which can be followed.

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

Network Security

Wechat

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

12
Report