[email protected]Support 24/7 · Billing 09:00 – 00:00LinkedInXFacebook
NexonHost
Netherlands Dedicated ServersAmsterdam · Equinix AM6Germany Dedicated ServersFrankfurt · Equinix FR4Romania Dedicated ServersBucharest · VoxilityAustria Dedicated ServersVienna · Interxion VIEBulgaria Dedicated ServersSofia · TelepointFrance Dedicated ServersParis · Interxion PAR — Marseille · Digital Realty MRS3Ireland Dedicated ServersDublin · Equinix DB2Italy Dedicated ServersMilan · Irideos AvalonPoland Dedicated ServersWarsawSpain Dedicated ServersMadrid · Equinix MD2United States Dedicated ServersAshburn · Equinix DC
All articles
Knowledge BaseJanuary 15, 2024

How to install OpenVPN

Guide to Install OpenVPN on Ubuntu 20.04

Step 1: Update System Packages

sudo apt update
sudo apt upgrade -y

Step 2: Install OpenVPN and Easy-RSA

sudo apt install openvpn easy-rsa -y

Step 3: Set Up the Certificate Authority (CA)

  1. Create a directory for Easy-RSA:

make-cadir ~/openvpn-ca
cd ~/openvpn-ca
  1. Edit the vars file to customize CA settings:

nano vars

Update the following lines with your information:

set_var EASYRSA_REQ_COUNTRY    "US"
set_var EASYRSA_REQ_PROVINCE   "California"
set_var EASYRSA_REQ_CITY       "Los Angeles"
set_var EASYRSA_REQ_ORG        "MyOrganization"
set_var EASYRSA_REQ_EMAIL      "[email protected]"
set_var EASYRSA_REQ_OU         "MyOrganizationalUnit"

Step 4: Build the CA

./easyrsa init-pki
./easyrsa build-ca nopass

Step 5: Generate Server Certificate and Key

./easyrsa gen-req server nopass
sudo cp pki/private/server.key /etc/openvpn/

Step 6: Sign Server Certificate

./easyrsa sign-req server server
sudo cp pki/issued/server.crt /etc/openvpn/
sudo cp pki/ca.crt /etc/openvpn/

Step 7: Generate Diffie-Hellman Parameters

./easyrsa gen-dh
sudo cp pki/dh.pem /etc/openvpn/

Step 8: Configure OpenVPN Server

  1. Copy the sample configuration file:

sudo cp /usr/share/doc/openvpn/examples/sample-config-files/server.conf.gz /etc/openvpn/
cd /etc/openvpn/
sudo gzip -d server.conf.gz
  1. Edit the server configuration file:

sudo nano server.conf

Uncomment or set the following lines:

ca ca.crt
cert server.crt
key server.key  # keep secret
dh dh.pem
push "redirect-gateway def1 bypass-dhcp"
push "dhcp-option DNS 8.8.8.8"
push "dhcp-option DNS 8.8.4.4"

Step 9: Enable IP Forwarding

Edit the sysctl configuration:

sudo nano /etc/sysctl.conf

Uncomment this line:

net.ipv4.ip_forward=1

Apply changes:

sudo sysctl -p

Step 10: Start and Enable OpenVPN

sudo systemctl start openvpn@server
sudo systemctl enable openvpn@server

Step 11: Configure Firewall (if UFW is enabled)

sudo ufw allow 1194/udp
sudo ufw allow OpenSSH
sudo ufw enable

Step 12: Generate Client Certificates

cd ~/openvpn-ca
./easyrsa gen-req client1 nopass
./easyrsa sign-req client client1
cp pki/private/client1.key /etc/openvpn/
cp pki/issued/client1.crt /etc/openvpn/

Step 13: Create Client Configuration File

Create a client config file client1.ovpn:

client
dev tun
proto udp
remote your_server_ip 1194
resolv-retry infinite
nobind
persist-key
persist-tun
remote-cert-tls server
cipher AES-256-CBC
auth SHA256
auth-nocache
verb 3
<ca>
$(cat /etc/openvpn/ca.crt)
</ca>
<cert>
$(cat /etc/openvpn/client1.crt)
</cert>
<key>
$(cat /etc/openvpn/client1.key)
</key>

Step 14: Connect to VPN

Transfer the client1.ovpn file to your client machine and connect using:

openvpn --config client1.ovpn

OpenVPN is now installed and configured on your Ubuntu 20.04 server.

 

Keep reading
HTTP response status codes
February 21, 2023

HTTP response status codes

HTTP response status codes HTTP response status codes indicate whether a specific HTTP request has been successfully completed. Information responses 100 Continue This interim response indicates that the client should continue the request or ignore the response if the request is already finished.

Read article
How To Install Nginx on Ubuntu 18
February 21, 2023

How To Install Nginx on Ubuntu 18

How To Install Nginx on Ubuntu 18 Installing Nginx Since Nginx is available in Ubuntu’s default repositories, it is possible to install it from these repositories using the apt packaging system. sudo apt install nginx After accepting the procedure, apt will install Nginx and any required…

Read article
How to Configure Static IP Address on Ubuntu 18
February 21, 2023

How to Configure Static IP Address on Ubuntu 18

How to Configure Static IP Address on Ubuntu 18 The newer versions of Ubuntu uses ‘Predictable Network Interface Names’ that, by default, start with en[letter][number]. The first step is to identify the name of the ethernet interface you want to configure. To do so use the ip link command, as…

Read article
Get in Touch

Together, Let’s Build a Faster, Safer Internet.

Build scalable infrastructure with NexonHost — high-performance dedicated servers, VPS hosting, cloud hosting, and DDoS protection across Europe.

Get Started →Contact Us
[email protected]Support 24/7 · Billing 09:00 – 00:00