1.5 国内IPsec VPN方案。 测试演示

1.5 国内IPsec VPN方案。 测试演示

情况

我收到了三个月的 C-Terra VPN 产品 4.3 版演示版。 我想知道切换到新版本后我的工程生活是否会变得更加轻松。

今天不难,一袋速溶咖啡三合一就够了。 我会告诉你如何获得演示。 我将尝试构建 GRE-over-IPsec 和 IPsec-over-GRE 方案。

如何获得演示

1.5 国内IPsec VPN方案。 测试演示

从图中可以看出,为了获得演示,您需要:

  • 写信给 [电子邮件保护] 来自公司地址;
  • 在信中注明您组织的 TIN;
  • 列出产品及其数量。

演示的有效期为三个月。 供应商不限制其功能。

扩大图像

安全网关演示是一个虚拟机映像。 我正在使用 VMWare 工作站。 供应商的网站上提供了受支持的虚拟机管理程序和虚拟化环境的完整列表。

在开始之前,请注意默认虚拟机映像中没有网络接口:

1.5 国内IPsec VPN方案。 测试演示

逻辑很清晰,用户需要添加多少个接口就可以了。 我会一次添加四个:

1.5 国内IPsec VPN方案。 测试演示

现在我启动虚拟机。 启动后,网关立即需要用户名和密码。

S-Terra Gateway 中有多个具有不同帐户的控制台。 我将在另一篇文章中统计他们的数量。 目前:
Login as: administrator
Password: s-terra

我正在初始化网关。 初始化是一系列操作:输入许可证、设置生物随机数生成器(键盘模拟器 - 我的记录是 27 秒)以及创建网络接口映射。

网络接口映射。 变得更容易了

4.2 版本用消息向活动用户致意:

Starting IPsec daemon….. failed
ERROR: Could not establish connection with daemon

活跃用户(根据一位匿名工程师的说法)是可以快速设置任何内容且无需文档的用户。

尝试在接口上设置 IP 地址之前出现问题。 这都是关于网络接口映射的。 有必要这样做:

/bin/netifcfg enum > /home/map
/bin/netifcfg map /home/map
service networking restart

结果,创建了一个网络接口映射,其中包含物理接口名称 (0000:02:03.0) 及其在操作系统 (eth0) 和类似 Cisco 控制台 (FastEthernet0/0) 中的逻辑名称的映射:

#Unique ID iface type OS name Cisco-like name

0000:02:03.0 phye eth0 FastEthernet0/0

接口的逻辑名称称为别名。 别名存储在 /etc/ifaliases.cf 文件中。
在4.3版本中,当虚拟机第一次启动时,会自动创建一个接口映射。 如果您更改虚拟机中的网络接口数量,请重新创建接口映射:

/bin/netifcfg enum > /home/map
/bin/netifcfg map /home/map
systemctl restart networking

方案 1:GRE-over-IPsec

我部署了两个虚拟网关,我切换如图:

1.5 国内IPsec VPN方案。 测试演示

步骤 1. 设置 IP 地址和路由

VG1(config) #
interface fa0/0
ip address 172.16.1.253 255.255.255.0
no shutdown
interface fa0/1
ip address 192.168.1.253 255.255.255.0
no shutdown
ip route 0.0.0.0 0.0.0.0 172.16.1.254

VG2(config) #
interface fa0/0
ip address 172.16.1.254 255.255.255.0
no shutdown
interface fa0/1
ip address 192.168.2.254 255.255.255.0
no shutdown
ip route 0.0.0.0 0.0.0.0 172.16.1.253

检查 IP 连接:

root@VG1:~# ping 172.16.1.254 -c 4
PING 172.16.1.254 (172.16.1.254) 56(84) bytes of data.
64 bytes from 172.16.1.254: icmp_seq=1 ttl=64 time=0.545 ms
64 bytes from 172.16.1.254: icmp_seq=2 ttl=64 time=0.657 ms
64 bytes from 172.16.1.254: icmp_seq=3 ttl=64 time=0.687 ms
64 bytes from 172.16.1.254: icmp_seq=4 ttl=64 time=0.273 ms

--- 172.16.1.254 ping statistics ---
4 packets transmitted, 4 received, 0% packet loss, time 3005ms
rtt min/avg/max/mdev = 0.273/0.540/0.687/0.164 ms

第 2 步:设置 GRE

我举一个从官方脚本设置GRE的例子。 我在 /etc/network/interfaces.d 目录中创建一个包含内容的 gre1 文件。

对于 VG1:

