Connecting your Elastix server to a MikroTik OpenVPN server can greatly enhance network security and more features. In this guide, we will walk you through the step-by-step process to set up the OpenVPN client on Elastix 4.0.76 running CentOS 7.


Step 1: Access Elastix via PuTTy and FileZilla

  • Connect to your Elastix terminal using PuTTy.
  • Use FileZilla for SFTP access to transfer files to Elastix.

Step 2: Download Necessary RPM Packages

Download the following RPM packages to your local PC:

You may use alternate download links if the above sources failed. Below is the alternate download links.


Step 3: Prepare the RPM Files on Elastix

  1. Open PuTTy and run the following commands:
cd /tmp
mkdir ovpn
cd ovpn
  1. Switch to FileZilla and upload the downloaded RPM files into the /tmp/ovpn/ folder.
  2. Back in PuTTy, install the RPM packages:
rpm -Uvh --replacepkgs --replacefiles *.rpm
Check the OpenVPN version if successfully installed.
openvpn --version

Step 4: Upload MikroTik Certificates

  1. Download the following files from MikroTik:
    • ca.crt
    • client.crt
    • ovpnclient.key
  2. Keep the private key file name as ovpnclient.key, because we will remove the passphrase by renaming the key file.
  3. Upload all three files to Elastix in the /etc/openvpn/ folder.
  4. Remove the passphrase from the private key:
openssl rsa -in /etc/openvpn/ovpnclient.key -out /etc/openvpn/client.key

Enter the passphrase 12345678 when prompted.

  1. Secure the private key file:
chmod 600 /etc/openvpn/client.key

Step 5: Create OpenVPN Client Configuration

Create the client configuration file:

nano /etc/openvpn/client.conf

Paste the following configuration:

client
dev tun
proto tcp
remote <MIKROTIK_PUBLIC_IP> <PORT>
resolv-retry infinite
nobind
persist-key
persist-tun
ca /etc/openvpn/ca.crt
cert /etc/openvpn/client.crt
key /etc/openvpn/client.key
remote-cert-tls server
verb 3
auth-user-pass /etc/openvpn/credentials.txt
auth-nocache
route-nopull
script-security 2
up "/etc/csf/csfpost.sh &"

Replace <MIKROTIK_PUBLIC_IP> and <PORT> with your MikroTik server’s details.

Save and exit the file.


Step 6: Provide VPN Credentials

Create a credentials file for the OpenVPN client:

nano /etc/openvpn/credentials.txt

Add your vpn username and password:

username
password

Save and secure the file:

chmod 600 /etc/openvpn/credentials.txt

Step 7: Test the VPN Connection

Run the following command to test the connection:

openvpn --config /etc/openvpn/client.conf
  • You should see Initialization Sequence Completed, indicating a successful connection.
  • Verify the tun0 interface and assigned IP:
ip addr show tun0

Step 8: Enable OpenVPN on System Startup

To make OpenVPN auto-connect on reboot:

systemctl enable openvpn@client
reboot

🎉 Congratulations!

Your Elastix OpenVPN Client is now successfully configured and ready to securely connect to your MikroTik ovpn server.

Leave A Comment