Suivez le lien ci-dessous pour savoir comment installer et configurer le serveur VPN strongSwan sur Debian 10 Buster.
Configurer le VPN IPSEC à l'aide de StrongSwan sur Debian 10
Une fois que vous avez configuré le serveur VPN strongSwan, vous pouvez maintenant tester l'attribution IP et la connexion locale via le serveur VPN.
Dans cette démo, nous utilisons Ubuntu 18.04 et CentOS 8 comme nos clients VPN StrongSwan de test.
Configurer le client VPN strongSwan sur Ubuntu 18.04/CentOS 8
Installez strongSwan sur Ubuntu 18.04
strongSwan et des plugins supplémentaires peuvent être installés sur Ubuntu 18.04 en exécutant la commande ci-dessous ;
apt update
apt install strongswan libcharon-extra-plugins
Installez strongSwan sur CentOS 8
Les packages strongSwan sont fournis par les référentiels EPEL sur CentOS 8 et des dérivés similaires. Par conséquent, commencez par installer EPEL repos ;
dnf install epel-release
dnf update
dnf install strongswan strongswan-charon-nm
Installer le certificat AC strongSwan VPN Server sur le client
Copiez le certificat de l'autorité de certification strongSwan généré ci-dessus , /etc/ipsec.d/cacerts/vpn_ca_cert.pem
aux serveurs clients et ;
- placez-le sur
/etc/ipsec.d/cacerts/
répertoire sur Ubuntu 18.04 - placez-le sur
/etc/strongswan/ipsec.d/cacerts
répertoire sur CentOS 8.
Configurer le client VPN strongSwan sur Ubuntu 18.04/CentOS 8
Sur Ubuntu 18.04 ;
Mettre à jour le /etc/ipsec.conf
fichier de configuration pour définir comment se connecter au serveur VPN strongSwan. Voir le fichier de configuration ci-dessous ;
vim /etc/ipsec.conf
conn ipsec-ikev2-vpn-client auto=start right=vpnsvr.kifarunix-demo.com rightid=vpnsvr.kifarunix-demo.com rightsubnet=0.0.0.0/0 rightauth=pubkey leftsourceip=%config leftid=vpnsecure leftauth=eap-mschapv2 eap_identity=%identity
Configurer les secrets d'authentification
vim /etc/ipsec.secrets
... # user id : EAP secret vpnsecure : EAP "[email protected]" # this file is managed with debconf and will contain the automatically created private key include /var/lib/strongswan/ipsec.secrets.inc
Enregistrez le fichier de configuration et redémarrez le strongswan.
systemctl restart strongswan
Désactiver l'exécution de strongSwan au démarrage du système ;
systemctl disable strongswan
Vérifier l'état ;
ipsec statusall
Security Associations (1 up, 0 connecting):
ipsec-ikev2-vpn-client[1]: ESTABLISHED 1 minutes ago, 10.0.2.15[vpnsecure]...192.168.56.174[vpnsvr.kifarunix-demo.com]
ipsec-ikev2-vpn-client{1}: INSTALLED, TUNNEL, reqid 1, ESP in UDP SPIs: cc36db97_i cb5ceb5b_o
ipsec-ikev2-vpn-client{1}: 172.16.7.1/32 === 0.0.0.0/0
Sur CentOS 8 ;
Mettez à jour le /etc/strongswan/ipsec.conf
fichier de configuration pour définir comment se connecter au serveur VPN strongSwan.
vim /etc/strongswan/ipsec.conf
conn ipsec-ikev2-vpn-client auto=start right=vpnsvr.kifarunix-demo.com rightid=vpnsvr.kifarunix-demo.com rightsubnet=0.0.0.0/0 rightauth=pubkey leftsourceip=%config leftid=koromicha leftauth=eap-mschapv2 eap_identity=%identity
Ensuite, ouvrez le /etc/strongswan/ipsec.secrets
fichier de configuration et configurez les détails d'authentification EAP tels qu'ils sont définis sur le serveur.
vim /etc/strongswan/ipsec.secrets
# user id : EAP secret koromicha : EAP "mypassword"
Redémarrez le strongswan.
systemctl restart strongswan
Désactiver l'exécution de strongSwan au démarrage du système ;
systemctl disable strongswan
Vérifier l'état de la connexion VPN
strongswan statusall
Security Associations (1 up, 0 connecting):
ipsec-ikev2-vpn-client[1]: ESTABLISHED 2 minutes ago, 10.0.2.15[vpnsecure]...192.168.56.174[vpnsvr.kifarunix-demo.com]
ipsec-ikev2-vpn-client{1}: INSTALLED, TUNNEL, reqid 1, ESP in UDP SPIs: c573b6a1_i cd8306eb_o
ipsec-ikev2-vpn-client{1}: 172.16.7.2/32 === 0.0.0.0/0
Sur le serveur VPN strongSwan , vérifiez l'état ;
Dans cette démo, notre serveur VPN strongSwan fonctionne sur Debian 10 Buster. Par conséquent, vous pouvez vérifier l'état comme indiqué ci-dessous :
ipsec status
Security Associations (2 up, 0 connecting): ipsec-ikev2-vpn[4]: ESTABLISHED 18 seconds ago, 192.168.56.174[vpnsvr.kifarunix-demo.com]…192.168.56.1[koromicha] ipsec-ikev2-vpn{4}: INSTALLED, TUNNEL, reqid 4, ESP in UDP SPIs: c4e5f1c2_i c8e1a02f_o ipsec-ikev2-vpn{4}: 0.0.0.0/0 === 172.16.7.2/32 ipsec-ikev2-vpn[3]: ESTABLISHED 21 seconds ago, 192.168.56.174[vpnsvr.kifarunix-demo.com]…192.168.56.1[vpnsecure] ipsec-ikev2-vpn{3}: INSTALLED, TUNNEL, reqid 3, ESP in UDP SPIs: c7a4ee1d_i c558073b_o ipsec-ikev2-vpn{3}: 0.0.0.0/0 === 172.16.7.1/32
Tester la connexion des clients VPN
Maintenant que nous avons deux clients assignés leurs adresses individuelles ;
- Ubuntu 18.04 :172.16.7.1
- CentOS 8 :172.16.7.2
Pour tester la connexion, vous pouvez simplement exécuter le test ping.
À partir d'Ubuntu 18.04, envoyez un ping à CentOS 8 ;
ping 172.16.7.2
PING 172.16.7.2 (172.16.7.2) 56(84) bytes of data.
64 bytes from 172.16.7.2: icmp_seq=1 ttl=64 time=3.18 ms
64 bytes from 172.16.7.2: icmp_seq=2 ttl=64 time=4.15 ms
64 bytes from 172.16.7.2: icmp_seq=3 ttl=64 time=3.47 ms
64 bytes from 172.16.7.2: icmp_seq=4 ttl=64 time=3.61 ms
--- 172.16.7.2 ping statistics ---
4 packets transmitted, 4 received, 0% packet loss, time 10ms
rtt min/avg/max/mdev = 3.176/3.602/4.154/0.360 ms
Depuis CentOS 8, ping Ubuntu 18.04.
ping 172.16.7.1
PING 172.16.7.1 (172.16.7.1) 56(84) bytes of data.
64 bytes from 172.16.7.1: icmp_seq=1 ttl=64 time=3.24 ms
64 bytes from 172.16.7.1: icmp_seq=2 ttl=64 time=4.37 ms
64 bytes from 172.16.7.1: icmp_seq=3 ttl=64 time=4.08 ms
64 bytes from 172.16.7.1: icmp_seq=4 ttl=64 time=3.43 ms
--- 172.16.7.1 ping statistics ---
4 packets transmitted, 4 received, 0% packet loss, time 9ms
rtt min/avg/max/mdev = 3.237/3.780/4.371/0.462 ms
Essayez de vous connecter en SSH des deux côtés ;
ssh [email protected]
The authenticity of host '172.16.7.2 (172.16.7.2)' can't be established.
ECDSA key fingerprint is SHA256:wKoh/MWvCicV6cEe6jY19AkcBgk1lyjZorQt3aqflJM.
Are you sure you want to continue connecting (yes/no)? yes
Warning: Permanently added '172.16.7.2' (ECDSA) to the list of known hosts.
[email protected]'s password:
[[email protected] ~]$
ssh [email protected]
The authenticity of host '172.16.7.1 (172.16.7.1)' can't be established.
ECDSA key fingerprint is SHA256:v20whQz4a4zpTJQfny/CGG56fRnP3Dpx8g5CkeCtFpo.
Are you sure you want to continue connecting (yes/no)? yes
Warning: Permanently added '172.16.7.1' (ECDSA) to the list of known hosts.
[email protected]'s password:
Linux debian 4.19.0-8-amd64 #1 SMP Debian 4.19.98-1 (2020-01-26) x86_64
The programs included with the Debian GNU/Linux system are free software;
the exact distribution terms for each program are described in the
individual files in /usr/share/doc/*/copyright.
Debian GNU/Linux comes with ABSOLUTELY NO WARRANTY, to the extent
permitted by applicable law.
Last login: Wed Feb 26 00:54:04 2020 from 172.16.7.2
[email protected]:~$
Cela marque la fin de notre guide sur la configuration du client VPN strongSwan sur Ubuntu 18.04/CentOS 8.
Tutoriels associés
Connectez-vous à Cisco VPN à l'aide du fichier PCF sur Ubuntu
Configurer le VPN IPSEC à l'aide de StrongSwan sur Ubuntu 18.04
Installer et configurer le serveur OpenVPN sur Fedora 29/CentOS 7
Installer le client Cisco AnyConnect sur CentOS 8