配置靜態路由實驗全網互通
實驗環境:
實驗要求:需要在三臺路由器上配置靜態路由,以實現各網段之間的互通。
R1Loopback 0配置192.168.10.1/24
R1F0/0接口配置192.168.1.1/24
R1F0/1
R2Loopback 0配置192.168.20.1/24
R2F0/0接口配置192.168.3.2/24
R2F0/1接口配置192.168.1.2/24
R3Loopback 0配置192.168.30.1/24
R3F0/0接口配置192.168.2.3/24
R3F0/1接口配置192.168.3.3/24
實驗過程:
1. 配置R1各接口IP地址
R1#conf t
Enter configuration commands, one per line. End with CNTL/Z.
R1(config)#int lo
R1(config)#int loopback 0
R1(config-if)#ip add 192.168.10.1 255.255.255.0
R1(config-if)#no sh
R1(config-if)#int f0/0
R1(config-if)#ip add 192.168.1.1 255.255.255.0
R1(config-if)#no sh
R1(config-if)#int f0/1
R1(config-if)#ip add 192.168.2.1 255.255.255.0
R1(config-if)#no sh
檢查R1各接口IP地址是否正確
R1#show ip interface B
Interface IP-Address OK? Method Status Protocol
FastEthernet0/0 192.168.1.1 YES manual up up
FastEthernet0/1 192.168.2.1 YES manual up up
Loopback0 192.168.10.1 YES manual up up
2. 配置R2各接口IP地址
R2#conf t
Enter configuration commands, one per line. End with CNTL/Z.
R2(config)#int lo
R2(config)#int loopback 0
R2(config-if)#ip add 192.168.20.1 255.255.255.0
R2(config-if)#no sh
R2(config-if)#int f0/0
R2(config-if)#ip add 192.168.3.2 255.255.255.0
R2(config-if)#no sh
R2(config-if)#int f0/1
R2(config-if)#ip add 192.168.1.2 255.255.255.0
R2(config-if)#no sh
檢查R2各接口IP地址是否正確
R2#show ip interface B
Interface IP-Address OK?Method Status Protocol
FastEthernet0/0 192.168.3.2 YES manual up up
FastEthernet0/1 192.168.1.2 YES manual up up
Loopback0 192.168.20.1 YES manual up up
3. 配置R3各接口IP地址
R3#conf t
Enter configuration commands, one per line. End with CNTL/Z.
R3(config)#int lo
R3(config)#int loopback 0
R3(config-if)#ip add 192.168.30.1 255.255.255.0
R3(config-if)#no sh
R3(config-if)#int f0/0
R3(config-if)#ip add 192.168.2.3 255.255.255.0
R3(config-if)#no sh
R3(config-if)#int f0/1
R3(config-if)#ip add 192.168.3.3 255.255.255.0
R3(config-if)#no sh
檢查R3各接口IP地址是否正確
R3#show ip interface B
Interface IP-Address OK? MethodStatus Protocol
FastEthernet0/0 192.168.2.3 YES manual up up
FastEthernet0/1 192.168.3.3 YES manual up up
Loopback0 192.168.30.1 YESmanual up up
4. 在R1上配置靜態路由
R1#conf t
Enter configuration commands, one per line. End with CNTL/Z.
R1(config)#ip route 192.168.20.0 255.255.255.0192.168.1.2
R1(config)#ip route 192.168.3.0 255.255.255.0192.168.1.2
R1(config)#ip route 192.168.30.0 255.255.255.0192.168.1.2
5.在R2上配置靜態路由
R2#conf t
Enterconfiguration commands, one per line. End with CNTL/Z
R2(config)#iproute 192.168.30.0 255.255.255.0 192.168.3.3
R2(config)#iproute 192.168.2.0 255.255.255.0 192.168.3.3
R2(config)#iproute 192.168.10.0 255.255.255.0 192.168.3.3
6. 在R3上配置靜態路由
R3#conf t
Enter configuration commands, one per line. End with CNTL/Z.
R3(config)#ip route 192.168.10.0 255.255.255.0192.168.2.1
R3(config)#ip route 192.168.1.0 255.255.255.0192.168.2.1
R3(config)#ip route 192.168.20.0 255.255.255.0192.168.2.1
6.進行ping通測試,測試個網段是否互通
R1#ping192.168.30.1
Type escapesequence to abort.
Sending 5,100-byte ICMP Echos to 192.168.30.1, timeout is 2 seconds:
!!!!!
Success rate is100 percent (5/5), round-trip min/avg/max = 44/64/100 ms
R1#ping192.168.20.1
Type escapesequence to abort.
Sending 5,100-byte ICMP Echos to 192.168.20.1, timeout is 2 seconds:
!!!!!
Success rate is100 percent (5/5), round-trip min/avg/max = 28/56/68 ms
R2#ping192.168.10.1
Type escapesequence to abort.
Sending 5,100-byte ICMP Echos to 192.168.10.1, timeout is 2 seconds:
!!!!!
Success rate is100 percent (5/5), round-trip min/avg/max = 28/58/96 ms
R2#ping 192.168.20.1
Type escapesequence to abort.
Sending 5,100-byte ICMP Echos to 192.168.20.1, timeout is 2 seconds:
!!!!!
Success rate is100 percent (5/5), round-trip min/avg/max = 1/2/4 ms
R3#ping192.168.10.1
Type escapesequence to abort.
Sending 5, 100-byteICMP Echos to 192.168.10.1, timeout is 2 seconds:
.!!!!
Success rate is80 percent (4/5), round-trip min/avg/max = 44/67/96 ms
R3#ping192.168.20.1
Type escapesequence to abort.
Sending 5,100-byte ICMP Echos to 192.168.20.1, timeout is 2 seconds:
..!!!
Success rate is60 percent (3/5), round-trip min/avg/max = 52/89/116 ms
實驗總結:路由器在對非直連網段就需要通過靜態路由指定路由條目,路由器轉發數據是根據數據包中的目標地址所對應的條目。靜態路由是設置是根據目標網段和下一跳接口組成。
配置靜態路由實驗全網互通