靜態路由--遞迴路由
實驗說明:
地址按照路由器的序號設定,例如R1為10.1.1.1 R2為10.1.1.2……
R1配置靜態路由,下一跳指向20.1.1.4
要求做到當某條鏈路出現故障的時候能快速切換線路通訊
準備知識:
ARP代理:ARP代理應答。通俗一點來說就是中間人/代理商
當收到一個ARP請求,是否應答,要滿足下面三點:
檢視請求者的源地址和目的地址是否在同一網段
代理ARP需要有ARP的源和目的地址的路由
代理ARP功能開啟
ARP表項在路由器中存活時間為4小時
對於路由器來說,路由器接收到ARP之後會檢測其合法性。判斷Reply應答者的IP所在的網段是否可達,可達即合法,不可達就會丟棄。
實驗步驟:
R1的配置
R1#conf t
R1(config-if)#ip add 10.1.1.1 255.255.255.0
R1(config-if)#no sh
R1(config-if)#int lo 0
R1(config-if)#ip add 172.16.1.1255.255.255.0
R1(config-if)#no sh
R1(config)#ip route 192.168.0.0 255.255.252.0f0/0 20.1.1.4 #靜態路由,下一跳為R4的介面地址
R1(config)#ip route 20.1.1.0 255.255.255.0f0/0 #去往下一跳的地址的路由,因為R2或者R3會冒充R4傳送應答給R1,所以要有應答者IP網段的路由,如果沒有,ARP報文會被丟棄
R1(config-if)#arp timeout 5 #修改
R2的配置
R2#conf t
R2(config)#int f0/0
R2(config-if)#ip add 10.1.1.2 255.255.255.0
R2(config-if)#no sh
R2(config-if)#int f0/1
R2(config-if)#ip add 20.1.1.2 255.255.255.0
R2(config-if)#no sh
R2(config-if)#exit
R2(config)#ip route 172.16.1.0255.255.255.0 f0/0 10.1.1.1
R2(config)#ip route 192.168.0.0255.255.252.0 f0/1 20.1.1.4 #參考
R3的配置
R3#conf t
R3(config)#int f0/0
R3(config-if)#ip add 10.1.1.3 255.255.255.0
R3(config-if)#no sh
R3(config-if)#int f0/1
R3(config-if)#ip add 20.1.1.3 255.255.255.0
R3(config-if)#no sh
R3(config)#ip route 172.16.1.0255.255.255.0 f0/0 10.1.1.1
R3(config)# ip route 192.168.0.0255.255.252.0 f0/1 20.1.1.4
R4的配置
R4(config)#int f0/0
R4(config-if)#ip add 20.1.1.4 255.255.255.0
R4(config-if)#no sh
R4(config-if)#int lo 0
R4(config-if)#ip add 192.168.0.1255.255.255.0
R4(config-if)#no sh
R4(config-if)#int lo 1
R4(config-if)#ip add 192.168.1.1255.255.255.0
R4(config-if)#no sh
R4(config-if)#int lo 2
R4(config-if)#ip add 192.168.2.1255.255.255.0
R4(config-if)#no sh
R4(config-if)#int lo 3
R4(config-if)#ip add 192.168.3.1255.255.255.0
R4(config-if)#no sh
R4(config-if)#arp timeout 5
R4(config)#ip route 172.16.1.0255.255.255.0 f0/0
測試:
R1#ping 192.168.0.1 source 172.16.1.1
Type escape sequence to abort.
Sending 5, 100-byte ICMP Echos to192.168.0.1, timeout is 2 seconds:
Packet sent with a source address of172.16.1.1
.!!!!
Success rate is 80 percent (4/5),round-trip min/avg/max = 36/56/64 ms
R1#
是可以通的哈。
下面測試故障切換效果:
在ping的時候把R2的鏈路down掉
R1#ping 192.168.0.1 source 172.16.1.1repeat 10000
Type escape sequence to abort.
Sending 10000, 100-byte ICMP Echos to192.168.0.1, timeout is 2 seconds:
Packet sent with a source address of172.16.1.1
!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!
!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!....!!.!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!
!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!
!!!!!!!!!!!!!!!!!!!!.
Success rate is 97 percent (225/231),round-trip min/avg/max = 12/57/108 ms
R1#
是可以自動切換的哈。
同樣,你可以把R2或者R3連線R4的鏈路down掉測試,也是可以切換的。
轉載於:https://blog.51cto.com/xiaowangzai/1868046