Ubuntu 20.04 LTS Set Up OpenVPN Server In 5 Minutes

Ubuntu 20.04 LTS Set Up OpenVPN Server In 5 Minutes

Setting up an OpenVPN server on Ubuntu 20.04 LTS is a relatively simple process that can be completed in just a few minutes. Here is a step-by-step guide to help you set up an OpenVPN server on your Ubuntu 20.04 LTS system:

  1. First, make sure that your system is up to date by running the following command:
sudo apt-get update
sudo apt-get upgrade
Sour‮‬ce:www.lautturi.com
  1. Install the OpenVPN package by running the following command:
sudo apt-get install openvpn
  1. Generate the necessary SSL/TLS certificates and keys:
sudo apt-get install easy-rsa
sudo make-cadir /etc/openvpn/easy-rsa
cd /etc/openvpn/easy-rsa

Now you will need to edit the file vars to set the appropriate values for your environment. Open the file with a text editor (e.g. nano) and make the following changes:

  • Set KEY_COUNTRY to the two-letter code for your country
  • Set KEY_PROVINCE to the name of your state or province
  • Set KEY_CITY to the name of your city
  • Set KEY_ORG to the name of your organization
  • Set KEY_EMAIL to your email address

Once you have made these changes, save the file and run the following command to initialize the PKI (public key infrastructure):

source vars
./clean-all
./build-ca

Follow the prompts to create the certificate authority (CA) certificate and key. Next, generate the server certificate and key:

./build-key-server server

Again, follow the prompts to create the server certificate and key. Finally, generate the client certificates and keys:

./build-key client1
./build-key client2

Replace client1 and client2 with the names of the clients that you want to create certificates for.

  1. Configure the OpenVPN server:

Copy the sample OpenVPN configuration file to the OpenVPN directory:

gunzip -c /usr/share/doc/openvpn/examples/sample-config-files/server.conf.gz > /etc/openvpn/server.conf

Edit the server.conf file with a text editor and make the following changes:

  • Uncomment the push "redirect-gateway def1 bypass-dhcp" line to force all client traffic through the VPN
  • Uncomment the push "dhcp-option DNS 208.67.222.222" and push "dhcp-option DNS 208.67.220.220" lines to set the OpenDNS servers as the DNS servers for the clients
  • Set the server and server-bridge options to specify the IP range for the VPN clients
  • Set the ca, cert, and key options to point to the files that you generated in step 3

Once you have made these changes, save the file and start the OpenVPN server by running the following command:

systemctl start openvpn@server
Created Time:2017-10-30 14:27:24  Author:lautturi