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 (7.2 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. Before we can install EPEL, we need to install wget so that we can download the repository:

yum install wget

Next we will need to install EPEL (Extra Packages for Enterprise Linux), as this contains the OpenVPN package.

yum install epel-release -y

Now that we have the extended packages we can go ahead and install OpenVPN. Type the following into the terminal:

yum install openvpn -y

We will need to use a text editor to modify various settings throughout this guide. We will use nano, although you are welcome to perform the steps in the guide with any other command line text editor of your choice. You can install nano with the following command:

yum install nano -y

Finally, we will install net-tools as this will give us access to ifconfig which we may need to examine the network setup:

yum install net-tools

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. 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. 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

DNS Server

If you are planning on encrypting all network traffic through your VPN server then it is recommended to enable your own 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.

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 [email protected]
systemctl start [email protected]

To check the server status, enter:

systemctl -l status [email protected]

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.

Router Setup

If your Red Hat server is directly accessible, then you can skip this section. There is no router to configure.

However if your Red Hat server is behind a router (such as on your home WiFi), then you will need to configure your router to permit VPN traffic. Due to the many different models of router and network configurations, we cannot provide a step by step guide on how to set up your router to allow VPN traffic. However there are a few settings you are likely to need to change, so we will outline them here.

As the the router will be directing all traffic to and from your OpenVPN server, you will need to set up port forwarding so that the OpenVPN server is externally accessible. Port forwarding may be under the section in your router management interface named 'Virtual Servers'. In general, you will want to forward any traffic incoming to the router on the OpenVPN port (1194). You will need to setup a rule to send any UDP traffic on these ports to the local IP address of your OpenVPN server (which is probably something in the range 192.168.0.x).

If you have set up port forwarding please also make a note of your external WAN IP address. This is the IP address assigned to your router by your Internet Service Provider (ISP). This address will be needed when configuring your connection in Viscosity below.

The other main router setting you will need to consider is static routing. Because you will have a VPN set up, there will be traffic sent to your router with a source or destination IP in the range 10.8.0.x. This traffic will need to have static routing in place to ensure that when a host recieves a request from the VPN client (on the 10.8.0.x subnet) and sends a response to that address, the router knows how to convert the 10.8.0.x IP address into an address it understands (i.e. 192.168.0.x). Thus you will need to setup a static routing rule that has the following properties:

Subnet mask:
Default gateway: your-server-IP

where your-server-IP is the IP address of your OpenVPN server on the local network (something in the range 192.168.0.x).

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 menu bar (Windows: system tray) and select 'Connect DemoConnection'. That's it, you should see a notification that you're now connected!

To check that the VPN is up and running, you can use the Viscosity details window. Click the Viscosity menu bar (Windows: system tray) icon and select 'Details...'. This will bring up the details window.

This window will show you the traffic passing through the VPN connection.

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!