R1(E1/1口) — 網絡提供商(NP) — (E1/1口)R2
|
(E1/1口)
R3
一、實驗需求:
R1的一個出口能同時與R2和R3進行***的site to stie連接。
二、網絡環境:
R1、R2、R3的局域網段分別爲:192.168.1.0/24
192.168.2.0/24
192.168.3.0/24
R1、R2、R3的出口IP分別爲:10.10.1.2/30
10.10.2.2/30
10.10.3.2/30
NP的與3個路由器的對應IP爲:10.10.1.1/30
10.10.2.1/30
10.10.3.1/30
三、詳細配置:
NP只需在與3個路由器連接的接口上配置相應的IP地址即可。
R1
R1(config)# ip route 0.0.0.0 0.0.0.0 10.10.1.1
R1(config)# int e1/1
R1(config-if)# ip address 10.10.1.2 255.255.255.252
R1(config-if)# no shutdown
R1(config-if)# exit
#建立IKE策略,優先級爲100
R1(config)# crypto isakmp policy 10
#使用預共享的密碼進行身份驗證
R1 (isakmp-policy)# authentication pre-share
#使用hash md5加密方式
R1(isakmp-policy)# hash md5
#指定密鑰位數,group 2安全性更高,但更耗cpu
R1 (isakmp-policy)# group 2
R1 (isakmp-policy)# exit
設置要使用的預共享密鑰和指定***另一端路由器的IP地址(***鏈路兩端的密碼必須匹配。)
R1(config)# crypto isakmp key 0 R1ToR2 address 10.10.2.2
R1(config)# crypto isakmp key 0 R1ToR3 address 10.10.3.2
配置IPSec交換集,***這個名字可以隨便取,兩端的名字也可不一樣,但其他參數要一致。
R1(config)# crypto ipsec transform-set *** ah-md5-hmac esp-des esp-md5-hmac
#設置爲隧道模式
R1 (cfg-crypto-trans)# mode tunel
R1(cfg-crypto-trans)# exit
#創建加密圖
R1(config)# crypto map ***map 10 ipsec-isakmp
#標識對方路由器IP地址
R1 (config-crypto-map)# set peer 10.10.2.2
R1 (config-crypto-map)# set peer 10.10.3.2
#指定加密圖使用的IPSEC交換集
R1 (config-crypto-map)# set transform-set ***
#用ACL來定義加密的通信
R1 (config-crypto-map)# match address 110
#ipsec安全關聯存活期
R1 (config-crypto-map)# set security-association lifetime 86400
R1 (config-crypto-map)# exit
R1 (config)# ip access-list extend 110
R1(config-acl)# permit ip 192.168.1.0 0.0.0.255 192.168.2.0 0.0.0.255
R1(config-acl)# petmit ip 192.168.1.0 0.0.0.255 192.168.3.0 0.0.0.255
R1(config-acl)# exit
R1(config)# int e1/1
R1(config)# crypto map ***map
R2:
R2(config)# ip route 0.0.0.0 0.0.0.0 10.10.2.1
R2(config)# int e1/1
R2(config-if)# ip address 10.10.2.2 255.255.255.252
R2(config-if)# no shutdown
R2(config-if)# exit
R2(config)# crypto isakmp policy 10
R2 (isakmp-policy)# authentication pre-share
R2(isakmp-policy)# hash md5
R2 (isakmp-policy)# group 2
R2 (isakmp-policy)# exit
R2(config)# crypto isakmp key 0 R1ToR2 address 10.10.1.2
R2(config)# crypto ipsec transform-set *** ah-md5-hmac esp-des esp-md5-hmac
R2 (cfg-crypto-trans)# mode tunel
R2(cfg-crypto-trans)# exit
R2(config)# crypto map ***map 10 ipsec-isakmp
R2 (config-crypto-map)# set peer 10.10.1.2
R2 (config-crypto-map)# set transform-set ***
R2 (config-crypto-map)# match address 110
R2(config-crypto-map)# set security-association lifetime 86400
R2 (config-crypto-map)# exit
R2 (config)# ip access-list extend 110
R2(config-acl)# permit ip 192.168.2.0 0.0.0.255 192.168.1.0 0.0.0.255
R2(config-acl)# exit
R2(config)# int e1/1
R2(config)# crypto map ***map
R3:
R3(config)# ip route 0.0.0.0 0.0.0.0 10.10.3.1
R3(config)# int e1/1
R3(config-if)# ip address 10.10.3.2 255.255.255.252
R3(config-if)# no shutdown
R3(config-if)# exit
R3(config)# crypto isakmp policy 10
R3 (isakmp-policy)# authentication pre-share
R3(isakmp-policy)# hash md5
R3 (isakmp-policy)# group 2
R3 (isakmp-policy)# exit
R3(config)# crypto isakmp key 0 R1ToR3 address 10.10.1.2
R3(config)# crypto ipsec transform-set *** ah-md5-hmac esp-des esp-md5-hmac
R3 (cfg-crypto-trans)# mode tunel
R3(cfg-crypto-trans)# exit
R3(config)# crypto map ***map 10 ipsec-isakmp
R3 (config-crypto-map)# set peer 10.10.1.2
R3 (config-crypto-map)# set transform-set ***
R3 (config-crypto-map)# match address 110
R3 (config-crypto-map)# set security-association lifetime 86400
R3 (config-crypto-map)# exit
R3 (config)# ip access-list extend 110
R3(config-acl)# permit ip 192.168.3.0 0.0.0.255 192.168.1.0 0.0.0.255
R3(config-acl)# exit
R3(config)# int e1/1
R3(config)# crypto map ***map
四、配置驗證
Ping其***連接的各個對端網段的IP,測試其連通性,也可用下面命令查看:
#show crypto isakmp policy
命令可以查看所配置的IKE策略(通過兩個路由器上IKE策略的對比進行排錯)
#show crypto isakmp sa
可以查看***對等實體兩端的IP地址參數,如果協商不成功,是沒有這些參數出現的。
#show crypto ipsec sa
查看安全聯盟當前使用的設置。在ping的過程中,還能看到數據包的增加過程。
#show crypto isakmp key
可以查看***兩端的共享實體的IP地址或者主機名,預共享密鑰。
#show crypto ipsec security-association-lifetime
查看全局IPSec安全關聯生命週期。(注意:對等實體兩端是一樣的)
#show crypto ipsec transform-set
可以查看IPSec的工作模式以及變換集的配置。
#show crypto map
顯示所有配置在路由器上的Crypto Map,便於更詳細的查看。
六、 實驗總結:
1、 配置多條***隧道的時候,注意在端口只能應用一個Crypto Map,如果有多條***,應該將所有的crypto map定義相同的名稱。
2、 配置Crypto Map時候所使用的密鑰交換方式應該與IKE階段所配置的密鑰交換方式相同。
3、 配置交換集的時候,每種類型只能選擇一種參數。
4、 定義Crypto加密訪問列表時候,注意應用的先後次序,記得將特殊的放到前面,然後再將一般的放到後面。最後加上access-list access-list-number denyip any any,拒絕其它沒有數據通過。
5、 檢查Crypto加密訪問列表出錯,應該重新定義訪問列表,刪除或者添加某一條都不會生效的。
6、 檢查錯誤的時候,如果內容較多,也可以使用show running將兩個結果進行對比排錯。
7、 在配置*** IPSec之前最後讓全網都互通,可以使用ping命令,讓各自路由器裏都學習到其它路由器的路由條目,以免造成對實驗的干擾。
8、 配置IKE協商參數應該與對應的交換集保持一致。