auto gre1
iface gre1 inet static
address 1.1.1.1
netmask 255.255.255.252
pre-up ip tunnel add gre1 mode gre remote 172.16.1.254 local 172.16.1.253 key 1 ttl 64 tos inherit
pre-up ethtool -K gre1 tx off > /dev/null
pre-up ip link set gre1 mtu 1400
post-down ip link del gre1

对于 VG2:

auto gre1
iface gre1 inet static
address 1.1.1.2
netmask 255.255.255.252
pre-up ip tunnel add gre1 mode gre remote 172.16.1.253 local 172.16.1.254 key 1 ttl 64 tos inherit
pre-up ethtool -K gre1 tx off > /dev/null
pre-up ip link set gre1 mtu 1400
post-down ip link del gre1

我在系统中提出界面:

root@VG1:~# ifup gre1
root@VG2:~# ifup gre1

检查:

root@VG1:~# ip address show
8: gre1@NONE: <POINTOPOINT,NOARP,UP,LOWER_UP> mtu 1400 qdisc noqueue state UNKNOWN group default qlen 1
    link/gre 172.16.1.253 peer 172.16.1.254
    inet 1.1.1.1/30 brd 1.1.1.3 scope global gre1
       valid_lft forever preferred_lft forever

root@VG1:~# ip tunnel show
gre0: gre/ip remote any local any ttl inherit nopmtudisc
gre1: gre/ip remote 172.16.1.254 local 172.16.1.253 ttl 64 tos inherit key 1

C-Terra Gateway 有一个内置的数据包嗅探器 - tcpdump。 我会将流量转储写入 pcap 文件:

root@VG2:~# tcpdump -i eth0 -w /home/dump.pcap

我开始在 GRE 接口之间执行 ping 操作:

root@VG1:~# ping 1.1.1.2 -c 4
PING 1.1.1.2 (1.1.1.2) 56(84) bytes of data.
64 bytes from 1.1.1.2: icmp_seq=1 ttl=64 time=0.918 ms
64 bytes from 1.1.1.2: icmp_seq=2 ttl=64 time=0.850 ms
64 bytes from 1.1.1.2: icmp_seq=3 ttl=64 time=0.918 ms
64 bytes from 1.1.1.2: icmp_seq=4 ttl=64 time=0.974 ms

--- 1.1.1.2 ping statistics ---
4 packets transmitted, 4 received, 0% packet loss, time 3006ms
rtt min/avg/max/mdev = 0.850/0.915/0.974/0.043 ms

GRE 隧道已启动并运行:

1.5 国内IPsec VPN方案。 测试演示

步骤 3. 使用 GOST GRE 加密

我设置了身份识别类型 - 按地址。 使用预定义密钥进行身份验证(根据使用条款,必须使用数字证书):

VG1(config)#
crypto isakmp identity address
crypto isakmp key KEY address 172.16.1.254

我设置 IPsec 第一阶段参数:

VG1(config)#
crypto isakmp policy 1
encr gost
hash gost3411-256-tc26
auth pre-share
group vko2

我设置IPsec第二阶段参数:

VG1(config)#
crypto ipsec transform-set TSET esp-gost28147-4m-imit
mode tunnel

我创建了一个用于加密的访问列表。 目标流量 - GRE:

VG1(config)#
ip access-list extended LIST
permit gre host 172.16.1.253 host 172.16.1.254

我创建一个加密映射并将其绑定到 WAN 接口:

VG1(config)#
crypto map CMAP 1 ipsec-isakmp
match address LIST
set transform-set TSET
set peer 172.16.1.253
interface fa0/0
  crypto map CMAP

对于VG2,配置是镜像的,区别是:

VG2(config)#
crypto isakmp key KEY address 172.16.1.253
ip access-list extended LIST
permit gre host 172.16.1.254 host 172.16.1.253
crypto map CMAP 1 ipsec-isakmp
set peer 172.16.1.254

检查:

root@VG2:~# tcpdump -i eth0 -w /home/dump2.pcap
root@VG1:~# ping 1.1.1.2 -c 4
PING 1.1.1.2 (1.1.1.2) 56(84) bytes of data.
64 bytes from 1.1.1.2: icmp_seq=1 ttl=64 time=1128 ms
64 bytes from 1.1.1.2: icmp_seq=2 ttl=64 time=126 ms
64 bytes from 1.1.1.2: icmp_seq=3 ttl=64 time=1.07 ms
64 bytes from 1.1.1.2: icmp_seq=4 ttl=64 time=1.12 ms

--- 1.1.1.2 ping statistics ---
4 packets transmitted, 4 received, 0% packet loss, time 3006ms
rtt min/avg/max/mdev = 1.077/314.271/1128.419/472.826 ms, pipe 2

ISAKMP/IPsec 统计信息:

