Introduction
OpenVPN is an open-source Virtual Private Network (VPN) project. It creates secure connections over the Internet using a custom security protocol that utilizes SSL/TLS.
VPN software protects your information by masking your device’s IP address, encrypting your data, and routing it through secure networks to servers in different locations. This helps hide your online identity and allows you to browse securely and anonymously.
This guide provides instructions for configuring an OpenVPN server on Ubuntu 18.04, 20.04, and 22.04 LTS.
Upgrade your system
Before installing OpenVPN, update your operating system to avoid incompatibilities.
If you are working as root user
apt update && apt full-upgrade -y && apt autoremove -y && apt autoclean
If you are working as normal user
sudo apt update && sudo apt full-upgrade -y && sudo apt autoremove -y && sudo apt autoclean
Find your server’s IP address
To get the IP address, run the following command:
ip address show up
You will receive output similar to the following:
2: eth0: mtu 1500
inet 192.168.121.241/24 brd 192.168.121.255 scope global dynamic eth0
Save this IP address. You will need it in the next steps.
Download OpenVPN installer script by Angristan
This script allows you to set up a secure VPN server in just a few seconds.
If you are working as root user
apt install curl -y && curl -O https://raw.githubusercontent.com/angristan/openvpn-install/master/openvpn-install.sh && chmod +x openvpn-install.sh
If you are working as normal user
sudo apt install curl -y && sudo curl -O https://raw.githubusercontent.com/angristan/openvpn-install/master/openvpn-install.sh && sudo chmod +x openvpn-install.sh
Run OpenVPN installer script by Angristan
Run the script as root and make sure the TUN module is enabled.
If you are working as root user
./openvpn-install.sh
If you are working as normal user
sudo ./openvpn-install.sh
Configure OpenVPN server
Step 1
Welcome to the OpenVPN installer!
IP address: [YOUR-SERVER-IP-ADDRESS]
Verify the displayed IP address and press Enter.
Step 2
Do you want to enable IPv6 support (NAT)? n
If your server does not have IPv6, simply press Enter.
Step 3
What port do you want OpenVPN to listen to?
1) Default: 1194
2) Custom
3) Random
Port choice [1-3]: 1
Press Enter to use the default port.
Step 4
What protocol do you want OpenVPN to use?
1) UDP
2) TCP
Protocol [1-2]: 1
UDP is recommended for better performance.
Step 5
What DNS resolvers do you want to use with the VPN?
3) Cloudflare
11) AdGuard DNS
DNS [1-12]: 11
Select your preferred DNS provider and press Enter.
Step 6
Enable compression? [y/n]: n
Leave compression disabled for security reasons.
Step 7
Customize encryption settings? [y/n]: n
Press Enter to use the default secure settings.
Step 8
Client name: [VPN-CLIENT-NAME]
Enter a name for your VPN client.
Step 9
Select an option [1-2]: 1
Choose whether the client configuration should be protected with a password.
The End
Download the .ovpn file and import it in your OpenVPN client.
Download the generated .ovpn file and import it into your preferred OpenVPN client.
How to create more clients
Re-run the installation script to add additional VPN clients.
Welcome to OpenVPN-install!
1) Add a new user
2) Revoke existing user
3) Remove OpenVPN
4) Exit
Select an option [1-4]: 1
Select option 1 and follow the client creation process again.
If you want to install your OpenVPN server, you can purchase a VPS or Dedicated Server from LyraHosting.