环境拓扑
R1配置
接口配置
R1#configure terminal
R1(config)#interface e1/0
R1(config-if)#ip address 40.1.1.2 255.255.255.0
R1(config-if)#no shutdown
R1(config-if)#exit
路由配置
R1(config)#ip route 0.0.0.0 0.0.0.0 40.1.1.1
R1(config)#end
R2配置
接口配置
R2#configure terminal
R2(config)#interface e1/0
R2(config-if)#no shutdown
R2(config-if)#ip address 40.1.1.1 255.255.255.0
R2(config-if)#exit
R2(config)#interface e1/1
R2(config-if)#no shutdown
R2(config-if)#ip address 30.1.1.2 255.255.255.0
R2(config-if)#exit
IPSec配置
# 配置预共享密钥
R2(config)#crypto isakmp key 123456 address 20.1.1.1 255.255.255.255
# 配置ike一阶段加密套件
R2(config)#crypto isakmp policy 1
R2(config-isakmp)#encryption 3des
R2(config-isakmp)#hash sha
R2(config-isakmp)#authentication pre-share
R2(config-isakmp)#group 2
R2(config-isakmp)#lifetime 86400
R2(config-isakmp)#exit
# 配置ike策略,引用加密套件
R2(config)#crypto isakmp profile ike_pro
R2(conf-isa-prof)#keyring default
R2(conf-isa-prof)#match identity address 20.1.1.1 255.255.255.255
R2(conf-isa-prof)#exit
# 配置感兴趣流
R2(config)#access-list 100 permit ip 40.1.1.0 0.0.0.255 10.1.1.0 0.0.0.255
# 配置ike二阶段算法,以及ike二阶段协商模式
R2(config)#crypto ipsec transform-set ipsec_tra esp-des esp-md5-hmac
R2(cfg-crypto-trans)#mode tunnel
R2(cfg-crypto-trans)#exit
# 配置map信息,引用ike一阶段和二阶段以及感兴趣流
R2(config)#crypto map ipsec_map 1 ipsec-isakmp
R2(config-crypto-map)#set peer 20.1.1.1
R2(config-crypto-map)#set transform-set ipsec_tra
R2(config-crypto-map)#set isakmp-profile ike_pro
R2(config-crypto-map)#match add 100
R2(config-crypto-map)#exit
# 接口引用map
R2(config)#interface e1/1
R2(config-if)#crypto map ipsec_map
R2(config-if)#exit
路由配置
R2(config)#ip route 20.1.1.0 255.255.255.0 30.1.1.1
R2(config)#ip route 10.1.1.0 255.255.255.0 30.1.1.1
R2(config)#end
R3配置
接口配置
R3#configure terminal
R3(config)#interface e1/2
R3(config-if)#ip address 20.1.1.2 255.255.255.0
R3(config-if)#no shutdown
R3(config-if)#interface e1/1
R3(config-if)#ip address 30.1.1.1 255.255.255.0
R3(config-if)#no shutdown
R3(config)#end
R4配置
接口配置
R4#configure terminal
R4(config)#interface e1/3
R4(config-if)#ip address 10.1.1.2 255.255.255.0
R4(config-if)#no shutdown
R4(config-if)#interf e1/2
R4(config-if)#no shutdown
R4(config-if)#ip address 20.1.1.1 255.255.255.0
R4(config-if)#exit
IPSec配置
R4(config)#crypto isakmp key 123456 address 30.1.1.2 255.255.255.255 # 设置ike预共享密钥及对端IP
# 设置加密套件
R4(config)#crypto isakmp policy 1
R4(config-isakmp)#encryption 3des
R4(config-isakmp)#hash sha
R4(config-isakmp)#authentication pre-share
R4(config-isakmp)#group 2
R4(config-isakmp)#lifetime 86400
R4(config-isakmp)#exit
# 配置ike策略,引用加密套件
R4(config)#crypto isakmp profile ike_pro
R4(conf-isa-prof)#keyring default
R4(conf-isa-prof)#match identity address 30.1.1.2 255.255.255.255
R2(conf-isa-prof)#exit
# 配置感兴趣流
R4(config)#access-list 100 permit ip 10.1.1.0 0.0.0.255 40.1.1.0 0.0.0.255
# 配置ike二阶段算法,以及ike二阶段协商模式
R4(config)#crypto ipsec transform-set ipsec_tra esp-des esp-md5-hmac
R4(cfg-crypto-trans)#mode tunnel
R4(cfg-crypto-trans)#exit
# 配置map信息,引用ike一阶段和二阶段以及感兴趣流
R4(config)#crypto map ipsec_map 1 ipsec-isakmp
R4(config-crypto-map)#set peer 30.1.1.2
R4(config-crypto-map)#set transform-set ipsec_tra
R4(config-crypto-map)#set isakmp-profile ike_pro
R4(config-crypto-map)#match address 100
R4(config-crypto-map)#exit
# 接口引用map
R4(config)#interface e1/2
R4(config-if)#crypto map ipsec_map
R4(config-if)#exit
路由配置
R4(config)#ip route 40.1.1.0 255.255.255.0 20.1.1.2
R4(config)#ip route 30.1.1.0 255.255.255.0 20.1.1.2
R5配置
接口配置
R5#configure terminal
R5(config)#interface e1/3
R5(config-if)#no shutdown
R5(config-if)#ip address 10.1.1.1 255.255.255.0
R5(config-if)#exit
路由配置
R5(config)#ip route 0.0.0.0 0.0.0.0 10.1.1.2
调试命令
查看IKEv1协商过程
debug crypto isakmp
查看IPSec转发过程
debug crypto ipsec
查看IPSec配置
show running-config | section crypto
查看IPSec sa
show crypto ipsec sa
查看map 信息
show crypto map