To establish a secure VPN connection to AzireVPN using strongSwan, you'll first need to obtain the necessary certificate. AzireVPN utilizes a certificate authority (CA) for authenticating its servers. Download the AzireVPN CA certificate, typically available in .pem format from their website.
Once you have the certificate, place it in the appropriate directory for strongSwan to access. A common location is /etc/ipsec.d/cacerts/. Ensure the file has appropriate permissions (readable by the ipsec user).
Next, configure your ipsec.conf file. A basic configuration would look like this:
conn azirevpn
type=tunnel
auto=add
keyexchange=ikev2
authby=rsasig
left=%any
leftid=%any
right=YOUR_AZIREVPN_SERVER_IP_OR_HOSTNAME
rightid=%any
rightsubnet=0.0.0.0/0
leftsourceip=%config
ike=aes256gcm16-sha384-prfsha384-ecp384!
esp=aes256gcm16-sha384-ecp384!
dpdaction=clear
dpddelay=300s
rekey=yes
leftcert=/etc/ipsec.d/certs/YOUR_CLIENT_CERT.pem
leftprivate=/etc/ipsec.d/private/YOUR_CLIENT_PRIVATE_KEY.pem
rightcert=/etc/ipsec.d/cacerts/azirevpn_ca.pem
Replace YOUR_AZIREVPN_SERVER_IP_OR_HOSTNAME with the actual AzireVPN server address. If you're using client certificates (recommended), generate a client certificate and key, place them in /etc/ipsec.d/certs/ and /etc/ipsec.d/private/ respectively, and update leftcert and leftprivate accordingly. If you are using EAP-TLS, configure accordingly.
After the strongSwan connection to AzireVPN is established, configure your routing table to direct all traffic through the VPN tunnel. This typically involves adding a default route pointing to the VPN gateway. The leftsourceip=%config option in the ipsec.conf assigns an IP address to the ipsec0 interface. You can use this IP as the gateway.
Example commands using ip route:
ip route add default via [IP address assigned to ipsec0 interface] dev ipsec0
To prevent DNS leaks, configure your system to use AzireVPN's DNS servers. This is typically done by modifying /etc/resolv.conf or using a network manager configuration. Using systemd-resolved requires editing /etc/systemd/resolved.conf and setting DNS= to the AzireVPN DNS servers, and restarting the service. Some AzireVPN configurations may push DNS server addresses automatically.
Proper firewall configuration is crucial for security. Ensure that your firewall allows the necessary UDP ports for IKEv2 (500 and 4500) to reach the AzireVPN server. If using NAT-T, these ports are essential.
Using iptables, you can achieve this with:
iptables -A INPUT -p udp --dport 500 -j ACCEPT
iptables -A INPUT -p udp --dport 4500 -j ACCEPT
iptables -A OUTPUT -p udp --dport 500 -j ACCEPT
iptables -A OUTPUT -p udp --dport 4500 -j ACCEPT
For nftables, the equivalent rules are:
nft add rule inet filter input udp dport { 500, 4500 } counter accept
nft add rule inet filter output udp dport { 500, 4500 } counter accept
Also, ensure that traffic originating from your internal network and destined for the internet is routed through the ipsec0 interface (or the interface assigned to the strongSwan tunnel). This might involve masquerading traffic from your internal network behind the VPN's IP address.
After configuring strongSwan and establishing the connection to AzireVPN, verify that the VPN is functioning correctly. Use tools like traceroute or mtr to confirm that your traffic is indeed being routed through the AzireVPN server.
A simple test involves checking your public IP address before and after connecting to the VPN. Use a website like ifconfig.me or icanhazip.com. After connecting, the IP address should match the AzireVPN server's IP.
Additionally, use a DNS leak test to ensure your DNS requests are being routed through AzireVPN's DNS servers and not your ISP's. Several online DNS leak test tools are available.
A common issue is certificate verification failures. Double-check the path to the AzireVPN CA certificate in your ipsec.conf file and ensure the certificate is valid.
Another potential problem is incorrect routing. Verify that your default route is correctly pointing to the ipsec0 interface. Use the ip route command to diagnose routing issues.
Firewall misconfigurations can also prevent the VPN from working. Ensure that the necessary UDP ports (500 and 4500) are open in both directions. Check your firewall logs for blocked connections.
If you encounter issues with DNS resolution, verify that your /etc/resolv.conf file (or your network manager's DNS settings) is configured to use AzireVPN's DNS servers. Test DNS resolution using nslookup or dig.
Finally, ensure that strongSwan is properly started and running. Use the command sudo ipsec status to check the status of the VPN connection. Check the strongSwan logs (typically located in /var/log/syslog or /var/log/daemon.log) for error messages.