OpenVPN is a versatile and secure VPN (Virtual Private Network) solution that allows you to securely connect devices across networks. Setting up your own self-hosted OpenVPN server ensures complete control over your VPN infrastructure. This guide outlines the step-by-step procedure to set up an OpenVPN server on Ubuntu.
Begin by updating the repository and installing Git, which is required for downloading the necessary files.
sudo apt update
sudo apt install gitClone the OpenVPN installation repository using Git.
git clone https://github.com/Nyr/openvpn-install.gitNavigate to the downloaded directory and set permissions for the installation script.
cd openvpn-install/
sudo chmod +x openvpn-install.shRun the installation script.
sudo ./openvpn-install.shFollow the prompts to fill in the required arguments for the installation. These typically include:
- Protocol (UDP or TCP)
- Port (default is 1194)
- DNS resolver (typically Google DNS or Cloudflare DNS)
- Client name (username)
After providing the necessary arguments, press Enter to complete the installation process. Note that the name of your ".ovpn" file, typically "sobhan," is arbitrary.
Once the installation is complete, your ".ovpn" configuration file will be generated and accessible in the "/root/" directory. You can download this file using SCP tools like WinSCP for Windows machines.
Ensure that the tunnel interface has been created, typically identified as something like "10.8.0.0".
ip ad | grep tun0Start the OpenVPN service and enable it to run at system startup.
service openvpn@server start
systemctl enable openvpn@serverTo add new users to your OpenVPN server, rerun the installation script.
sudo ./openvpn-install.shFor further details and troubleshooting, refer to the comprehensive article on installing and configuring OpenVPN server on Ubuntu.
Follow these steps to set up your self-hosted OpenVPN server for secure network communications.