How to set up OpenVPN with FreeRADIUS Authentication on CentOS 7 or Ubuntu 20

This guide assumes you already have OpenVPN installed.

In this guide, we will show you how to set up OpenVPN to authenticate off FreeRADIUS – this allows you to control access via an external billing system, for example, using WHMCS or Hostbill, which provides a FreeRADIUS module.

Ok, so on a clean install of Centos 7 or Ubuntu 20.x and a clean install of OpenVPN, we need to grab a couple of packages so we can install the Radius Plugin:

On CentOS we run:

yum install libgcrypt libgcrypt-devel gcc-c++ lsof psmisc -y

On Ubuntu we run:

apt-get install libgcrypt20 libgcrypt20-dev gcc make build-essential

Now we need to grab the Radius Plugin:


Decompress it:

tar xvfz radiusplugin_v2.1a_beta1.tar.gz

Move to its directory:

cd radiusplugin_v2.1a_beta1/

Compile it:


The output will be a single file.  Now move the file and the .cnf file to the OpenVPN directory using the below commands:

cp /etc/openvpn/
cp radiusplugin.cnf /etc/openvpn/

First thing, edit the radiusplugin.cnf file and focus on the server section and ensure that the details are correct:

        # The UDP port for radius accounting.
        # The UDP port for radius authentication.
        # The name or ip address of the radius server.
        # How many times should the plugin send the if there is no response?
        # How long should the plugin wait for a response?
        # The shared secret.
        sharedsecret=YOUR RADIUS SERVER SECRET

Now edit your OpenVPN config file and remove any other plugin lines, then add the following:

plugin /etc/openvpn/ /etc/openvpn/radiusplugin.cnf

Example OpenVPN server config:

port 1194
proto udp6
dev tun
user nobody
group nobody
keepalive 10 120
topology subnet
ifconfig-pool-persist ipp.txt
push "dhcp-option DNS"
push "dhcp-option DNS"
push "redirect-gateway def1 bypass-dhcp"
server-ipv6 fd41:19:19:19::/112
push tun-ipv6
push "route-ipv6 2000::/3"
push "redirect-gateway ipv6"
plugin /etc/openvpn/ /etc/openvpn/radiusplugin.cnf
dh none
ecdh-curve prime256v1
tls-crypt tls-crypt.key
crl-verify crl.pem
ca ca.crt
cert server_YYGbjpdCVDUTmgsp.crt
key server_YYGbjpdCVDUTmgsp.key
auth SHA256
cipher AES-128-GCM
ncp-ciphers AES-128-GCM
tls-version-min 1.2
client-config-dir /etc/openvpn/ccd
status /var/log/openvpn/status.log
verb 3

Now restart OpenVPN with either of the commands below:

killall -9 openvpn
service openvpn restart

Or use systemctl:

sudo systemctl stop [email protected] #<--- stop server
{null@centos7:~ }$ sudo systemctl start [email protected] #<--- start server
{null@centos7:~ }$ sudo systemctl restart [email protected] #<--- restart server
{null@centos7:~ }$ sudo systemctl status [email protected] #<--- get server status

Now try logging in using a username/password pair that exists in the FreeRADIUS database.

Leave a reply:

Your email address will not be published.

This site uses Akismet to reduce spam. Learn how your comment data is processed.