IPSec介紹:
IPSec是由IETF制定的,用於保障在internet上傳輸資料的安全保密性的框架協議。
下面將使用一個例項來演示IPSec的配置過程。
裝置清單:
DCR-2655路由器兩臺 PC機兩臺
R1: f0/0 192.168.0.1/24 s0/1 192.168.1.1/24 R2: f0/0 192.168.2.1/24 s0/2 192.168.1.2/24 PC1: 192.168.0.2/24 PC2: 192.168.2.2/24
show running-config:
R1:
! hostname R1 ! ! gbsc group default ! ! crypto isakmp key password 192.168.1.2 255.255.255.255 #配置IKE預共享金鑰與對端IP ! ! crypto isakmp policy 10 #配置IKE策略 hash md5 #設定數字簽名演算法 ! crypto ipsec transform-set one #設定變換集 transform-type esp-des esp-md5-hmac #設定加密演算法與變換型別 ! crypto map my 10 ipsec-isakmp #配置加密對映表 set peer 192.168.1.2 #設定對等體的IP地址 set transform-set one #關聯變換集 match address 101 #指定要加密的流量 ! ! interface FastEthernet0/0 ip address 192.168.0.1 255.255.255.0 no ip directed-broadcast ! interface GigaEthernet0/3 no ip address no ip directed-broadcast ! interface GigaEthernet0/4 no ip address no ip directed-broadcast ! interface GigaEthernet0/5 no ip address no ip directed-broadcast ! interface GigaEthernet0/6 no ip address no ip directed-broadcast ! interface Serial0/1 ip address 192.168.1.1 255.255.255.0 no ip directed-broadcast crypto map my #將加密對映表應用到埠 ! interface Serial0/2 no ip address no ip directed-broadcast ! interface Async0/0 no ip address no ip directed-broadcast ! ! ip route default 192.168.1.2 ! ! ip access-list extended 101 permit ip 192.168.0.0 255.255.255.0 192.168.2.0 255.255.255.0 !
R2:
! hostname R2 ! ! gbsc group default ! ! crypto isakmp key password 192.168.1.1 255.255.255.255 #預共享金鑰要與R1一致 ! ! crypto isakmp policy 10 #IKE策略配置要與R1一致 hash md5 ! crypto ipsec transform-set one transform-type esp-des esp-md5-hmac #變換集加密演算法及變換型別要與R1一致 ! crypto map my 10 ipsec-isakmp #金鑰協商方式要與R1一致 set peer 192.168.1.1 set transform-set one match address 101 ! ! interface FastEthernet0/0 ip address 192.168.2.1 255.255.255.0 no ip directed-broadcast ! interface GigaEthernet0/3 no ip address no ip directed-broadcast ! interface GigaEthernet0/4 no ip address no ip directed-broadcast ! interface GigaEthernet0/5 no ip address no ip directed-broadcast ! interface GigaEthernet0/6 no ip address no ip directed-broadcast ! interface Serial0/1 no ip address no ip directed-broadcast ! interface Serial0/2 ip address 192.168.1.2 255.255.255.0 no ip directed-broadcast crypto map my physical-layer speed 64000 ! interface Async0/0 no ip address no ip directed-broadcast ! ! ip route default 192.168.1.1 ! ! ip access-list extended 101 permit ip 192.168.2.0 255.255.255.0 192.168.0.0 255.255.255.0 !
測試:
檢視安全聯盟資訊。
R1#show crypto ipsec sa
列印出安全聯盟的資訊既是成功建立安全聯盟,若沒有成功建立則僅會返回如下的資訊。
使用PC1 ping PC2,ping通既完成本實驗(開始時會超時,耐心等待一會)。
名詞解釋:
IKE:
簡而言之,IKE是用來協商並建立安全聯盟的,兩端都需要設定一個預共享金鑰來認證對方身份。當然,也可以不使用IKE而使用手工方式建立安全聯盟,本文中不討論這種形式。
變換集:
變換集是用來加密傳輸的資料的(需指定加密演算法與變換型別),加密時兩端會使用非對稱金鑰,比較安全。
主要配置步驟及相關命令:
一、確定要經過VPN保護的資料流量
使用訪問控制列表定義即可。
二、IKE策略設定
crypto isakmp policy 優先順序<1-1000>
其下包含的命令:
authentication -- 設定驗證方法 encryption -- 設定加密演算法 group -- 設定Diffie-Hellman小組 hash -- 設定完整性演算法 lifetime -- 設定ISAKMP SA的生命週期
三、設定IKE預共享秘鑰
crypto isakmp key 金鑰 對端IP 對端IP的掩碼(預設是32位)
四、變換集設定
crypto ipsec transform-set 變換集名稱
其下包含的命令:
mode -- 封裝模式 transform-type -- 變換型別
五、配置IPSec加密對映(自動協商)
crypto map 對映表名稱 序列號 ipsec-isakmp<自動協商金鑰,手工配置為ipsec-manual>
其下包含的命令:
id -- 設定身份驗證引數 match -- 匹配值 mode -- ISAKMP採用模式 set -- 設定加/減密引數
六、進入介面,應用IPSec加密對映
interface 介面名 crypto map 對映表的名稱