Introduction
IKEv2 is a modern, resilient VPN protocol that delivers fast reconnection, robust security, and native support on most operating systems. For organizations and developers who require stronger trust controls than third-party certificate providers, deploying an IKEv2 VPN with a custom Certificate Authority (CA) is a common and secure approach. This guide walks you through the full life cycle: creating a custom CA, issuing server and client certificates, configuring a popular VPN server (strongSwan on Linux), and provisioning common clients. It assumes familiarity with the Linux command line, OpenSSL, and basic networking.
Why use a custom CA for IKEv2?
Using a custom CA provides several concrete advantages for businesses and developers:
- Full trust control — You determine certificate issuance, validity periods, revocation, and key usage policies.
- Improved security posture — Minimizes external dependency on third-party CAs and allows shorter, safer lifetimes and algorithm control (e.g., ECDSA vs RSA).
- Operational flexibility — Automate client provisioning, revoke access quickly with CRLs or OCSP, and integrate with internal PKI workflows.
Prerequisites and security considerations
Before beginning, ensure the following:
- A Linux server (Ubuntu/Debian/CentOS) with root or sudo access to run strongSwan and OpenSSL.
- A static public IP or DNS name for the VPN endpoint.
- Open ports: UDP 500 (IKE) and UDP 4500 (NAT-T). Also ensure IP forwarding and firewall NAT rules permit client traffic.
- Strong cryptographic defaults: use modern curves (e.g., secp521r1 or prime256v1) or RSA 3072+, and set sensible lifetimes (e.g., CA 10 years, server 2-3 years, client 1 year by default).
Security tip: Keep the CA private key offline if possible. Perform signing on an isolated machine or HSM. Maintain a CRL and/or OCSP responder to revoke compromised client certs promptly.
Step 1 — Create a minimal custom CA with OpenSSL
We will create a self-signed root CA and use it to sign server and client certificates. Adjust CNs, subjects, and extensions to match your policy.
1) Generate CA private key (ECDSA recommended):
openssl ecparam -name prime256v1 -genkey -noout -out ca.key
2) Create a self-signed CA certificate (validity 10 years):
openssl req -x509 -new -nodes -key ca.key -sha256 -days 3650 -subj “/CN=MyCorp VPN Root CA/O=Example Corp/C=US” -out ca.crt
3) Prepare a config template for extensions (server/client) to set key usage and extended key usage appropriately. Example extension file can declare keyUsage and extendedKeyUsage for serverAuth and clientAuth. Keep these files backed up with your CA metadata.
Step 2 — Issue server certificate
Generate a server key and CSR, sign it with the CA, and include SubjectAltName (SAN) for your public IP or DNS.
1) Server key:
openssl genpkey -algorithm RSA -out server.key -pkeyopt rsa_keygen_bits:3072
2) CSR (replace vpn.example.com with your hostname):
openssl req -new -key server.key -subj “/CN=vpn.example.com/O=Example Corp” -out server.csr
3) Sign the server CSR with the CA (include SANs). Example using a temporary config file to add SANs:
openssl x509 -req -in server.csr -CA ca.crt -CAkey ca.key -CAcreateserial -out server.crt -days 825 -sha256 -extfile <(printf "subjectAltName=DNS:vpn.example.com,IP:203.0.113.5")
Note: On systems without process substitution, create a file for extfile instead.
Step 3 — Issue client certificates
Client certificates are crucial for certificate-based IKEv2 authentication. Each client should have its own key pair and certificate to enable per-user revocation.
1) Client key (prefer ECDSA for smaller keys):
openssl ecparam -name prime256v1 -genkey -noout -out client1.key
2) Client CSR:
openssl req -new -key client1.key -subj “/CN=client1@example.com/O=Example Corp” -out client1.csr
3) Sign with the CA (clientAuth EKU):
openssl x509 -req -in client1.csr -CA ca.crt -CAkey ca.key -CAcreateserial -out client1.crt -days 365 -sha256 -extfile <(printf "extendedKeyUsage = clientAuth")
4) Package key and cert for client installation (e.g., PKCS#12 for Windows/macOS):
openssl pkcs12 -export -inkey client1.key -in client1.crt -certfile ca.crt -out client1.p12 -name “client1@example.com”
Step 4 — Install and configure strongSwan on the server
strongSwan is a mature IPsec/IKEv2 implementation. Below are the essentials for Ubuntu/Debian; adapt package names for other distros.
1) Install:
sudo apt update && sudo apt install strongswan strongswan-pki libcharon-standard-plugins
2) Place certificates and keys under /etc/ipsec.d/:
- /etc/ipsec.d/private/server.key
- /etc/ipsec.d/certs/server.crt
- /etc/ipsec.d/cacerts/ca.crt
3) Update /etc/ipsec.conf with an IKEv2 connection block. Example minimal config (conceptual):
conn ikev2-vpn
left=%any
leftcert=server.crt
leftid=”vpn.example.com”
leftsubnet=0.0.0.0/0
right=%any
rightauth=pubkey
rightsourceip=10.10.10.0/24
ike=aes256gcm16-prfsha384-ecp521!
esp=aes256gcm16-ecp521!
keyexchange=ikev2
auto=add
Note: Use modern proposals (nonce and AEAD if possible) and force strong algorithms. The exclamation (!) forces exact match.
4) Enable IP forwarding and NAT masquerading (for clients to reach internet):
echo 1 | sudo tee /proc/sys/net/ipv4/ip_forward
iptables -t nat -A POSTROUTING -s 10.10.10.0/24 -o eth0 -j MASQUERADE
Persist ip_forward via /etc/sysctl.conf and use your distro’s firewall tooling to persist iptables rules (or use nftables).
5) Restart strongSwan:
sudo systemctl restart strongswan
Step 5 — Configure CRL and revocation handling
When using a custom CA you must maintain certificate revocation to remove compromised clients. Generate a CRL and serve it where the VPN server can fetch it or load it locally:
1) Create CRL:
openssl ca -config /etc/ssl/openssl.cnf -revoke client1.crt -keyfile ca.key -cert ca.crt
openssl ca -gencrl -out crl.pem -keyfile ca.key -cert ca.crt
2) Copy crl.pem to /etc/ipsec.d/crls/ and ensure strongSwan is configured to check CRLs for client validation.
Alternatively, implement an OCSP responder for real-time revocation checks if your environment requires faster response and lower operational windows.
Step 6 — Client setup examples
macOS and iOS (Built-in IKEv2)
Use a PKCS#12 bundle (.p12) that contains the client key and certificate, plus the root CA installed as trusted. On iOS, you can distribute the .p12 via MDM or secure download; install the profile and trust the CA. Create a new VPN configuration: type IKEv2, server = vpn.example.com, remote ID = vpn.example.com, local ID = client certificate CN. Set authentication to Certificate.
Windows 10/11
Import the .p12 into the Windows certificate store (Current User – Personal). Import the CA certificate into Trusted Root Certification Authorities. Create a new VPN connection (type = IKEv2) in Settings > Network & Internet > VPN. Under Security properties, choose “Use machine certificates” or user certificate depending on your config. For domain-joined endpoints, you can deploy certificates via GPO.
Linux (strongSwan or NetworkManager)
Use strongSwan’s swanctl or NetworkManager’s key files. For swanctl, install client cert/key into /etc/ipsec.d and configure swanctl.conf with local and remote auth using public key. For NetworkManager, import the .p12 and select IKEv2 with certificate authentication.
Operational tips and monitoring
- Enable logging in strongSwan but keep log levels appropriate for production to avoid disk exhaustion. Use syslog or journald centralization.
- Monitor certificate expirations. Automate reminders for renewals at least 30 days before expiry.
- Use short client certificate lifetimes if you plan frequent rotation; keep CA lifetime longer but protect its key carefully.
- Regularly review IKE/ESP proposals and keep cryptographic libraries up to date to mitigate newly discovered vulnerabilities.
Troubleshooting common issues
If clients fail to connect, check these items first:
- Server logs: sudo journalctl -u strongswan or check /var/log/syslog for IKE errors.
- Certificate chain issues: ensure the server presents the full chain (server cert + CA) if required by the client.
- NAT traversal: ensure UDP 4500 is open and that strongSwan is configured to handle NAT-T.
- IP forwarding and firewall rules: confirm traffic is forwarded and NATed correctly; verify routing table entries for client subnets.
- CRL/OCSP: ensure revoked certificates are reflected if a client was revoked; misconfigured CRLs can block valid clients.
Conclusion
Deploying IKEv2 with a custom CA gives you granular trust control and the ability to manage client identities securely. By combining careful CA practices (offline key storage where possible, short client lifetimes, CRL/OCSP for revocation) with strong server-side cryptographic choices and correct firewall/NAT configuration, you can provide a robust VPN environment for employees, customers, or devices. Follow change control and automation practices for certificate issuance and revocation to scale securely.
For more in-depth tutorials, tool-specific examples, and managed dedicated-IP solutions, visit Dedicated-IP-VPN at https://dedicated-ip-vpn.com/