CentOS 7 Set Up OpenVPN Server In 5 Minutes

OpenVPN is a full-featured SSL VPN (virtual private network). It implements OSI layer 2 or 3 secure network extension using the SSL/TLS protocol. It is an open source software and distributed under the GNU GPL. A VPN allows you to connect securely to an insecure public network such as wifi network at the airport or hotel. VPN is also required to access your corporate or enterprise or home server resources. You can bypass the geo-blocked site and increase your privacy or safety online. This tutorial provides step-by-step instructions for configuring an OpenVPN server on CentOS Linux 7 server.

1. Update your system

Run the yum command

sudo yum update

2. Find and note down your IP address

Use the ip command as follows

ip a
ip a show eth0
ip-command-get-my-IP-address-on-CentOS-Linux-7.0.png (599×353)

Another option is to run the following dig command/host command to find out your public IP address from Linux command line

dig +short

One can grab find IPv4 address using the dig and awk command

dig -4 TXT +short | awk -F'"' '{ print $2}'

For IPv6 version, try

dig -6 TXT +short | awk -F'"' '{ print $2}'
AWS EC2 or Lighsail find and note down your NAT IP address

Most cloud servers have two types of IP address

  • Public static IP address directly assigned to your box and routed from the Internet. For example, Linode, Digital Ocean, and others gives you direct public IP address.
  • Private static IP address directly attached to your server and your server is behind NAT with public IP address. For example, AWS EC2/Lightsail give you this kind of NAT public IP address.

The script will automatically detect your networking setup. All you have to do is provide correct IP address when asked for it.

Download and run script

wget -O
Download script to setup OpenVPN server in 5 minutes on CentOS

Setup permissions using the chmod command

chmod +x

One can view the script using a text editor such as vim/vi


Run to install OpenVPN server

Now all you have to do is

sudo ./

Sample session from AWS/Lightsail where my cloud server is behind NAT

CentOS 7.0 Set Up OpenVPN Server in 5 minutes

Sample session from Linode/DO server where cloud server has direct public IPv4 address

How To Setup OpenVPN Server In 5 Minutes on CentOS 7 Linux

To avoid problem always choose DNS as or Google DNS. Those are fast DNS server and reached from anywhere on the Internet.

VPN client config

At the end of the installation, you need to provide a client name. We can choose client names such as desktop for desktop VPN client or ios for Apple iPhone and so on. We can also encrypt the private key with a password for added security. So every time you start a VPN session, you need to provide a password for added security reasons

CentOS 7 OpenVPN password protect client or not on Linux

How do I start/stop/restart OpenVPN server on CentOS 7

sudo systemctl stop openvpn@server
sudo systemctl start openvpn@server
sudo systemctl restart openvpn@server
sudo systemctl status openvpn@server

Connect an OpenVPN server using IOS/Android/Linux/Windows client

On server your will find a client configuration file called ~/desktop.ovpn. All you have to do is copy this file to your local desktop using the scp command

scp vivek@ .


scp root@ .

Verify/test the connectivity

Execute the following commands after connecting to OpenVPN server from your Linux desktop

ping #Ping to the OpenVPN server gateway
ip route #Make sure routing setup working
dig TXT +short #Must return public IP address of OpenVPN server

How to add additional OpenVPN client on a CentOS 7

First, log in to your openvpn based CentOS 7 server using the ssh command

Run downloaded script again

sudo ./

A note about trouble shooting OpenVPN server and client issues

Check OpenVPN server for errors

journalctl --identifier openvpn

Is firewall rule setup correctly on your server? Use the cat command to see rules

sudo cat /etc/iptables/
iptables -t nat -I POSTROUTING 1 -s -o eth0 -j MASQUERADE
iptables -I INPUT 1 -i tun0 -j ACCEPT
iptables -I FORWARD 1 -i eth0 -o tun0 -j ACCEPT
iptables -I FORWARD 1 -i tun0 -o eth0 -j ACCEPT
iptables -I INPUT 1 -i eth0 -p udp --dport 1194 -j ACCEPT

Another option is to run iptables command and sysctl command commands to verify NAT rule setup on your server

sudo iptables -t nat -L -n -v
sysctl net.ipv4.ip_forward
NAT Firewall OpenVPN Rules Verification

Insert the rules if not inserted from/etc/iptables/

sudo sh /etc/iptables/
sudo sysctl -w net.ipv4.ip_forward=1

Is OpenVPN server running and port is open? Use the ss command or netstat command and pidof command/ps command

netstat -tulpn | grep :1194 ## 1194 is the openvpn server port ##
ss -tulpn | grep :1194 ## 1194 is the openvpn server port ##
ps aux | grep openvpn ## is the openvpn server running? ##
ps -C openvpn ## is the openvpn server running? ##
pidof openvpn ## find the openvpn server PID ##
Verify that OpenVPN server runnign and Port is Open on ubuntu Linux

If not running, restart the OpenVPN server

sudo systemctl restart openvpn@server

Look out for errors

sudo systemctl status openvpn@server



Install Deluge and WebUI to CentOS 7

To install Deluge torrent client and take advantage of the web-ui, the process is quite simple in comparison to rtorrent + rutorrent.

First install epel and the ‘nux’ desktop which will satisfy the dependencies and enable the ability to install deluge RPMs using yum.

yum install epel-release && rpm -iv \

Next, install the deluge-web

yum -y install deluge-web

Open port 8112 for TCP on the firewall:

firewall-cmd --permanent --zone=public --add-port=8112/tcp
firewall-cmd --reload

Install deluge-console

yum install deluge-console

Start the WebUI service:

systemctl start deluge-web

Navigate to http://%5Bip address]:8112

Deluge-WebUI will be active. The default password will be “deluge” — enter it and it will prompt you to change your password. Initially, you will not be connected to the deluge daemon from within the WebUI. Click on “Connection Manager” and there should be a* address to connect to and/or start/stop the daemon with a button. Click on that and it should fire up — you’re ready to start adding torrents!

From within the GUI you can enable SSL under preferences > interface.