CentOS 8 Set Up OpenVPN Server In 5 Minutes

www.la‮uttu‬ri.com
CentOS 8 Set Up OpenVPN Server In 5 Minutes

Setting up an OpenVPN server on CentOS 8 can be done in just a few minutes using the following steps:

  1. Install the OpenVPN package:
sudo dnf install openvpn
  1. Copy the sample OpenVPN configuration files to the /etc/openvpn directory:
sudo cp /usr/share/doc/openvpn-*/sample/sample-config-files/* /etc/openvpn
  1. Rename the sample configuration file to server.conf:
sudo mv /etc/openvpn/server.conf.sample /etc/openvpn/server.conf
  1. Edit the server.conf file and configure the OpenVPN server settings. At a minimum, you will need to set the local and proto options. For example:
local 192.168.1.100
proto udp
  1. Generate the encryption keys and certificates required for the OpenVPN server and clients:
sudo bash -c 'umask 077; /usr/share/openvpn/easy-rsa/easyrsa init-pki; /usr/share/openvpn/easy-rsa/easyrsa build-ca nopass; /usr/share/openvpn/easy-rsa/easyrsa gen-req server nopass; /usr/share/openvpn/easy-rsa/easyrsa sign-req server server; /usr/share/openvpn/easy-rsa/easyrsa gen-dh'
  1. Copy the required files to the /etc/openvpn directory:
sudo cp /usr/share/openvpn/easy-rsa/pki/ca.crt /usr/share/openvpn/easy-rsa/pki/private/server.key /usr/share/openvpn/easy-rsa/pki/issued/server.crt /etc/openvpn
  1. Enable and start the OpenVPN service:
sudo systemctl enable --now openvpn@server
  1. Configure your firewall to allow incoming connections on the OpenVPN port (udp/1194 by default). For example, to allow incoming connections using firewalld:
sudo firewall-cmd --add-service=openvpn --permanent
sudo firewall-cmd --reload

That's it! Your OpenVPN server should now be up and running. You can create client configuration files using the instructions in the /usr/share/doc/openvpn/README.fedora file, or by following the official OpenVPN documentation.

Note: These instructions are intended as a basic guide for setting up an OpenVPN server on CentOS 8. For a more secure and robust OpenVPN setup, you should consider using additional security measures such as certificate authentication, firewall rules, and seccomp filters.

Created Time:2017-10-16 14:38:40  Author:lautturi