任务十一:部署GRE over IPSec

目录

目的

器材

拓扑

步骤

一、基本配置

1、配置GRE隧道,实现同一公司内网互通

2、创建IPSec安全提议

3、创建IKE安全提议,配置IKE对等体

4、创建安全框架

5、在接口加载和应用安全框架,并定义IPSec兴趣流

总结


目的

理解IPSec安全提议和IKE协商参数,掌握GRE over IPSec配置过程。

器材

路由器(AR2220):5台

主机:4台

拓扑

步骤

一、基本配置

1、配置GRE隧道,实现同一公司内网互通

详见任务十:

任务十

2、创建IPSec安全提议

[R1]ipsec proposal tran_A   //定义IPSec安全提议名称tran_A,名称取值string<1-15>
[R1-ipsec-proposal-tran_A]esp authentication-algorithm ?   //查询ESP封装采用的认证算法,摘要算法哈希值越大越安全,但会影响性能
  md5       Use HMAC-MD5-96 algorithm
  sha1      Use HMAC-SHA1-96 algorithm
  sha2-256  Use SHA2-256 algorithm
  sha2-384  Use SHA2-384 algorithm
  sha2-512  Use SHA2-512 algorithm
  sm3       Use SM3 algorithm
[R1-ipsec-proposal-tran_A]esp authentication-algorithm sha2-256

[R1-ipsec-proposal-tran_A]esp encryption-algorithm  ?   //查询ESP封装采用的加密算法,以下为对称加密算法,加密密钥和解密密钥相同,密钥长度越大越安全,但会影响性能。对称加密算法公开,保证密钥Key传输安全性即可。
  3des     Use 3DES
  aes-128  Use AES-128
  aes-192  Use AES-192
  aes-256  Use AES-256
  des      Use DES
  sm1      Use SM1
  <cr>     Please press ENTER to execute command 
[R1-ipsec-proposal-tran_A]esp encryption-algorithm aes-128 
[R1-ipsec-proposal-tran_A]quit



[R2]ipsec proposal tran_A	 //安全提议名称仅在本地有效,可与R1不同。建议同一公司【实例】安全提议名称相同,避免误解
[R2-ipsec-proposal-tran_A]esp authentication-algorithm sha2-256 	//认证算法与R1一致
[R2-ipsec-proposal-tran_A]esp encryption-algorithm aes-128 	  //加密算法与R1一致
[R2-ipsec-proposal-tran_A]quit
//GRE和IPSec相互独立,IPSec是可选项


[R3]ipsec proposal tran_B
[R3-ipsec-proposal-tran_B]esp authentication-algorithm md5 
[R3-ipsec-proposal-tran_B]esp encryption-algorithm 3des 	//3倍DES移位加密算法
[R3-ipsec-proposal-tran_B]quit 


[R4]ipsec proposal tran_B
[R4-ipsec-proposal-tran_B]esp authentication-algorithm md5 	
[R4-ipsec-proposal-tran_B]esp encryption-algorithm 3des 	
[R4-ipsec-proposal-tran_B]quit 

3、创建IKE安全提议,配置IKE对等体

[R1]ike proposal 1   //定义IKE【Internet Key Exchange,网络密钥交换协议】安全协议序号,取值Integer<1-99>。序号越小优先级越高。
[R1-ike-proposal-1]authentication-method ?  //查询IKE身份鉴别方式
  digital-envelope  Select digital envelope  key as the authentication method   //IKE v2不可用
  pre-share         Select pre-shared key as the authentication method  //默认方式
  rsa-signature     Select rsa-signature key as the authentication method  //需做额外配置

[R1-ike-proposal-1]authentication-method pre-share   //IKE双方身份鉴别方式采用pre-share【预共享密钥方式】本行命令可以不输入,查看当前配置也无法看到该脚本,因为默认方式即pre-share,除非更改其它鉴别方式,但要注意R1和R2双方必须使用相同的鉴别方式
[R1-ike-proposal-1]authentication-algorithm ?   //查询密钥交换身份鉴别算法
  aes-xcbc-mac-96  Select aes-xcbc-mac-96 as the hash algorithm
  md5              Select MD5 as the hash algorithm
  sha1             Select SHA as the hash algorithm  //IKE默认摘要鉴别算法
  sm3              Select sm3 as the hash algorithm  //需做额外配置

