In this post, we explain how to install OpenVPN easily with 3 commands. This is possible thanks to the author of openvpn-install, available on GitHub. To create our server, we will use a machine running Ubuntu 16.04 with 1 GB of RAM, 1 Core, and 25 GB of disk space.
Install OpenVPN server
To install OpenVPN server with a web interface for managing users, simply run the following commands:
# wget https://raw.githubusercontent.com/theonemule/simple-openvpn-server/master/openvpn.sh
# chmod +x openvpn.sh
# ./openvpn.sh --adminpassword=TestVPN25TestVPN25 will be the default password we use to access our server through the web interface to create users. We recommend using a different, secure password. The script uses the following values by default:
DNS1="8.8.8.8"
DNS2="8.8.4.4"
PROTOCOL=udp
PORT=1194
HOST=$(wget -4qO- “http://whatismyip.akamai.com/”) // Finds our server's IP addressYou can change these values by passing the corresponding variables to the installation script (check the script's code for the variable names to use). For example, to use these DNS servers: 208.67.222.222 208.67.220.220 and this host: vpn.midominio.com
# ./openvpn.sh --adminpassword=TestVPN25 --dns1=208.67.222.222 --dns2=208.67.220.220 --host=vpn.midominio.com --email=tuemail@dominio.comConfigure the Firewall
Once we have installed our OpenVPN server, we need to open UDP port 1194 in our firewall. The configuration should look like the following image:
Manage OpenVPN Users
To manage the users who will have access to our VPN, open the administration interface in your browser at https://IPservidorVPN. You will be prompted for the username admin and password TestVPN25 (the password we specified in the installation script). Once logged in, we can create as many users (clients) as we need:
Once the clients have been created, there will be 2 links: “Revoke” deletes a client, and “Download” contains all the configuration needed to use OpenVPN on a PC, mobile phone, or tablet. Do not delete “server”.
Connect to Your OpenVPN Server
Using the file downloaded in the previous step, follow these steps (in the following examples, we call it FicheroConfig.ovpn; the actual name will depend on the name you chose):
- Windows Go to the OpenVPN website > Descargas and download the Windows version “Installer, Windows Vista and later”. Copy FicheroConfig.ovpn to “C:\Archivos de Programa\OpenVPN\config” and open OpenVPN. An OpenVPN icon will appear in the taskbar. Right-click it to access the options to connect/disconnect and use your VPN.
- MacOS Go to the website for Tunnelblick and download the stable version. Once installed, open FicheroConfig.ovpn from Finder and import it. The Tunnelblick icon will appear in the menu bar, where you can connect/disconnect and use your VPN.
- Linux Run sudo openvpn --config FicheroConfig.ovpn from the terminal. If you use Ubuntu, another option is “sudo apt-get install network-manager-openvpn-gnome”. In the network manager, go to “Editar las Conexiones > Añadir > Importar una configuración VPN guardada”, select FicheroConfig.ovpn, and you can then use your VPN.
- Android Install from PlayStore OpenVPN Connect then open the app and go to “Menú > Import >Import Profile from SD card”. Select FicheroConfig.ovpn there, and you can then use your VPN.
- iOS Install from AppStore OpenVPN Connect then open the app and go to “Import your Private Tunnel Profile”. Select FicheroConfig.ovpn there, and you can then use your VPN.