神州數碼路由器下IPSec VPN配置方法簡介

IPSec介紹:
IPSec是由IETF制定的,用於保障在internet上傳輸數據的安全保密性的框架協議。
下面將使用一個實例來演示IPSec的配置過程。
設備清單:

DCR-2655路由器兩台
PC機兩台

拓撲:

IP地址表:

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 映射表的名稱