1. 程式人生 > 實用技巧 >靜態路由--遞迴路由

靜態路由--遞迴路由

實驗說明:

wKioL1gYLW7Q0BxZAABzxltkuFA295.png

地址按照路由器的序號設定,例如R110.1.1.1 R210.1.1.2……

R1配置靜態路由,下一跳指向20.1.1.4

要求做到當某條鏈路出現故障的時候能快速切換線路通訊

準備知識:

  1. ARP代理:ARP代理應答。通俗一點來說就是中間人/代理商

當收到一個ARP請求,是否應答,要滿足下面三點:

  1. 檢視請求者的源地址和目的地址是否在同一網段

  2. 代理ARP需要有ARP的源和目的地址的路由

  3. 代理ARP功能開啟

  4. ARP表項在路由器中存活時間為4小時

  5. 對於路由器來說,路由器接收到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 #修改

ARP超時的時間,如果時間過長,切換效果會大打則扣,當時時間過短,會浪費頻寬,在這種實驗的環境下就無所謂。

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 #參考

ARP代理是否應答的條件的第2條,代理ARP需要擁有源和目的網段的路由。

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