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 sends data to PC2. First, PC1 finds that PC2 is not in the same network as itself, so it will send the data to the router (gateway 192.168.1.1)
2. When PC1 sends data to the gateway, it must first obtain the MAC address of the gateway , so the ARP protocol is used to obtain it.
3. Write 192.168.2.10 on the destination IP of PC1, and write 192.168.1.10 on the source IP. The destination MAC is the MAC address of the gateway GE0/0/0, and the source MAC is its own MAC
. 4. The switch receives the data frame and sees that the destination MAC address of the frame is the MAC address of the gateway 192.168.1.1. The switch looks up its own MAC address table, and then sends the frame from e0/0/1
5. After the router receives the data, it sees that the destination IP address of the data packet is 192.168.2.10. It will check its own routing table, the routing table indicates that if the data is sent to the 192.168.2.0/24 network, as long as the data is sent from g0/0/1
6. The switch receives the data frame, checks the frame's destination MAC address and own MAC address table, send frames from e0/0/2.

**Route classification
1. Directly connected route (the interface is configured with IP)
2. Static route (manually configured by the administrator), the default route can be regarded as a special static route
3. Dynamic route (automatically learned through routing protocols)

**Static routing

**1. If you need PC1 to PING 192.168.2.2, you need to let R2 know how to send data back to the 192.168.1.0/24 network
[R2]ip route-static 192.168.1.0 255.255.255.0 192.168.2.1
2. If you want PC1 can ping 192.168.3.10, and R1 needs to know how to send data to the 192.168.3.0/24 network
[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=325787805&siteId=291194637