Now there are five devices: pC1 connected to rout1, rout1 connected to rout2, rout2 connected to rout3, and rout3 connected to PC2. The topology is shown below:
□---- ○ ---- □
PC1 rout1 rout2 rout3 PC2
The static IP addresses of the five devices are:
PC1 192.168.1.88/24
Rout1 192.168.1.128/24 192.168.2.128/24
Rout2 192.168.2.66/24 192.168.3.66/24
Rout3 192.168.3.100/24 192.168.4.33/24
PC2 192.168.4.66/24
The pC1 configuration is as follows:
# Ifconfig eth0 192.168.1.88 netmask 255.255.255.0
# Route add default GW 192.168.1.128
Configure rout1 as follows:
# Ifconfig eth0 192.168.1.128 netmask 255.255.255.0
# Ifconfig eth0: 1 192.168.2.128 netmask 255.255.255.0
# Route add-net 192.168.4.0/24 GW 192.168.2.66
Configure rout2 as follows:
# Ifconfig eth0 192.168.2.66 netmask 255.255.255.0
# Ifconfig eth0: 1 192.168.3.66 netmask 255.255.255.0
# Route add-net 192.168.1.0/24 GW 192.168.2.128
# Route add-net 192.168.4.0/24 GW 192.168.3.100
Configure rout3 as follows:
# Ifconfig eth0 192.168.3.100 netmask 255.255.255.0
# Ifconfig eth0: 1 192.168.4.33 netmask 255.255.255.0
# Route add-net 192.168.1.0/24 GW 192.168.3.66
The PC2 configuration is as follows:
# Ifconfig eth0 192.168.4.66 netmask 255.255.255.0
# Route add default GW 192.168.4.33
In this way, pC1 can ping pc2.
Note:
The above three routers are replaced by three PCs. To replace a router with a computer, you must enable the IP forwarding function of the computer. Change the content in/proc/sys/NET/IPv4/ip_forward to 1 (the default value is 0 ), run the following command to complete
# E Cho 1>/proc/sys/NET/IPv4/ip_forward
After the network is restarted, the above file is automatically changed to 0
Add several commands:
1. Delete the default route
# Route del default
2. View routes
# Route-n
3. Set a route entry for a specified CIDR Block
# Route add-net 192.168.3.0 netmask 255.255.255.0 GW 192.168.6.66
Or
# Route add-net 192.168.3.0/24 GW 192.168.6.66
4. delete a route entry
# Route del-net 192.168.3.0 netmask 255.255.255.0
Or
# Route del-net 192.168.3.0/24