1.5 schemes on domestic IPsec VPN. Testing demos





Situation



I received a three month trial version of C-Terra VPN version 4.3. I want to find out if my engineering life will become easier after upgrading to the new version.



Today it is not difficult, one packet of instant coffee 3 in 1 should be enough. I'll tell you how to get the demos. I will try to put together GRE-over-IPsec and IPsec-over-GRE schemes.



How to get a demo







From the figure it follows to get a demo you need:



  • Write a letter to presale@s-terra.ru from the corporate address;
  • In the letter, indicate the TIN of your organization;
  • List the products and their quantity.


The demos are valid for three months. The vendor does not limit their functionality.



Expand the image



The Security Gateway Demo is a virtual machine image. I am using VMWare Workstation. A complete list of supported hypervisors and virtualization environments is available on the vendor's website.



Before starting the active steps, please note that there are no network interfaces in the default virtual machine image:







The logic is clear, the user must add as many interfaces as he needs. I'll add four at once:







Now I start the virtual machine. Immediately after starting, the gateway requires a username and password.



C-Terra Gateway has several consoles with different accounts. I will count their number in a separate article. Until then:

Login as: administrator

Password: s-terra


Initializing the gateway. Initialization is a sequence of actions: entering a license, setting up a biological random number generator (keyboard simulator - my record is 27 seconds) and creating a network interface map.



Network interface card. It became easier



Version 4.2 greeted the active user with the following messages: An active user (according to the anonymous engineer) is a user who can configure anything quickly and without documentation. Something went wrong even before trying to configure an IP address on the interface. It's all about the network interface map. It was necessary to do: As a result, a map of network interfaces is created, which contains a mapping of the names of physical interfaces (0000: 02: 03.0) and their logical designations in the operating system (eth0) and Cisco-like console (FastEthernet0 / 0): Logical designations of interfaces are called aliases ... Aliases are stored in the /etc/ifaliases.cf file.



Starting IPsec daemon….. failed

ERROR: Could not establish connection with daemon












/bin/netifcfg enum > /home/map

/bin/netifcfg map /home/map

service networking restart








#Unique ID iface type OS name Cisco-like name



0000:02:03.0 phye eth0 FastEthernet0/0






In version 4.3, the interface map is created automatically when the virtual machine is first started. If you change the number of network interfaces in the virtual machine, please create the interface map again:



/bin/netifcfg enum > /home/map

/bin/netifcfg map /home/map

systemctl restart networking




Figure 1: GRE-over-IPsec



I deploy two virtual gateways, switch them as shown in the figure:







Step 1. Configure IP addresses and routes



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


Checking IP connectivity:



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




Step 2. Configuring GRE



An example of configuring GRE is taken from the official scripts. Create file gre1 in /etc/network/interfaces.d directory with content.



For 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


For 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


I bring up the interface in the system:



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


I check:



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 has a built-in packet sniffer - tcpdump. I will dump the traffic to a pcap file:



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


I ping between GRE interfaces:



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 tunnel is active and working:







Step 3. Encrypt with GRE GRE



Set the type of identification - by address. Authentication using a predefined key (according to the Terms of Use, you must use digital certificates):



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


I set the IPsec Phase I parameters:



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


I set the parameters for IPsec Phase II:



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


I am creating an access list for encryption. Target traffic - GRE:



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


I create a crypto map and bind it to the WAN interface:



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


For VG2, the configuration is mirrored, the differences are:



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


I check:



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 statistics:



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


There are no packets in the GRE traffic dump:







Conclusion: GRE-over-IPsec scheme works correctly.



Figure 1.5: IPsec-over-GRE



I do not plan to use IPsec-over-GRE on the network. I collect because I want to.







To deploy the GRE-over-IPsec scheme, on the contrary, you need:



  • Fix access list for encryption - target traffic from LAN1 to LAN2 and vice versa;
  • Configure routing via GRE;
  • Hang up the crypto map on the GRE interface.


By default, the Cisco-like gateway console does not have a GRE interface. It only exists on the operating system.



I add the GRE interface to the Cisco-like console. To do this, edit the /etc/ifaliases.cf file:



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="*")


where gre1 is the interface designation in the operating system, Tunnel0 is the interface designation in the Cisco-like console.



I recalculate the hash of the file:



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

SUCCESS:  Operation was successful.


Now the Tunnel0 interface has appeared in the Cisco-like console:



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


Correcting the access list for encryption:



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


Setting up routing via 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


I remove the cryptocard from Fa0 / 0 and bind it to the GRE interface:



VG1(config)#
interface Tunnel0
crypto map CMAP


Similarly for VG2.



I check:



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 statistics:



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


In the ESP traffic dump, packets encapsulated in GRE:







Conclusion: IPsec-over-GRE is working correctly.



Outcome



One cup of coffee was enough. Sketched out instructions on how to get the demo. Configured GRE-over-IPsec and deployed the other way around.



The network interface map in version 4.3 is automatic! I'm testing further.



Anonymous engineer

t.me/anonimous_engineer



All Articles