[R1-ike-proposal-1]authentication-algorithm sha1 //IKE密钥交换时采用的身份鉴别算法和IPSec提议中的ESP头采用的鉴别算法,两者没有直接关系,可采用不同摘要方式。采用默认sha1,可不输入本行命令
[R1-ike-proposal-1]encryption-algorithm ?  //查询密钥加密算法
  3des-cbc     168 bits 3DES-CBC
  aes-cbc-128  Use AES-128
  aes-cbc-192  Use AES-192
  aes-cbc-256  Use AES-256
  des-cbc      56 bits DES-CBC  //IKE默认加密算法

[R1-ike-proposal-1]encryption-algorithm aes-cbc-128  //对密钥加密与对ESP头部加密两者没有直接关系,可采用不同对称加密算法。但是R1和R2双方要协商一致
[R1-ike-proposal-1]dh ?   //查询IKE密钥交换采用的Diffie-Hellman组大小。密钥交换安全性随DH组长度而增加,但交换时间也加长
  group1   768 bits Diffie-Hellman group   默认DH组长度
  group14  2048 bits Diffie-Hellman group
  group2   1024 bits Diffie-Hellman group
  group5   1536 bits Diffie-Hellman group
	
[R1-ike-proposal-1]dh group1   //本行命令可以不输入,即使输入也无法在当前配置中查看该脚本,除非选用其它组
[R1-ike-proposal-1]sa duration ?  //查询IKE中SA生存周期,用于SA定时更新。SA快要失效前,IKE将自动为对等体双方协商新的SA
  INTEGER<60-604800>  Value of time(in seconds), default is 86400   //默认86400s,即60s×60min×24h=86400s=1d,默认每天定时更新SA
[R1-ike-proposal-1]sa duration 86400  //双方协商IKE SA时,R1和R2配置的SA生存周期时长可以不一致,实际生效以双方生存周期较小的为准
[R1-ike-proposal-1]quit 
[R1]ike peer companyA_R2 v2 //A公司中R1与R2双方交换密钥Key,R1的对等体(peer)为R2。创建与对等体协商的IKE参数集合,集合名称为companyA_R2。R1可以与多个分公司GRE VPN并协商IKE,建立不同IKE协商参数集合并命名以方便调用。IKE默认版本为v2。
[R1-ike-peer-companyA_R2]ike-proposal 1  //加载上述proposal 1中IKE安全提议
[R1-ike-peer-companyA_R2]pre-shared-key cipher gdcp  //对等体双方预共享密钥生成参数协商为gdcp,通过该参数动态生成密钥以周期更新密钥(默认每天更新)
[R1-ike-peer-companyA_R2]quit


[R2]ike  proposal 1  //序号仅在本地有效,与R1可以不同。建议同一公司(实例)IKE提议序号相同,以免误解
[R2-ike-proposal-1]authentication-algorithm sha1  //注意认证算法与R1一致
[R2-ike-proposal-1]encryption-algorithm aes-cbc-128  //注意加密算法与R1一致	
[R2-ike-proposal-1]quit 
[R2]ike peer companyA_R1 v2  //R2创建与对等体R1协商的IKE参数集合,集合名称为companyA_R1。注意与R1使用相同版本v2	
[R2-ike-peer-companyA_R1]ike-proposal 1 
[R2-ike-peer-companyA_R1]pre-shared-key cipher gdcp  //注意R1与R2双方协商的预共享密钥参数必须与R1严谨一致,区分大小写。但对于预共享密钥参数“gdcp”使用密文cipher保存还是使用simple明文保存在本地配置,可以不一样。
[R2-ike-peer-companyA_R1]quit 


[R3]ike proposal 2   //不同公司有不同的IKE认证和加密算法
[R3-ike-proposal-2]authentication-algorithm sha1 
[R3-ike-proposal-2]encryption-algorithm aes-cbc-128
[R3-ike-proposal-2]quit 
[R3]ike peer companyB_R4 v2
[R3-ike-peer-companyB_R4]ike-proposal 2
[R3-ike-peer-companyB_R4]pre-shared-key cipher huawei  //公司B路由器双方协商的生成预共享密钥参数为huawei
[R3-ike-peer-companyB_R4]quit 


[R4]ike proposal 2
[R4-ike-proposal-2]authentication-algorithm sha1  //注意认证算法与R3一致
[R4-ike-proposal-2]encryption-algorithm aes-cbc-128  //注意加密算法与R3一致	
[R4-ike-proposal-2]quit 
[R4]ike peer companyB_R3 v2
[R4-ike-peer-companyB_R3]ike-proposal 2
[R4-ike-peer-companyB_R3]pre-shared-key cipher huawei	
[R4-ike-peer-companyB_R3]quit 



4、创建安全框架

