IPSec tunnel between Strongswan behind NAT and VMWare NSX Edge

For a number of reasons, it became necessary to set up a VPN connection between the network in VMWare Cloud Director and a separate Ubuntu machine in the cloud. This note does not claim to provide a complete description; it is simply a brief how-to.

IPSec tunnel between Strongswan behind NAT and VMWare NSX Edge

I found a single article from 2015 on this topic titled "Site to Site IPSEC VPN between NSX Edge and Linux strongSwan».

Unfortunately, I couldn't use it directly as I wanted more reliable encryption than a self-signed certificate, and the described config would not work with NAT.

Therefore, I had to sit down and dig into the documentation.

I based my setup on a config I have long used, allowing connections from virtually any OS, and simply added a part to connect to the NSX Edge.

Since the installation and full configuration of the Strongswan server go beyond the scope of this note, I will refer to a decent resource on this topic.

Now, let's move on to the settings.

The connection diagram will look like this:

IPSec tunnel between Strongswan behind NAT and VMWare NSX Edge

on the VMWare side, the external address is 33.33.33.33 and the internal network is 192.168.1.0/24
on the Linux side, the external address is 22.22.22.22 and the internal network is 10.10.10.0/24
we will also need to set up a Let's Encrypt certificate for the address vpn.linux.ext
PSK on both sides: ChangeMeNow!

Settings on the NSX Edge side:

Text

Enabled: yes
Enable perfect forward secrecy (PFS): yes
Name: VPN_strongswan (any name of your choice)
Local Id: 33.33.33.33
Local Endpoint: 33.33.33.33
Local Subnets: 192.168.1.0/24
Peer Id: vpn.linux.ext
Peer Endpoint: 22.22.22.22
Peer Subnets: 10.10.10.0/24
Encryption Algorithm: AES256
Authentication: PSK
Pre-Shared Key: ChangeMeNow!
Diffie-Hellman Group: 14 (2048 bit — an acceptable compromise between speed and security. But if you want, you can set a higher number)
Digest Algorithm: SHA256
IKE Option: IKEv2
IKE Responder Only: no
Session Type: Policy Based Session

Screenshots
IPSec tunnel between Strongswan behind NAT and VMWare NSX Edge
IPSec tunnel between Strongswan behind NAT and VMWare NSX Edge

Settings on the Strongswan side:

ipsec.conf

# /etc/ipsec.conf
config setup

conn %default
	dpdaction=clear
	dpddelay=35s
	dpdtimeout=300s

	fragmentation=yes
	rekey=no

	ike=aes256gcm16-aes256gcm12-aes128gcm16-aes128gcm12-sha256-sha1-modp2048-modp4096-modp1024,aes256-aes128-sha256-sha1-modp2048-modp4096-modp1024,3des-sha1-modp1024!
	esp=aes128gcm12-aes128gcm16-aes256gcm12-aes256gcm16-modp2048-modp4096-modp1024,aes128-aes256-sha1-sha256-modp2048-modp4096-modp1024,aes128-sha1-modp2048,aes128-sha1-modp1024,3des-sha1-modp1024,aes128-aes256-sha1-sha256,aes128-sha1,3des-sha1!

	left=%any
	leftsubnet=10.10.10.0/24
        leftcert=certificate.pem
	leftfirewall=yes
	leftsendcert=always

	right=%any
	rightsourceip=192.168.1.0/24
	rightdns=77.88.8.8,8.8.4.4

	eap_identity=%identity

# IKEv2
conn IPSec-IKEv2
	keyexchange=ikev2
	auto=add

# BlackBerry, Windows, Android
conn IPSec-IKEv2-EAP
	also="IPSec-IKEv2"
	rightauth=eap-mschapv2

# macOS, iOS
conn IKEv2-MSCHAPv2-Apple
	also="IPSec-IKEv2"
	rightauth=eap-mschapv2
	leftid=vpn.linux.ext

# Android IPsec Hybrid RSA
conn IKEv1-Xauth
	keyexchange=ikev1
	rightauth=xauth
	auto=add

# VMWare IPSec VPN
conn linux-nsx-psk
	authby=secret
	auto=start
	leftid=vpn.linux.ext
	left=10.10.10.10
	leftsubnet=10.10.10.0/24
	rightid=33.33.33.33
	right=33.33.33.33
	rightsubnet=192.168.1.0/24
	ikelifetime=28800
	keyexchange=ikev2
	lifebytes=0
	lifepackets=0
	lifetime=1h

ipsec.secret

# /etc/ipsec.secrets
: RSA privkey.pem

# Create VPN users accounts
# ВНИМАНИЕ! После логина сначала пробел, потом двоеточие.

user1 : EAP "stongPass1"
user2 : EAP "stongPass2"
%any 33.33.33.33 : PSK "ChangeMeNow!"

after this, it’s enough to reread the config, start the connection, and check if it is established:

ipsec update
ipsec rereadsecrets
ipsec up linux-nsx-psk
ipsec status

I hope this brief note proves useful and saves someone a couple of hours.

Source: habr.com

Buy reliable website hosting with DDoS protection, VPS VDS servers 🔥 Buy reliable website hosting with DDoS protection, VPS VDS servers | ProHoster