Linux libreswan settings for connecting as VPN client to FortiGate VPN with IPSEC/IKEv1, RSA + XAUTH
-
libreswan
andopenssl
packages installed; -
Stop
pluto
service withipsec stop
if it was autostarted; -
CA, User certs and Private key available for configuring RSA;
-
Disable ICMP
accept_redirects
andsend_redirects
with sysctl.
Set up /etc/ipsec.d/connection_name.conf
:
conn connection-name
ikev2=no
ike=aes256-sha256;modp1536
esp=aes256-sha1;modp1536
authby=rsasig
pfs=yes
auto=add
left=%defaultroute
leftcert=<YourLogin>
leftid=%fromcert
leftsendcert=always
leftxauthusername=<YourLogin>
rightsubnet=0.0.0.0/0
right=<FortiGate VPN IP-address or DNS-name>
rightid=%fromcert
rightxauthserver=yes
leftxauthclient=yes
rightmodecfgserver=yes
leftmodecfgclient=yes
modecfgpull=yes
nm-configured=yes
aggrmode=yes
cisco-unity=yes
ikelifetime=86400s
salifetime=43200s
dpddelay=20s
dpdtimeout=60s
nat-ikev1-method=rfc
esn=either
nopmtudisc=yes
remote-peer-type=cisco
nat-keepalive=no
In case of using DNS-name in right
option pluto could deny connecting to FortiGate VPN server if there is no DNSSEC-record available for domain name. Disable DNSSEC validation in /etc/ipsec.conf
:
config setup
dnssec-enable=no
-
Initialize NSS database for storing RSA keys:
ipsec initnss
Just for info, default path for NSS databases (
cert*.db
,key*.db
,pkcs11.txt
):
RHEL-based →/etc/ipsec.d
Debian-based →/var/lib/ipsec/nss
-
Make p12-container from certificates and private key:
openssl pkcs12 -export -in cert.pem -inkey key.pem -certfile cacert.pem -out YourName.p12 -name YourName
-
Import p12-container into NSS db:
ipsec import YourName.p12
-
Check if cert is listed in NSS db now:
certutil -L -d <PATH_TO_NSS_DATABASES_DIR>
-
Start
pluto
service and check if it sees certificate now:ipsec start ipsec showhostkey --list
-
Start connection:
ipsec auto --up connection-name ipsec auto --start connection-name
If resolv.conf is controlled by systemd-resolved then link DNS-servers manually to ipsec interface in /etc/sysconfig/pluto_updown
(for RPM-based distros) or in /etc/default/pluto_updown
(for DEB-based):
#!/bin/bash
resolvectl dns ipsec1 <DNS1_IP> <DNS2_IP> <DNSX_IP>
resolvectl domain ipsec1 <DOMAIN_NAME_1> <DOMAIN_NAME2>