How routers work

**The working principle of the router
(1) The router decides how to forward the data packet according to the routing table
(2) The routing table stores the best path to the destination. The
destination network I send to whom I send from which port
192.168.10.0/24 192.168. 1.2 e0/0/1
(3) The router only cares about the network, not the specific IP address.
7. Formation
of the routing table Directly connected
192.168.1.0/24 Direct D 192.168.1.1 GigabitEthernet 0/0/0
2. Non-directly connected routes:
(1) It can be manually entered by the administrator (static route, default route)
(2) It can be automatically entered by the router Learning (need to configure routing protocol)

**Data sending process

**1、PC1发送数据到PC2,首先PC1发现PC2与自己不是同一网络,那么它要将数据发往路由器(网关192.168.1.1)
2、PC1将数据发网关时,要先获得网关的MAC地址,所以采用ARP协议获得。
3、PC1目标IP写上192.168.2.10,源IP写上192.168.1.10。目标MAC写的是网关GE0/0/0的MAC地址,源MAC写的是自己的MAC
4、交换机收到数据帧,看到帧的目标MAC地址是网关192.168.1.1的MAC地址。交换机查找自己的MAC地址表,然后将帧从e0/0/1发出
5、路由器收到数据后,看到数据包的目标IP地址是192.168.2.10。它将查看自己的路由表,路由表表明如果把数据发往192.168.2.0/24网络,只要把数据从g0/0/1发出即可
6、交换机收到数据帧,检查帧的目标MAC地址以及自己的MAC地址表,将帧从e0/0/2发出。

**路由的分类
1、直连路由(接口配置IP即出现)
2、静态路由(管理员手工配置),缺省路由可以看作是特殊的静态路由
3、动态路由(通过路由协议自动学习)

**静态路由

**1、如果需要PC1能PING通192.168.2.2,需要让R2知道如何把数据发回到192.168.1.0/24网络
[R2]ip route-static 192.168.1.0 255.255.255.0 192.168.2.1
2、如果希望PC1能PING通192.168.3.10,需要让R1知道如何把数据发送到192.168.3.0/24网络
[R1]ip route-static 192.168.3.0 255.255.255.0 192.168.2.2

**Conclusion
When configuring static routes, if the router needs to be able to access all network segments, routes to all networks must be configured on the router.


Guess you like

Origin http://43.154.161.224:23101/article/api/json?id=325686585&siteId=291194637