情況
我收到了三個月的 C-Terra VPN 產品 4.3 版演示版。 我想知道切換到新版本後我的工程生活是否會變得更加輕鬆。
今天不難,一袋速溶咖啡三合一就夠了。 我會告訴你如何獲得演示。 我將嘗試構建 GRE-over-IPsec 和 IPsec-over-GRE 方案。
如何獲得演示
從圖中可以看出,為了獲得演示,您需要:
- 寫信給 [電子郵件保護] 來自公司地址;
- 在信中註明您組織的 TIN;
- 列出產品及其數量。
演示的有效期為三個月。 供應商不限制其功能。
擴大圖像
安全網關演示是一個虛擬機映像。 我正在使用 VMWare 工作站。 供應商的網站上提供了受支持的虛擬機管理程序和虛擬化環境的完整列表。
在開始之前,請注意默認虛擬機映像中沒有網絡接口:
邏輯很清晰,用戶需要添加多少個接口就可以了。 我會一次添加四個:
現在我啟動虛擬機。 啟動後,網關立即需要用戶名和密碼。
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. 設置 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 隧道已啟動並運行:
步驟 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 流量轉儲中沒有數據包:
結論:GRE-over-IPsec 方案工作正常。
圖 1.5:GRE 上的 IPsec
我不打算在網絡上使用 IPsec-over-GRE。 我收集是因為我想收集。
要以相反的方式部署 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 中的數據包:
結論:IPsec-over-GRE 工作正常。
結果
一杯咖啡就足夠了。 我概述了獲取演示版本的說明。 配置 GRE-over-IPsec 並部署反之亦然。
4.3 版本中的網絡接口映射是自動的! 我正在進一步測試。
匿名工程師
t.me/anonymous_engineer
來源: www.habr.com