« Internet Key ExchangeGRE over IPSec »

IPSec over GRE

注意:这里是IPSec over GRE,而不是GRE over IPSec,仅仅是将某些经过加密的流量放到GRE中去跑,首先GRE隧道必须UP,而不是对整个隧道的流量进行加密

试验拓扑:

R2配置:

hostname R2
!
crypto isakmp policy 1
 authentication pre-share   //这里的认证方式使用的是预共享密钥
crypto isakmp key fuck address 192.168.34.4  //配置预共享密钥
!
crypto ipsec transform-set trans esp-des esp-sha-hmac
 mode transport   //配置为传输模式
!
crypto map mm 10 ipsec-isakmp
 set peer 192.168.34.4
 set transform-set trans
 match address toR4
!
interface Tunnel0
 ip address 192.168.24.2 255.255.255.0
 tunnel source Ethernet1/1
 tunnel destination 192.168.34.4
 crypto map mm
!
interface Ethernet1/0
 ip address 192.168.1.254 255.255.255.0
!
interface Ethernet1/1
 ip address 192.168.23.2 255.255.255.0
!
ip route 0.0.0.0 0.0.0.0 192.168.23.3
ip route 192.168.2.0 255.255.255.0 Tunnel0
!
ip access-list extended toR4
 permit ip 192.168.1.0 0.0.0.255 192.168.2.0 0.0.0.255
!

 

R4配置:

hostname R4
!
crypto isakmp policy 1
 authentication pre-share
crypto isakmp key fuck address 192.168.23.2
!
crypto ipsec transform-set trans esp-des esp-sha-hmac
!        
crypto map mm 10 ipsec-isakmp
 set peer 192.168.23.2
 set transform-set trans
 match address toR2
!
interface Tunnel0
 ip address 192.168.24.4 255.255.255.0
 tunnel source Ethernet1/2
 tunnel destination 192.168.23.2
 crypto map mm
!
interface Ethernet1/2
 ip address 192.168.34.4 255.255.255.0
!
interface Ethernet1/3
 ip address 192.168.2.254 255.255.255.0
!
ip route 0.0.0.0 0.0.0.0 192.168.34.3
ip route 192.168.1.0 255.255.255.0 Tunnel0
!
ip access-list extended toR2
 permit ip 192.168.2.0 0.0.0.255 192.168.1.0 0.0.0.255
!
 

这里IPsec配置为传输模式,由于GRE会在原始数据包的外面加个自己的IP包头,所以也就没必要再去加密原包头并添加新包头了,这样可以节省20bytes的IPSec包头 

由于GRE隧道是先UP的,所以可以使用下面命令查看isakmp和IPSec安全联结有没有建立成功:
Show crypto isakmp sa
Show crypto ipsec sa
 

最后进行验证,从192.168.2.0网段去ping192.168.1.0网段,可以成功看到ISAKMP 安全联结建立成功,并且ICMP数据包已经成功被加密

  • [引用] 2.xmw80888
  • 在网上找到了好几篇写IPsec Over GRE的实验,结果发现都是用两端的物理口来起IPsec隧道,然后在GRE tunnel里面绑定加密图,这样做还会被GRE封装吗???

    凭直觉感到这样做只是被IPsec封装了,今天自己做实验验证了一下,抓包显示的确是这样。博主做这个实验时难道实现了IPsec Over GRE的效果?

    鄙人粗浅理解应该这样做比较靠谱:用tunnel口的地址来起IPsec,同时把私网的流量通过静态路由引到tunnel口上,也就是将博主的配置中对等体地址改成tunnel口地址,当然预共享密钥验证也要作相应修改。这样私网流量先被路由到tunnel口,之后路由器发现相应的加密图,交由IPsec封装,打上两个tunnel口地址的IP头,最后由本端tunnel口地址去往对端tunnel口地址的普通IP包由GRE隧道来处理。这个思路我已经在一款国产设备上验证过,抓包显示实现了IPsec Over GRE的效果。但是郁闷的是用思科设备这样做时 IPsec封装的源IP是物理接口地址,只有目的IP是tunnel地址,因此无法协商成功。博主能给予指点吗?
    godupgod 于 2009-11-16 16:37:40 回复
    什么叫做“用两端的物理口来起IPsec隧道,然后在GRE tunnel里面绑定加密图”
    哪个接口绑定的crypto-map,应该就是用那个接口起的IPSec隧道,
    这里IPSec对端应该就是tunnel两端的地址
  • [回复留言] | [删除] 2009-11-12 13:54:25
  • [引用] 1.CT
  • 你好,看了你的文章很受益。我有个问题,文章最后抓包怎么不是GRE的包?不是最外面都是GRE封装吗??
    godupgod 于 2009-10-24 20:00:45 回复
    哥们眼神NB的!应该是GRE包
  • [回复留言] | [删除] 2009-10-21 23:03:28

发表评论:

◎欢迎参与讨论,请在这里发表您的看法、交流您的观点。

Powered By Z-Blog 1.8 Spirit Build 80722

Copyright 2007-2010 John Winning's Blog. All Rights Reserved.