root@VG1:~# sa_mgr show
ISAKMP sessions: 0 initiated, 0 responded

ISAKMP connections:
Num Conn-id (Local Addr,Port)-(Remote Addr,Port) State Sent Rcvd
1 1 (172.16.1.253,500)-(172.16.1.254,500) active 1086 1014

IPsec connections:
Num Conn-id (Local Addr,Port)-(Remote Addr,Port) Protocol Action Type Sent Rcvd
1 1 (172.16.1.253,*)-(172.16.1.254,*) 47 ESP tunn 480 480

GRE 流量转储中没有数据包:

1.5 国内IPsec VPN方案。 测试演示

结论:GRE-over-IPsec 方案工作正常。

图 1.5:GRE 上的 IPsec

我不打算在网络上使用 IPsec-over-GRE。 我收集是因为我想收集。

1.5 国内IPsec VPN方案。 测试演示

要以相反的方式部署 GRE-over-IPsec 方案:

  • 修复加密访问列表 - 从 LAN1 到 LAN2 的目标流量,反之亦然;
  • 通过GRE配置路由;
  • 在 GRE 接口上挂起加密映射。

默认情况下,类Cisco网关控制台中没有GRE接口。 它仅存在于操作系统中。

我将 GRE 接口添加到类似 Cisco 的控制台。 为此,我编辑 /etc/ifaliases.cf 文件:

interface (name="FastEthernet0/0" pattern="eth0")
interface (name="FastEthernet0/1" pattern="eth1")
interface (name="FastEthernet0/2" pattern="eth2")
interface (name="FastEthernet0/3" pattern="eth3")
interface (name="Tunnel0" pattern="gre1")
interface (name="default" pattern="*")

其中 gre1 是操作系统中的接口名称,Tunnel0 是类似 Cisco 的控制台中的接口名称。

我重新计算文件的哈希值:

root@VG1:~# integr_mgr calc -f /etc/ifaliases.cf

SUCCESS:  Operation was successful.

现在Tunnel0接口已经出现在类似Cisco的控制台中:

VG1# show run
interface Tunnel0
ip address 1.1.1.1 255.255.255.252
mtu 1400

更正加密的访问列表:

VG1(config)#
ip access-list extended LIST
permit ip 192.168.1.0 0.0.0.255 192.168.3.0 0.0.0.255

我通过GRE配置路由:

VG1(config)#
no ip route 0.0.0.0 0.0.0.0 172.16.1.254
ip route 192.168.3.0 255.255.255.0 1.1.1.2

我从 Fa0 / 0 中删除加密映射并将其绑定到 GRE 接口:

VG1(config)#
interface Tunnel0
crypto map CMAP

对于 VG2 来说也是类似的。

检查:

root@VG2:~# tcpdump -i eth0 -w /home/dump3.pcap

root@VG1:~# ping 192.168.2.254 -I 192.168.1.253 -c 4
PING 192.168.2.254 (192.168.2.254) from 192.168.1.253 : 56(84) bytes of data.
64 bytes from 192.168.2.254: icmp_seq=1 ttl=64 time=492 ms
64 bytes from 192.168.2.254: icmp_seq=2 ttl=64 time=1.08 ms
64 bytes from 192.168.2.254: icmp_seq=3 ttl=64 time=1.06 ms
64 bytes from 192.168.2.254: icmp_seq=4 ttl=64 time=1.07 ms

--- 192.168.2.254 ping statistics ---
4 packets transmitted, 4 received, 0% packet loss, time 3006ms
rtt min/avg/max/mdev = 1.064/124.048/492.972/212.998 ms

ISAKMP/IPsec 统计信息:

root@VG1:~# sa_mgr show
ISAKMP sessions: 0 initiated, 0 responded

ISAKMP connections:
Num Conn-id (Local Addr,Port)-(Remote Addr,Port) State Sent Rcvd
1 2 (172.16.1.253,500)-(172.16.1.254,500) active 1094 1022

IPsec connections:
Num Conn-id (Local Addr,Port)-(Remote Addr,Port) Protocol Action Type Sent Rcvd
1 2 (192.168.1.0-192.168.1.255,*)-(192.168.2.0-192.168.2.255,*) * ESP tunn 352 352

在 ESP 流量转储中,封装在 GRE 中的数据包:

1.5 国内IPsec VPN方案。 测试演示

结论:IPsec-over-GRE 工作正常。

结果

一杯咖啡就足够了。 我概述了获取演示版本的说明。 配置 GRE-over-IPsec 并部署反之亦然。

4.3 版本中的网络接口映射是自动的! 我正在进一步测试。

匿名工程师
t.me/anonymous_engineer


来源: habr.com

添加评论