[R1]ipsec profile profile_A  //profile:概述、简介
[R1-ipsec-profile-profile_A]proposal tran_A  //加载IPSec安全提议参数集tran_A
[R1-ipsec-profile-profile_A]ike-peer companyA_R2  //加载与对等体R2协商的IKE参数集合companyA_R2,包含版本参数IKEv2、IKE安全提议ike-proposal 1(包含密钥加密和认证参数)、预共享密钥参数gdcp
[R1-ipsec-profile-profile_A]quit


[R2]ipsec profile profile_A
[R2-ipsec-profile-profile_A]proposal tran_A 	
[R2-ipsec-profile-profile_A]ike-peer companyA_R1 
[R2-ipsec-profile-profile_A]quit 


[R3]ipsec profile profile_B
[R3-ipsec-profile-profile_B]proposal tran_B 	
[R3-ipsec-profile-profile_B]ike-peer companyB_R4 
[R3-ipsec-profile-profile_B]quit


[R4]ipsec profile profile_B
[R4-ipsec-profile-profile_B]proposal tran_B 
[R4-ipsec-profile-profile_B]ike-peer companyB_R3 
[R4-ipsec-profile-profile_B]quit 

5、在接口加载和应用安全框架,并定义IPSec兴趣流

[R1]interface Tunnel 0/0/0
[R1-Tunnel0/0/0]ipsec profile profile_A   //在R1隧道tunnel 0/0/0接口加载公司A定义的安全框架profile_A 
[R1-Tunnel0/0/0]quit 
[R1]ip route-static 192.168.2.0 255.255.255.0 Tunnel 0/0/0  //配置静态路由,同时也定义受IPSec保护的兴趣流。从tunnel 0/0/0发出去的数据包需要经过IPSec封装保护



[R2]interface Tunnel 0/0/0
[R2-Tunnel0/0/0]ipsec profile profile_A 
[R2-Tunnel0/0/0]quit
[R2]ip route-static 192.168.1.0 255.255.255.0 Tunnel 0/0/0


[R3]interface Tunnel 0/0/0
[R3-Tunnel0/0/0]ipsec profile  profile_B 
[R3-Tunnel0/0/0]quit 
[R3]ip route-static 192.168.4.0 255.255.255.0 Tunnel 0/0/0


[R4]interface Tunnel 0/0/0	
[R4-Tunnel0/0/0]ipsec profile profile_B 
[R4-Tunnel0/0/0]quit 
[R4]ip route-static 192.168.3.0 255.255.255.0 Tunnel 0/0/0

可以自行测试一下:

主机1ping主机2,主机3ping主机4

总结

1)IPSec【Internet Protocol Security】目前不会对源数据包中的Data数据段进行加密。原因1:用户的密码字段加密本应通过HTTPS协议实现,IPSec没必要进行二次加密;原因2:Data数据段很长,加密需要消耗大量计算资源,导致路由器成为网络瓶颈,并不现实。

2)现阶段使用IPSec目的在于ESP【Ecapsulating Security Payload,封装安全载荷协议】封装时只对数据包头部进行身份鉴别和完整性验证,不包含Data数据段,也不对Data数据段安全性负责。就像邮递员只检查快递外包装,核实收件人和寄件人身份(身份鉴别),检查快递在途中是否被拆封(完整性认证),而不检查其内部物品是否完好。而且若寄件人本身邮寄的物品是坏的,快递员也没有义务进行修复。

3)IPSec仅是一种安全框架,并不是具体的实现方式,实现方式由具体算法和协议负责实施。受路由器硬件性能限制,目前对称加密算法和协议只应用于数据包头部,不排除日后路由器性能得到很大提升后,即使对Data数据段实施算法加密也对性能影响有限,此时协议也需同步升级。

【后续内容自行了解】

加密算法:对称(DES、3DES、AES)和非对称(RSA、DH)

摘要算法【验证算法/HASH算法】:单向性,无法逆向推导。MD5、SHA1【Secure Hash Algorithm,安全散列算法】、SHA2

封装协议:AH【Authentication Header,认证头协议】、ESP

封装模式:传输模式、隧道模式

  • 22
    点赞
  • 16
    收藏
    觉得还不错? 一键收藏
  • 打赏
    打赏
  • 0
    评论

“相关推荐”对你有帮助么?

  • 非常没帮助
  • 没帮助
  • 一般
  • 有帮助
  • 非常有帮助
提交
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包

打赏作者

小汐睡着了

你的鼓励将是我创作的最大动力

¥1 ¥2 ¥4 ¥6 ¥10 ¥20
扫码支付:¥1
获取中
扫码支付

您的余额不足,请更换扫码支付或充值

打赏作者

实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值