You are on page 1of 2

StrongSwan is an open-source VPN solution that supports various protocols such as IKEv1, IKEv2,

and EAP. Here's a tutorial on how to configure StrongSwan on Linux:

1. Install StrongSwan

• On Ubuntu/Debian: sudo apt-get install strongswan


• On CentOS/RHEL: sudo yum install strongswan
2. Configure IPsec

• Edit the /etc/ipsec.conf file using your favorite text editor (e.g., nano ,
vim ).
• Here's a basic configuration file:

arduinoCopy code
config setup
charondebug="ike 2, knl 2, cfg 2, net 2, esp 2, dmn 2, mgr 2"
uniqueids=no

conn myvpn
auto=start
left=%defaultroute
leftsubnet=0.0.0.0/0
leftauth=psk
leftid=<your_server_public_ip>
right=<your_client_public_ip>
rightsubnet=192.168.0.0/24
rightauth=psk
ike=3des-sha1-modp1024
esp=3des-sha1
keyexchange=ikev1
keyingtries=3
dpddelay=30
dpdtimeout=120
dpdaction=clear
ikelifetime=8h
lifetime=1h
type=tunnel
mark=100

• Explanation of some of the key parameters:


• left : The IP address of the StrongSwan server
• right : The IP address of the VPN client
• leftsubnet : The IP range of the local network that will be accessible
through the VPN
• rightsubnet : The IP range of the remote network that will be accessible
through the VPN
• leftauth and rightauth : The authentication method. In this example,
we're using pre-shared keys (PSK).
• ike and esp : The encryption algorithm and hashing algorithm to be used
for the IKE and ESP protocols.
• keyexchange : The key exchange protocol. In this example, we're using
IKEv1.
• ikelifetime and lifetime : The lifetime of the IKE and ESP SAs,
respectively.
• dpddelay , dpdtimeout , and dpdaction : The Dead Peer Detection
(DPD) parameters.
3. Configure PSK

• Edit the /etc/ipsec.secrets file.


• Add a line like this: <your_server_public_ip>
<your_client_public_ip> : PSK "<your_psk>" .
• Replace <your_server_public_ip> with the public IP address of your
StrongSwan server, <your_client_public_ip> with the public IP address of
your VPN client, and <your_psk> with a strong pre-shared key.
4. Start StrongSwan

• Start the StrongSwan service: sudo systemctl start strongswan


• Enable the StrongSwan service to start automatically on boot: sudo systemctl
enable strongswan
5. Configure Firewall

• Allow traffic through the IPsec ports (UDP 500 and UDP 4500) in your firewall
rules.

That's it! You should now have a working StrongSwan VPN. Of course, this is just a basic
configuration, and you can customize it further to suit your needs.

You might also like