App Support.

We're here to help.

Setting up an OpenVPN server with Red Hat Linux and Viscosity

Virtual Private Networks (VPNs) can be utilized for a number of very useful applications. You can securely connect to any public WiFi hotspot. You can overcome geo-blocking restrictions on your favourite websites. And you can even connect to your home or office network from anywhere in the world, as if you were sitting right at your desk. This guide will walk you through the process of setting up your own OpenVPN server, and connecting to it with your copy of Viscosity.

Running your own OpenVPN server will allow you to encrypt everything you do on the internet, so that you can safely do your online banking on the free WiFi at your favourite cafe. Anything you send over the VPN connection will be encrypted from your device until it reaches your OpenVPN server at home. Setting up your OpenVPN server to access your home or office network gives you full access to all your files on your network.

This guide will walk you through the steps involved in setting up an OpenVPN server on a Red Hat Linux host that allows you to securely access your home/office network from a remote location and optionally send all of your network traffic through it so you can access the internet securely as well.


For this guide, we assume:

  • You have already installed the latest version of Red Hat Enterprise Linux (8.4 at time of writing)
  • You have root access to this installation
  • Know the name of your network interfaces (instructions just below)
  • This installation of Red Hat is a fresh install
  • You already have a copy of Viscosity installed on your client device

If you need to download and install a copy of Red Hat, an evaluation copy can be found at We won't be covering the details of setting up a Red Hat instance, many guides can be found online. If you are running a different version of Red Hat, it's very likely that many or even all of the steps outlined in this guide will still apply. If you are looking to setup an OpenVPN server on a different operating system, please check out our other guides.

If you don't have a copy of Viscosity already installed on your client, then please check out this setup guide for installing Viscosity (Mac | Windows).

To get the name of your Primary Network Interface (WAN Access), run the following on your RHEL Server:
ip route | grep default | awk 'NR==1 {print $(NF-4)}'

If you have a second network interface for accessing machines on your local network, you will need the name of this as well when setting up the firewall and routing.


Unfortunately we cannot provide any direct support for setting up your own OpenVPN server. We provide this guide as a courtesy to help you get started with, and make the most of, your copy of Viscosity. We've thoroughly tested the steps in this guide to ensure that, if you follow the instructions detailed below, you should be well on your way to enjoying the benefits of running your own OpenVPN server.

For further information or help with RHEL, support is offered at

Countless RHEL communities and forums are also easily searchable across the Internet.

Accessing the Command Line Interface

The steps outlined in this guide are performed via the command line interface (i.e. terminal) on your RHEL server. If you are running this server remotely, you will need to use the SSH application to connect securely between your client device and the server (to "SSH into" your server). If you are setting up your OpenVPN server on a virtual private server (VPS), you may only be familiar with the web interface. Many VPS suppliers provide SSH access in addition to the web interface. Please consult your VPS provider for details.

If you're new to SSH, we have some instructions in our Introduction Guide.

Getting Started

Once logged in to root, we need to ensure that Red Hat's repository is up to date by typing the following:

yum update

This will run through and update the preinstalled packages. If any updates are found, you will be asked if you want to continue. Confirm that you do by entering y. You may be informed that you need to restart after the package upgrades complete. If so, make sure to log back in to the terminal as root after restarting.

Next we will need to install EPEL (Extra Packages for Enterprise Linux), as this contains the OpenVPN package. For RHEL 8 run the following:

yum install
ARCH=$( /bin/arch )
subscription-manager repos --enable "codeready-builder-for-rhel-8-${ARCH}-rpms"

For other RHEL releases, please follow the EPEL instructions here .

Next install OpenVPN:

yum install openvpn -y

Generating Configurations, Certificates and Keys

The next step is to generate your configurations for the server and your clients as well as certificates to go with them. You can do this easily by following the Creating Certificates and Keys Guide. You can either follow the section for Linux using the RHEL RPM installer and copy your client configurations off the server (we recommend this), or generate everything on your PC or Mac and copy the server folder that is generated onto your RHEL server.

