版权声明:本文为博主原创文章,转载请附带此文链接。 https://blog.csdn.net/ever_peng/article/details/89478343
1、拓扑图
R2和R3建立IPSec隧道
2、配置命令
R1:
R1#configure terminal
R1(config)#interface FastEthernet 0/0
R1(config-if)#ip address 10.10.10.2 255.255.255.0
R1(config-if)#no shutdown
R1(config-if)#end
R2:
#配置接口地址
R2#configure terminal
R2(config)#interface FastEthernet 0/0
R2(config-if)#ip address 10.10.10.1 255.255.255.0
R2(config-if)#no shutdown
R2(config-if)#exit
R2(config)#interface Ethernet 1/0
R2(config-if)#ip address 11.11.11.1 255.255.255.0
R2(config-if)#no shutdown
R2(config-if)#exit
#IKE配置
#建立IKE协商策略
R2(config)#crypto isakmp policy 1
#加密算法使用3des
R2(config-isakmp)#encryption 3des
#设置密钥验证所用的算法
R2(config-isakmp)#hash sha
#使用的预先共享的密钥认证
R2(config-isakmp)#authentication pre-share
#DH组使用2
R2(config-isakmp)#group 2
#IKE隧道生命周期86400秒
R2(config-isakmp)#lifetime 86400
#退出IKE配置
R2(config-isakmp)#exit
#配置预共享密钥为123123
R2(config)#crypto isakmp key 123123 address 13.13.13.2
#配置感兴趣流
R2(config)#access-list 100 permit ip 10.10.10.0 0.0.0.255 12.12.12.0 0.0.0.255
#配置IPSec加密认证算法
R2(config)#crypto ipsec transform-set benet esp-des ah-sha-hmac
#使用主模式建立连接
R2(cfg-crypto-trans)#mode tunnel
#退出IPSec配置
R2(cfg-crypto-trans)#exit
#IPSec隧道生命周期86400
R2(config)#crypto ipsec security-association lifetime seconds 86400
#配置静态的crypto map,需要指定名称和序列号,数值越小优先级越高。
R2(config)#crypto map mapmap 1 ipsec-isakmp
#指定IPsec的对等体设备
R2(config-crypto-map)#set peer 13.13.13.2
#指定传输集的名称
R2(config-crypto-map)#set transform-set benet
#调用crypto ACL
R2(config-crypto-map)#match address 100
#配置PFS为1
R1(config-crypto-map)#set pfs group1
#退出map配置
R2(config-crypto-map)#exit
#进入接口配置
R2(config)#interface Ethernet 1/0
#应用map配置
R2(config-if)#crypto map mapmap
#退出接口配置
R2(config-if)#exit
#配置前往R4的路由
R2(config)#ip route 12.0.0.0 255.0.0.0 11.11.11.2
#配置前往R3的路由
R2(config)#ip route 13.0.0.0 255.0.0.0 11.11.11.2
R3:
#R3
#配置接口地址
R3#configure terminal
R3(config)#interface FastEthernet 0/0
R3(config-if)#ip address 12.12.12.1 255.255.255.0
R3(config-if)#no shutdown
R3(config-if)#exit
R3(config)#interface Ethernet 1/1
R3(config-if)#ip address 13.13.13.2 255.255.255.0
R3(config-if)#no shutdown
R3(config-if)#exit
#IKE配置
#建立IKE协商策略
R3(config)#crypto isakmp policy 1
#加密算法使用3des
R3(config-isakmp)#encryption 3des
#设置密钥验证所用的算法
R3(config-isakmp)#hash sha
#使用的预先共享的密钥认证
R3(config-isakmp)#authentication pre-share
#DH组使用2
R3(config-isakmp)#group 2
#IKE隧道生命周期86400秒
R3(config-isakmp)#lifetime 86400
#退出IKE配置
R3(config-isakmp)#exit
#配置预共享密钥为123123
R3(config)#crypto isakmp key 123123 address 11.11.11.1
#配置感兴趣流
R3(config)#access-list 100 permit ip 12.12.12.0 0.0.0.255 10.10.10.0 0.0.0.255
#配置IPSec加密认证算法
R3(config)#crypto ipsec transform-set benet esp-des ah-sha-hmac
#使用主模式建立连接
R3(cfg-crypto-trans)#mode tunnel
#退出IPSec配置
R3(cfg-crypto-trans)#exit
#IPSec隧道生命周期86400
R3(config)#crypto ipsec security-association lifetime seconds 86400
#配置静态的crypto map,需要指定名称和序列号,数值越小优先级越高。
R3(config)#crypto map mapmap 1 ipsec-isakmp
#指定IPsec的对等体设备
R3(config-crypto-map)#set peer 11.11.11.1
#指定传输集的名称
R3(config-crypto-map)#set transform-set benet
#调用crypto ACL
R3(config-crypto-map)#match address 100
#配置PFS为1
R1(config-crypto-map)#set pfs group1
#退出map配置
R3(config-crypto-map)#exit
#进入接口配置
R3(config)#interface Ethernet 1/1
#应用map配置
R3(config-if)#crypto map mapmap
#退出接口配置
R2(config-if)#exit
#配置前往R2的路由
R3(config)#ip route 11.0.0.0 255.0.0.0 13.13.13.1
#配置前往R1的路由
R3(config)#ip route 10.0.0.0 255.0.0.0 13.13.13.1
R4:
R4#configure terminal
R4(config)#interface FastEthernet 0/0
R4(config-if)#ip address 12.12.12.2 255.255.255.0
R4(config-if)#no shutdown
R4(config-if)#end
R5:
R5#configure terminal
R5(config)#interface Ethernet 1/0
R5(config-if)#ip address 11.11.11.2 255.255.255.0
R5(config-if)#no shutdown
R5(config-if)#exit
R5(config)#interface Ethernet 1/1
R5(config-if)#ip address 13.13.13.1 255.255.255.0
R5(config-if)#no shutdown
R5(config-if)#exit
结果验证:
R1 ping R4,能够ping通,在R2和R5之间抓包,发现数据包经过了ESP的封装加密