我们前面通过了Juniper防火墙如何配置基于策略的IPsec VPN**(** 配置Juniper虚墙vSRX基于策略的IPsec VPN(CLI方式)) 以及如何配置基于路由的IPsec VPN**(** 配置Juniper虚墙vSRX基于路由的IPsec VPN(CLI方式)),那华为路由器有没有基于路由的IPsec VPN呢?
参考Juniper防火墙的配置,我们可以看出,其实我们前面配置了ACL的IPsec协商模式就可以算是基于策略的IPsec VPN**(** 通过IKE协商方式建立IPSec隧道) ;对应的,上次配置的GRE over IPsec稍加调整就可以变成基于路由的IPsec VPN**(** 快来看啊,华为路由器配置GRE over IPSec隧道案例来了!)。
组网拓扑还是跟上次一样,如下所示:

回顾一下,我们之前配置H3C的ADVPN的时候,没有配置IPsec策略,而是直接将IPsec安全框架应用在隧道接口上的**(** ADVPN:Full-Mesh模型组网实验),对应的,华为也可以这么配置。而且上次配置的时候,我们也说了,IKE对等体的地址可以不配置,那么相关配置就简单了,直接上配置。
HW-AR1
properties
#
ipsec proposal ipsec
esp authentication-algorithm sha1
esp encryption-algorithm aes-128
#
ike peer ar2
version 1
pre-shared-key cipher HwIPsec.2024
#
ipsec profile aripsec
ike-peer ar2
proposal ipsec
#
interface GigabitEthernet0/0/1
ip address 12.1.1.1 255.255.255.0
#
interface Tunnel0/0/0
ip address 10.13.1.1 255.255.255.0
tunnel-protocol gre
source 12.1.1.1
destination 23.1.1.3
ipsec profile aripsec
#
ip route-static 10.1.2.0 255.255.255.0 Tunnel0/0/0
ip route-static 23.1.1.0 255.255.255.0 12.1.1.2
H3C-MSR
nginx
#
interface GigabitEthernet1/0
ip address 12.1.1.2 255.255.255.0
#
interface GigabitEthernet2/0
ip address 23.1.1.2 255.255.255.0
HW-AR2
properties
#
ipsec proposal ipsec
esp authentication-algorithm sha1
esp encryption-algorithm aes-128
#
ike peer ar1
version 1
pre-shared-key cipher HwIPsec.2024
#
ipsec profile aripsec
ike-peer ar1
proposal ipsec
#
interface GigabitEthernet0/0/1
ip address 23.1.1.3 255.255.255.0
#
interface Tunnel0/0/0
ip address 10.13.1.3 255.255.255.0
tunnel-protocol gre
source 23.1.1.3
destination 12.1.1.1
ipsec profile aripsec
#
ip route-static 10.1.1.0 255.255.255.0 Tunnel0/0/0
ip route-static 23.1.1.0 255.255.255.0 12.1.1.2
就这么简简单单的几行配置,你就实现了基于路由的IPsec VPN的配置,只要添加通过GRE隧道转发的路由就能实现加密传输了。
同样的,配置完成之后,设备就自动发起了协商,协商成功之后直接就有IKE SA和IPsec SA了。

与使用ACL的策略模式不同,IPsec SA的Mode显示为PROF-ISAKMP,而ACL显示的只有ISAKMP。
测试一下业务联通性。

首包实验稍大这个问题是一直存在的,好像也不好解决。
我们再给AR2加一个环回口,并添加对应的路由条目,测试一下。

抓包看一下。

可以看到,所有经过GRE隧道接口转发的报文都是ESP封装的,不区分源目地址。
那么,GRE隧道接口不配置IP地址是否可以呢?

实测是不行的,因为接口没有IP地址之后,相关的路由表会失效,导致无法转发。
最后,两种GRE over IPsec配置方式,你更喜欢哪一种呢?
***推荐阅读***
快来看啊,华为路由器配置GRE over IPSec隧道案例来了!
Telnet不安全?如何配置使用更安全的STelnet远程登录华为AR1000V路由器?
华为交换机S3700/S5700/CE6800配置SSH远程登录
GRE和IPsec搭配使用,到底是谁over谁?先看GRE over IPsec
GRE over IPsec,IPsec不服,要求IPsec over GRE
配置Juniper虚墙vSRX基于路由的IPsec VPN(WEB方式)
配置Juniper虚墙vSRX基于策略的IPsec VPN(CLI方式)
