Installing strongSwan on POP! OS

strongSwan is an open-source VPN solution that provides secure communication between servers, laptops, desktops, and mobile devices. In this tutorial, we will guide you to install strongSwan on POP! OS.

Prerequisites

Before proceeding with the installation process, make sure your system meets the following requirements:

Step 1: Updating System Packages

The first step is always updating your system packages. This will help to ensure that all the system packages are up to date and bug-free, including key security packages.

To update your system packages, open up a terminal window and run the following command:

sudo apt update && sudo apt upgrade

Step 2: Installing strongSwan

Once the system packages have been updated, we can now proceed to install strongSwan.

Open up a terminal window and enter the following command:

sudo apt install strongswan

After running the command, the system will prompt you to confirm the installation process by pressing the Y key. Enter Y and wait for the installation to complete.

Step 3: Configuring strongSwan

Now that strongSwan is installed, we need to configure its settings. You can either configure everything manually or copy the default configurations files.

This tutorial will copy the default configuration files, which are stored in the /etc/ipsec.d/ directory. To copy the default configuration files, run the following command:

sudo cp -R /usr/share/doc/strongswan/examples/ipsec.d/* /etc/ipsec.d/

Here, the cp command is used to copy files from the source directory (/usr/share/doc/strongswan/examples/ipsec.d/) to the destination directory (/etc/ipsec.d/). The -R flag is used to copy the directories recursively.

Next, we need to configure the strongSwan service. To do so, open up the /etc/ipsec.conf file:

sudo nano /etc/ipsec.conf

In the editor, add the following lines at the end of the file:

conn myvpn
  auto=add
  left=192.168.0.10
  leftsubnet=192.168.0.0/24
  right=%any
  rightsubnet=192.168.1.0/24
  authby=secret
  type=tunnel
  ikev2=insist

Here, we define a connection named myvpn. left is the IP address of the local VPN gateway, and leftsubnet is the subnet of the local network. right is the IP address of the remote VPN gateway, and rightsubnet is the subnet of the remote network. authby is the authentication method, which we set to secret for simplicity. The type specifies that it's a tunnel connection, and ikev2 specifies that it should use the IKEv2 protocol for key exchange.

Once you've added the configuration lines, save and close the file by pressing Ctrl+X, followed by Y, and then Enter.

Step 4: Configuring the Pre-shared Key

Next, we need to configure the pre-shared key, which is used to authenticate the peers. For this tutorial, we'll use the simple pre-shared key mykey. You can use your own key, but make sure it's strong and secure.

To configure the pre-shared key, open up the /etc/ipsec.secrets file:

sudo nano /etc/ipsec.secrets

Add the following line at the end of the file:

192.168.0.10 192.168.1.0 : PSK "mykey"

Here, 192.168.0.10 is the IP address of the local VPN gateway, 192.168.1.0 is the subnet of the remote network, and PSK specifies that it's a pre-shared key. The pre-shared key is set to mykey. Once you've added the line, save and close the file.

Step 5: Restarting the strongSwan Service

With everything configured, we can now restart strongSwan to apply the changes.

To restart the strongSwan service, run the following command:

sudo systemctl restart strongswan

You can check the status of the service by running the following command:

sudo systemctl status strongswan

If the service is active and running, you should see a message that says active (running).

Conclusion

Congratulations! You have successfully installed and configured strongSwan on your POP! OS system. You can now configure your VPN clients to connect to your strongSwan VPN gateway.

If you want to self-host in an easy, hands free way, need an external IP address, or simply want your data in your own hands, give IPv6.rs a try!

Alternatively, for the best virtual desktop, try Shells!