Ubuntu 20.04 LTS Set Up OpenVPN Server In 5 Minutes
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:
- Install OpenVPN by running the command:
sudo apt install openvpn- Create a directory to store the server configuration files by running the command:
sudo mkdir /etc/openvpn/server- Generate the necessary certificate and key files by running the command:
sudo apt install easy-rsarnsudo make-cadir /etc/openvpn/server- Set up the server configuration by creating a new file
/etc/openvpn/server.confand 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 3You 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.
- Start the OpenVPN service by running the command:
sudo systemctl start openvpn@server- Enable the OpenVPN service to start automatically at boot by running the command:
sudo systemctl enable openvpn@server- Check the status of the OpenVPN service by running the command:
sudo systemctl status openvpn@server- 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.ovpnand 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- On the client side, you can install the OpenVPN client software, import the client configuration files and connect to the OpenVPN server.
