Skip to content
TrySitePrice

Ubuntu 20.04 LTS Set Up OpenVPN Server In 5 Minutes

Best/Tutorial

Setting up an OpenVPN server on Ubuntu 20.04 LTS can be done in a few simple steps. Here is an overview of the process:

  1. Install OpenVPN by running the command:
sudo apt install openvpn
  1. Create a directory to store the server configuration files by running the command:
sudo mkdir /etc/openvpn/server
  1. Generate the necessary certificate and key files by running the command:
sudo apt install easy-rsarnsudo make-cadir /etc/openvpn/server
  1. Set up the server configuration by creating a new file /etc/openvpn/server.conf and adding the following lines:
port 1194
proto udprndev tunrnca /etc/openvpn/server/ca.crtrncert /etc/openvpn/server/server.crtrnkey /etc/openvpn/server/server.keyrndh /etc/openvpn/server/dh2048.pemrnserver 10.8.0.0 255.255.255.0
ifconfig-pool-persist ipp.txtrnpush "redirect-gateway def1 bypass-dhcp"
push "dhcp-option DNS 8.8.8.8"
push "dhcp-option DNS 8.8.4.4"
keepalive 10 120
comp-lzornuser nobodyrngroup nogrouprnpersist-keyrnpersist-tunrnstatus openvpn-status.logrnverb 3

You can change the port number and protocols as per your need, and also set up your own DNS server instead of the Google's DNS servers.

  1. Start the OpenVPN service by running the command:
sudo systemctl start openvpn@server
  1. Enable the OpenVPN service to start automatically at boot by running the command:
sudo systemctl enable openvpn@server
  1. Check the status of the OpenVPN service by running the command:
sudo systemctl status openvpn@server
  1. Create client configuration files for each device that will connect to the OpenVPN server. You can create a new file for each client, for example client1.ovpn and add the following lines:
clientrndev tunrnproto udprnremote <your-server-ip> 1194
resolv-retry infiniternnobindrnpersist-key
persist-tunrnca ca.crtrncert client1.crtrnkey client1.key
comp-lzornverb 3
  1. On the client side, you can install the OpenVPN client software, import the client configuration files and connect to the OpenVPN server.
rnIt's important to note that, the above-explained steps are a basic setup and it should be used only for testing or in a secure environment. It is recommended to use a more secure setup with stronger encryption and authentication methods, also you should configure firewall rules to protect the OpenVPN server.