If you use the default DNS Server (, you will need to setup a DNS server yourself, instructions are at the end of this article. We recommend instead using an existing DNS server, a publically available DNS server like Google's ( and is the easiest.

Once you have generated your Configurations, you will need to transfer the server configuration to your server, or transfer your client configurations off your server. If you have local access, a USB drive is the easiest. If not, we have some help on how to transfer files with SCP in our Introduction Guide.

IP Forwarding

In order to forward our requests passing through the VPN, we want the OpenVPN server to act like a router. As such, we need to enable IP forwarding.

  1. In the terminal, we can enable IP forwarding on the Red Hat server by entering:
    echo 1 > /proc/sys/net/ipv4/ip_forward
  2. To ensure that hosts on the home/office network can find the VPN server, we need to make the server respond to any ARP requests:
    echo 1 > /proc/sys/net/ipv4/conf/ens33/proxy_arp
    where ens33 is the network interface of the home/office network if you have two network interfaces, or your
  3. Every time we reboot the server, these commands will be undone. To ensure that doesn't happen, we need to modify the sysctl.conf file:
    nano /etc/sysctl.conf
  4. Add the following lines to the bottom of this file:
    net.ipv4.ip_forward = 1
    net.ipv4.conf.ens33.proxy_arp = 1
  5. Press ctrl + x to exit nano. Save the changes when prompted.
  6. To enable the changes made to the sysctl.conf file, type:
    sysctl -p /etc/sysctl.conf

Firewall Rules

We will use the firewalld firewall installed by default on Red Hat. If you are installing OpenVPN on a server that already has its own firewall setup, make sure to add the rules to allow our OpenVPN traffic. However, if this is just a simple standalone Red Hat server, the firewall settings below should be enough to get your OpenVPN server up and running.

  1. Allow the openvpn service:
    firewall-cmd --permanent --add-service=openvpn
    firewall-cmd --add-service=openvpn
  2. Set the OpenVPN server to provide masquerade:
    firewall-cmd --permanent --add-masquerade
    firewall-cmd --add-masquerade
  3. Allow the OpenVPN port (1194):
    firewall-cmd --permanent --add-port=1194/udp
  4. Allow the DNS port (53):
    firewall-cmd --permanent --add-port=53/udp
  5. Restart the firewall with these new settings:
    firewall-cmd --reload

Starting the OpenVPN Server

At this point the basics are complete. Your server configuration and files should be on your server copied from where you generated them.

First, copy the server configuration files to the OpenVPN directory:

sudo cp /path/to/configs/server/* /etc/openvpn/

Now start your server, and enable it to start after a reboot as well.

systemctl -f enable openvpn@server
systemctl start openvpn@server

To check the server status, enter:

systemctl -l status openvpn@server

To which it should reply with the status and in green you should see:

Active: active (running)

Your OpenVPN server is now up and running and ready for you to connect to it.

Setting Up Viscosity

The final step is to setup Viscosity. Thanks to openvpn-generate, this is as easy as importing and connecting.


Copy your *.visz file you created with openvpn-generate to your Mac or Windows machine with Viscosity installed and double click the file. You should see a prompt that the config was imported successfully.

Connecting and Using Your VPN Connection

You are now ready to connect. Click on the Viscosity icon in the macOS menu bar or Windows system tray to open the Viscosity Menu, select the connection you imported, and Viscosity will connect.

To check that the VPN is up and running, you can open the Details window from the Viscosity Menu. This will allow you to view connection details, traffic and the OpenVPN log.


That's it, you've set up your very own OpenVPN server. Congratulations, you are now free to enjoy the benefits of operating your own OpenVPN server!

Basic DNS Server

If you are electing to run your own DNS server for clients, the following is an example setup for a bind DNS server.

  1. To install the DNS server, type:
    yum install bind bind-utils bind-libs bind-chroot
  2. To set up the forwarding rules for our DNS server, we will modify the configuration file:
    nano /etc/named.conf
  3. At the top you will see a braced collection of instructions labelled options. Insert the following two lines at the bottom of the list of options:
    forwarders {;;}; #IP of upstream nameservers
    forward only; #rely completely on our upstream nameservers
    where we are using the Google DNS servers (you are free to use your DNS resolution service of choice).
  4. Add the VPN subnet ( to the listen-on and allow-query parameters at the top of the options so that they now look like:
    listen-on port 53 {;; };
    allow-query {;localhost; };
  5. Press ctrl + x to exit nano. Save the changes when prompted.
  6. Set the conf file permissions to 644:
    chmod 644 /etc/named.conf

As this conf file is sensitive to errors, we can check it by typing:

named-checkconf /etc/named.conf

If your configuration file contains no errors, this command will return nothing.

  1. Open the list of nameservers:
    nano /etc/resolv.conf
  2. Set the server resolver to point to itself:
  3. Press ctrl + x to exit nano. Save the changes when prompted.
  4. If your Red Hat server is run on a router with a DHCP service, you need to ensure that the resolv.conf file does not get overwritten on DHCP lease renewal. Type:
    nano /etc/sysconfig/network-scripts/ifcfg-ens32
    Replace ens33 with the name of your Primary Network Interface if it is different (See Preparation section for more information)
  5. Ensure that the following three parameters are set:
  6. Press ctrl + x to exit nano. Save the changes when prompted.
  7. To start the DNS server, type:
    systemctl start named
  8. Enable DNS server auto start on system boot:
    systemctl enable named

That's it, the DNS server is now set up.