This project has the goal to automate the setup of a OpenVPN Server.
If you want to collaborate in this project, reach out us by e-Mail.
This script works on the following Linux distributions:
Debian 10 or later
Ubuntu LTS 18 or later
Fedora in any version
CentOS 7 or 8
Amazon Linux 2
Oracle Linux 8
Arch Linux in any version
It's possible to work on other OSes, but it will need customization.
To run the script, it's necessary to have root privileges or be a sudo user.
Basically, you just need to execute the setup.sh
file and follow the steps below:
- Define/confirm your public IP address.
- Define the VPN Server network address mask (/24).
- Define/confirm the VPN Server network port.
- Define/confirm if the VPN Server will listen in TCP or UDP.
- Define/confirm the DNS resolver.
- Define/confirm if you want to use compression in the VPN tunnels.
- Define/confirm the compression algorithm if you chose to use compression.
- Define/confirm the encryption settings.
- Define/confirm the default VPN client name.
- Define/confirm the default VPN client password.
The setup is interactive but if you want to do an unattended setup, set the following environment variables before:
AUTO_INSTALL=y
: Enable unattended setup with default values.APPROVE_IP=y
: Use the public IP of your machine or network.SERVER_NETWORK_ADDRESS_PREFIX
: Define the VPN Server network address mask (/24). Default value is10.8.0.0
PORT_CHOICE
: Define/confirm the VPN Server network port. Default value is1194
.PROTOCOL_CHOICE
: Define/confirm if the VPN Server will listen in TCP or UDP. Default value isUDP
.DNS
: Define/confirm the DNS resolver. Default value will be your machine or network DNS resolver.COMPRESSION_ENABLED
: Define/confirm if you want to use compression in the VPN tunnels. Default value isn
.CUSTOMIZE_ENC
: Define/confirm the compression algorithm if you chose to use compression. Default value isn
.CLIENT
: Define/confirm the default VPN client name. Default value isclient
.PASS
: Define/confirm the default VPN client password. Default value ispasswordless
.
After that, the script will generate the client/server certificates based on the previous settings, install all required software based on the machine operating system and set up the startup script.
Once the VPN Server is running, you will be able to connect into the VPN Server.
If you execute the setup.sh
again, you will be able to create a new client, revoke existing client or uninstall the
VPN Server.
This script was customized based on this project
And that's all! Enjoy!