IPsec sous debian avec strongswan
aptitude install strongswan strongswan-swanctl
Placer la CA dans /etc/ipsec.d/cacerts puis :
cd /etc/ipsec.d/cacerts/ ln -s myca.pem `openssl x509 -hash -noout -in myca.pem`.0
Placer le certificat dans /etc/ipsec.d/certs/
Placer la clé privée dans /etc/ipsec.d/private/
Il faut définir la clé privé dans /etc/ipsec.secrets sous le format ID : TYPE KEY. L'ID peut être vide, contenir une ip, un FQDN, user@FQSN, %any ou any6. TYPE est PSK ou RSA. KEY peut être soit une clé, soit un chemin vers une clé.
: RSA /etc/ipsec.d/private/mykey.key
ipsec.conf
conn ipsec1
reqid = 1
fragmentation = yes
keyexchange = ikev2
reauth = yes
forceencaps = no
mobike = no
rekey = yes
installpolicy = yes
auto = start
dpdaction = restart
dpddelay = 10s
dpdtimeout = 60s
left = 211.124.34.153
right = 92.119.29.26
leftid = nodeA.domain.tld
rightid = nodeB.domain.tld
ikelifetime = 28800s
lifetime = 3600s
ike = aes128gcm128-sha512-modp4096!
esp = aes128gcm128-sha256-modp2048!
leftauth = pubkey
rightauth = pubkey
leftcert="/etc/ipsec.d/certs/mycert.crt"
rightca="/CN=My Ca/ST=My Location/L=My City/O=My Company/OU=My Company Unit/"
leftsubnet = 10.66.10.18/30
rightsubnet = 10.66.10.17
mark = 42
leftupdown = /etc/ipsec.updown