
Estoy intentando configurar un servidor VPN StrongSwan que debería albergar múltiples conexiones roadwarrior (Windows 10 - cliente vpn interno), pero diferentes subredes, según el certificado del cliente.
root@VPN:/# ipsec version
Linux strongSwan U5.8.2/K5.4.0-26-generic
Mi configuración tiene 2 pares de claves públicas y privadas, usando CN diferentes, digamos vpn-dev.mycom.com
y vpn-liv.mycom.com
. El usado ipsec.conf
se parece a esto:
conn vpn-dev
auto=add
compress=no
type=tunnel
keyexchange=ikev2
fragmentation=yes
forceencaps=yes
dpdaction=clear
dpddelay=300s
rekey=no
ikelifetime=25200s
leftid=vpn-dev.mycom.com
leftcert=server-cert.pem
leftsendcert=always
leftsubnet=0.0.0.0/0
right=%any
rightid=%any
rightauth=eap-mschapv2
rightsourceip=10.100.0.0/16-10.100.254.254/16
rightdns=8.8.8.8,8.8.4.4
rightsendcert=never
rightcert=ca-cert.pem
eap_identity=%identity
ike=aes128-sha1-modp1024
conn vpn-liv
also=vpn-dev
leftid=vpn-liv.mycom.com
leftcert=liv-server-cert.pem
rightsourceip=10.200.0.0/16-10.200.254.254/16
rightcert=liv-ca-cert.pem
Ambas claves de certificado también se almacenan en elipsec.secrets
vpn-dev.mycom.com : RSA "server-key.pem"
vpn-liv.mycom.com : RSA "liv-server-key.pem"
someuser : EAP "somepassword"
Sin embargo, tan pronto como intento conectarme a la instancia de Strongswan, vpn-dev
se utiliza la conexión y Strongswan no cambia a conexión.vpn-liv
Aquí están los registros durante un intento:
Mar 30 08:47:48 VPN charon: 16[NET] received packet: from X.X.X.X[64558] to X.X.X.X[500] (1084 bytes)
Mar 30 08:47:48 VPN charon: 16[IKE] received MS NT5 ISAKMPOAKLEY v9 vendor ID
Mar 30 08:47:48 VPN charon: 16[IKE] received MS-Negotiation Discovery Capable vendor ID
Mar 30 08:47:48 VPN charon: 16[IKE] X.X.X.X is initiating an IKE_SA
Mar 30 08:47:48 VPN charon: 16[CFG] selected proposal: IKE:AES_CBC_128/HMAC_SHA1_96/PRF_HMAC_SHA1/MODP_1024
Mar 30 08:47:48 VPN charon: 16[IKE] local host is behind NAT, sending keep alives
Mar 30 08:47:48 VPN charon: 16[IKE] remote host is behind NAT
Mar 30 08:47:48 VPN charon: 16[NET] sending packet: from X.X.X.X[500] to X.X.X.X[64558] (328 bytes)
Mar 30 08:47:48 VPN charon: 06[NET] received packet: from X.X.X.X[64596] to X.X.X.X[4500] (576 bytes)
Mar 30 08:47:48 VPN charon: 10[NET] received packet: from X.X.X.X[64596] to X.X.X.X[4500] (576 bytes)
Mar 30 08:47:48 VPN charon: 05[NET] received packet: from X.X.X.X[64596] to X.X.X.X[4500] (576 bytes)
Mar 30 08:47:48 VPN charon: 14[NET] received packet: from X.X.X.X[64596] to X.X.X.X[4500] (368 bytes)
Mar 30 08:47:48 VPN charon: 14[IKE] received cert request for "CN=PRIV VPN LIV CA"
Mar 30 08:47:48 VPN charon: 14[IKE] received 69 cert requests for an unknown ca
Mar 30 08:47:48 VPN charon: 14[CFG] looking for peer configs matching X.X.X.X[%any]...X.X.X.X[192.168.0.117]
Mar 30 08:47:48 VPN charon: 14[CFG] selected peer config 'vpn-dev' # << here it has not selected vpn-live, even if the earlier provided private key is only matching vpn-live
Mar 30 08:47:48 VPN charon: 14[IKE] initiating EAP_IDENTITY method (id 0x00)
Mar 30 08:47:48 VPN charon: 14[IKE] peer supports MOBIKE
Mar 30 08:47:48 VPN charon: 14[IKE] authentication of 'vpn-dev.mycom.com' (myself) with RSA signature successful
Mar 30 08:47:48 VPN charon: 14[IKE] sending end entity cert "CN=vpn-dev.mycom.com"
Mar 30 08:47:49 VPN charon: 14[IKE] sending cert request for "CN=PRIV VPN DEV CA"
Mar 30 08:47:49 VPN charon: 14[IKE] sending cert request for "CN=PRIV VPN LIV CA"
Mar 30 08:47:49 VPN charon: 14[NET] sending packet: from X.X.X.X[500] to X.X.X.X[64548] (364 bytes)
Mar 30 08:47:49 VPN charon: 06[NET] received packet: from X.X.X.X[64618] to X.X.X.X[4500] (92 bytes)
Mar 30 08:47:49 VPN charon: 06[IKE] received (28) error notify
El objetivo es básicamente alojar 2 puntos finales VPN en una máquina, pero proporcionar diferentes rangos de IP según el inicio de sesión/certificado utilizado.
La configuración local se realiza con (powershell)
Import-Certificate -FilePath liv-ca-cert.pem -CertStoreLocation 'Cert:\LocalMachine\Root'
Add-VpnConnection -Name 'LIV VPN' -ServerAddress 'vpn-live.mycom.com' -AuthenticationMethod Eap -IdleDisconnectSeconds 43200
¿Me estoy perdiendo de algo? ¿Mi configuración está mal configurada? ¿O esto simplemente no es posible con strongswan y el cliente vpn interno de Windows 10?
Respuesta1
Solo es posible cambiar conexiones según la identidad/certificado del servidor si:
- los clientes envían una identidad remota (IDr) en su solicitud IKE_AUTH, lo que muchos clientes no hacen (en particular Windows); de lo contrario, no hay ninguna identidad que coincida, por lo que se utilizará la primera conexión.
o
- si los FQDN se asignan a diferentes direcciones IP, que se pueden configurar como direcciones locales para las conexiones, de modo que se seleccione la conexión correcta desde el principio
Respuesta2
Resulta que no es posible utilizar el certificado ya que no se utilizan para identificar a los usuarios en el servidor.
Así que terminé usando una solución alternativa que se describe enesta respuestalo que ayuda a evaluar el eap_identiy
.
Ahora mis clientes usan el mismo certificado, pero según los inicios de sesión puedo decidir qué subred van a usar.
Mi ipsec.conf ahora se ve así:
conn eap-shared
type=tunnel
ike=aes128-sha1-modp1024
rightauth=eap-mschapv2
leftcert=server-cert.pem
conn eap-init
also=eap-shared
# this config is used to do the EAP-Identity exchange and the
# authentication of client and server
eap_identity=%identity
# the following is used to force a connection switch after
# the authentication completed
rightgroups=thisseemsirrelevant
auto=add
conn eap-liv
also=eap-shared
eap_identity=*@liv-some-domain.com
rightsourceip=10.200.0.0/16-10.200.254.254/16
auto=add
conn eap-dev
also=eap-shared
eap_identity=*@dev-some-domain.com
rightsourceip=10.100.0.0/16-10.100.254.254/16
auto=add
Puede que no sea la solución más elegante, pero funciona en mi caso.
Respuesta3
Para múltiples configuraciones de conexión con el mismo método de autenticación, Strongswan puede seleccionar la adecuada según la identidad del cliente.
Usando dos configuraciones de conexión, por ejemplo:
- Ambos lados derechos usan pubkey, podemos usar
rightca
como restricción:
conn dev-network_ikev2-cert
rightauth=pubkey
rightca="C=CN, O=Sample, CN=Develop CA"
rightsourceip=10.100.0.0/16
rightdns=8.8.8.8
conn test-network_ikev2-cert
rightauth=pubkey
rightca="C=CN, O=Sample, CN=Testing CA"
rightsourceip=10.200.0.0/16
rightdns=8.8.8.8
En esta configuración, el cliente con certificados emitidos por
Develop CA
seleccionará la configuracióndev-network_ikev2-cert
directamente.Si el cliente utiliza certificados emitidos por
Testing CA
, strongswan primero seleccionará configuracióndev-network_ikev2-cert
, luego salidaconstraint check failed: peer not authenticated by CA 'C=CN, O=Sample, CN=Develop CA'
y seleccionará el siguientetest-network_ikev2-cert
.
- Ambos lados derechos usan eap-mschapv2, podemos usar
eap_identity
como restricción:
conn dev-network_ikev2-eap
rightauth=eap-mschapv2
eap_identity=*@dev.com
rightsourceip=10.100.0.0/16
rightdns=8.8.8.8
conn test-network_ikev2-eap
rightauth=eap-mschapv2
eap_identity=*@test.com
rightsourceip=10.200.0.0/16
rightdns=8.8.8.8
Este es el método utilizado por Flo. Strongswan realizará una lógica de verificación similar a la del uso de pubkey.
- Si el cliente usa la identidad
*@test.com
, strongswan primero seleccionarádev-network_ikev2-eap
, luego la buscaráconstraint check failed: EAP identity '*@dev.com' required
y seleccionará la siguientetest-network_ikev2-eap
.
Espero que esto ayude.