GRE over IPSec

GRE & IPSEC

由于GRE是支持动态路由协议来以组播的方式来发送路由更新,没有对数据报文进行加密操作的。相反IPsec支持对数据包的加密封装而不支持组播,也没有虚拟的隧道接口,因此IPsec对动态路由协议并没有太好的支持。
因此有了GRE over IPsec的出现
GRE over IPSec
网络基本配置:
R1:
R1(config)#interface f0/0
R1(config-if)#ip address 202.100.1.1 255.255.255.0
R1(config-if)#no shutdown
R1(config)#interface loopback 1
R1(config-if)#ip address 1.1.1.1 255.255.255.0
R1(config-if)#no shutdown
R1(config)#interface loopback 2
R1(config-if)#ip address 2.2.2.2 255.255.255.0
R1(config-if)#no shutdown
R1(config)#interface loopback 3
R1(config-if)#ip address 3.3.3.3 255.255.255.0
R1(config-if)#no shutdown
R1(config)#ip route 0.0.0.0 0.0.0.0 202.100.1.10
R2:
R2(config)#interface f0/0
R2(config-if)#ip address 202.100.1.10 255.255.255.0
R2(config-if)#no shutdown
R2(config)#interface f0/1
R2(config-if)#ip address 202.100.2.10 255.255.255.0
R2(config-if)#no shutdown
R3:
R3(config)#interface f0/0
R3(config-if)#ip add 202.100.2.1 255.255.255.0
R3(config-if)#no shutdown
R3(config)#interface loopback 1
R3(config-if)#ip address 4.4.4.4 255.255.255.0
R3(config-if)#no shutdown
R3(config)#interface loopback 2
R3(config-if)#ip address 5.5.5.5 255.255.255.0
R3(config-if)#no shutdown
R3(config)#interface loopback 3
R3(config-if)#ip address 6.6.6.6 255.255.255.0
R3(config-if)#no shutdown
测试公网连通性:
GRE over IPSec
GRE与动态路由配置:
R1:
R1(config)#interface tunnel 0 //进入tunnel口
R1(config-if)#ip address 172.16.1.1 255.255.255.0 //配置tunnel地址
R1(config-if)#tunnel source f0/0 //配置tunnel的源
R1(config-if)#tunnel destination 202.100.2.1 //配置tunnel的目的地
R1(config)#router ospf 10
R1(config-router)#network 1.1.1.0 0.0.0.255 area 0
R1(config-router)#network 2.2.2.0 0.0.0.255 area 0
R1(config-router)#network 3.3.3.0 0.0.0.255 area 0
R1(config-router)#network 172.16.1.0 0.0.0.255 area 0
R3:
R3(config)#interface tunnel 0
R3(config-if)#ip address 172.16.1.2 255.255.255.0
R3(config-if)#tunnel source f0/0
R3(config-if)#tunnel destination 202.100.1.1
R3(config)#router ospf 10
R3(config-router)#network 4.4.4.0 0.0.0.255 area 0
R3(config-router)#network 5.5.5.0 0.0.0.255 area 0
R3(config-router)#network 6.6.6.0 0.0.0.255 area 0
R3(config-router)#network 172.16.1.0 0.0.0.255 area 0
R1路由表:
GRE over IPSecGRE over IPSecGRE over IPSec
GRE over IPSec
GRE over IPSec
同样使用R1的 1.1.1.1 IP地址作为源,分别pingR3的lo1.lo2,lo3。抓包发现。无论你GRE内部的数据是什
么。外层的IP头部都是不变的。因此。使用IPsec对GRE加密时
感兴趣就可以只抓gre的202.100.1.1到202.100.2.1.R3反之。
IPsec 配置:
R1:
R1(config)#crypto isakmp enable //默认已开启。
R1(config)#crypto isakmp policy 10 //创建IKE第一阶段策略。策略编号为10
R1(config-isakmp)#encryption 3des //IKE数据包加密算法使用3DES。默认使用DES
R1(config-isakmp)#hash md5 //IKE数据包完整性校验的散列算法使用md5。默认使用SHA-1
R1(config-isakmp)#authentication pre-share //IKE第一阶段5-6个包,认证方式使用预共享**。默认
使用数字签名。
R1(config-isakmp)#group 2 //IKE第一阶段3-4个包,DH交换使用group2。默认使用group1
R1(config)#crypto isakmp key 0 cisco address 202.100.2.1 //IKE第一阶段5-6个包,与共享**为cisco
R1(config)#ip access-list extended lsj
R1(config-ext-nacl)#permit gre host 202.100.1.1 host 202.100.2.1
R1(config)#crypto ipsec transform-set myset esp-3des esp-sha-hmac
R1(cfg-crypto-trans)#mode transport //GRE OVER IPSEC使用传输模式。
R1(config)#crypto map ccie 10 ipsec-isakmp
R1(config-crypto-map)#match address lsj
R1(config-crypto-map)#set peer 202.100.1.2
R1(config-crypto-map)#set transform-set myset
R1(config)#interface f0/0
R1(config-if)#crypto map ccie
GRE OVER IPSEC 另外一种配置方式:
R3(config)#crypto isakmp policy 10
R3(config-isakmp)#encryption 3des
R3(config-isakmp)#hash md5
R3(config-isakmp)#authentication pre-share
R3(config-isakmp)#group
R3(config)#crypto isakmp key 0 cisco address 202.100.1.1
R1(config)#crypto ipsec transform-set myset esp-3des esp-sha-hmac
R3(config)#crypto ipsec profile PRO
R3(ipsec-profile)#set transform-set myset
R3(config)#interface tunnel 0
R3(config-if)#tunnel protection ipsec profile PRO
GRE over IPSec
查看加解密情况
这是种全新的IPSec profile的配置方式,是如何代替crypto map。那么感兴趣流,peer是是怎么一回事呢?
注意。这个profile是调用在tunnel下的。使用tunnel protection 这个命令。那么保护的自然是tunnel的流
量。也就是我们的感兴趣流了。peer。自然就是tunnel的目的了。
这种全新的配置方式。可以合旧的配置方式兼容。新的配置方式配置起来更简单。。建议使用新的配置方式