• Contact
  • Contact Us
  • Disclamer
  • Home 1
  • Home 2
  • Home 3
  • Privacy Policy
Friday, May 9, 2025
How VPS - How to use/setup VPS
  • Login
  • Home
  • Management guides
    • Web servers software
      • Directadmin
      • Hocvps Script
      • Centmin Mod
      • CWP
      • Kloxo-MR
      • Plesk
    • Control Panels
    • Securing VPS/Servers
      • SSL Certificates
      • Upgrading
      • Authentication
  • Operating System
    • CentOS
    • Fedora
    • Debian
    • Linux
    • Arch
    • BSD
    • CoreOS
  • Reviews
  • Coupon
    • Domain Coupon
    • Hosting Coupon
No Result
View All Result
  • Home
  • Management guides
    • Web servers software
      • Directadmin
      • Hocvps Script
      • Centmin Mod
      • CWP
      • Kloxo-MR
      • Plesk
    • Control Panels
    • Securing VPS/Servers
      • SSL Certificates
      • Upgrading
      • Authentication
  • Operating System
    • CentOS
    • Fedora
    • Debian
    • Linux
    • Arch
    • BSD
    • CoreOS
  • Reviews
  • Coupon
    • Domain Coupon
    • Hosting Coupon
No Result
View All Result
How VPS - How to use/setup VPS
No Result
View All Result
Home Operating System Linux

How to Create an OpenVPN Server on Ubuntu 16.04

How VPS by How VPS
January 1, 2020
in Linux
0
0
SHARES
42
VIEWS
Share on FacebookShare on Twitter

Contents

  1. Introduction
  2. Install
  3. Certificate Authority
    1. Setup
    2. Configure
    3. Build
    4. Server-Key
    5. Strong Key
    6. HMAC
    7. Generate a Client Key
  4. Configure the Server
  5. Edit the Config
  6. Allow Forwarding
  7. NAT
  8. Start
  9. Conclusion
  10. Want to contribute?


Introduction

OpenVPN is a secure VPN which uses SSL ( Secure Socket Layer ) and offers a broad range of features. In this guide we’ll be covering the process of installing OpenVPN on Ubuntu 16 utilizing the easy-rsa hosted certificate authority.

Install

In order to get started, we need some packages installed:

sudo su
apt-get update
apt-get install openvpn easy-rsa

Certificate Authority

OpenVPN is a SSL VPN, which means that it acts as Certificate Authority in order to encrypt the traffic between both parties.

Setup

We can start with setting up our OpenVPN server’s Certificate Authority by running the following command:

make-cadir ~/ovpn-ca

We can now switch into our fresh created directory:

cd ~/ovpn-ca

Configure

Open the file with the name vars and take a look at the following parameters:

export KEY_COUNTRY="US"
export KEY_PROVINCE="NJ"
export KEY_CITY="Matawan"
export KEY_ORG="Your Awesome Organization"
export KEY_EMAIL="me@your_awesome_org.com"
export KEY_OU="YourOrganizationUnit"

And edit them with your own values. We also need to look for and edit the following line:

export KEY_NAME="server"

Build

We can now start building our Certificate Authority by running the following command:

./clean-all
./build-ca

These commands might take a few minutes to complete.

Server-Key

Now, we can start building our server’s key by running the following command:

./build-key-server server

While the server field should be replaced with KEY_NAME we set in the vars file earlier. In our case, we can keep server.

The build process of our server’s key might ask a few questions, like the expiration of itself. We answer all these questions with y.

Strong Key

In the next step, we create a strong Diffie-Hellman key which will be used during the exchange of our keys. Type in the following command to create one:

./build-dh

HMAC

We can now create a HMAC signature to strengthen the server’s TLS integrity verification:

openvpn --genkey --secret keys/ta.key

Generate a Client Key

./build-key client

Configure the Server

Once we’ve successfully created our own Certificate Authority, we can start with copying all needed files and configuring OpenVPN itself. Now, we’re going to copy the generated keys and certificates to our OpenVPN directory:

cd keys
cp ca.crt ca.key server.crt server.key ta.key dh2048.pem /etc/openvpn
cd ..

Afterwards, we can copy an example OpenVPN config file to our OpenVPN directory by running the following command:

gunzip -c /usr/share/doc/openvpn/examples/sample-config-files/server.conf.gz | tee /etc/openvpn/server.conf

Edit the Config

We can now start editing our config to fit our needs. Open the file /etc/openvpn/server.conf and uncomment the following lines:

push "redirect-gateway def1 bypass-dhcp"
user nobody
group nogroup
push "dhcp-option DNS 208.67.222.222"
push "dhcp-option DNS 208.67.220.220"
tls-auth ta.key 0

We also need to add a new line to our config. Place the following line under the tls-auth line:

key-direction 0

Allow Forwarding

Because we want to allow our clients to access the Internet through our server, we open the following file /etc/sysctl.conf and uncomment this line:

net.ipv4.ip_forward=1

Now we have to apply the changes:

sysctl -p

NAT

In order to provide Internet Access to our VPN clients, we also have to create a NAT rule. This rule is a short one-liner which looks like this:

iptables -t nat -A POSTROUTING -s 10.8.0.0/16 -o eth0 -j MASQUERADE

Start

We can now start our OpenVPN server and let clients connect by typing in the following key:

service openvpn start

Conclusion

This concludes our tutorial. Enjoy your new OpenVPN Server!

Want to contribute?

You could earn up to $300 by adding new articles

Submit your article
Suggest an update
Request an article
Previous Post

Recovering Data via SFTP

Next Post

Installing Let’s Encrypt on DirectAdmin

Next Post

Installing Let's Encrypt on DirectAdmin

Leave a Reply Cancel reply

Your email address will not be published. Required fields are marked *

No Result
View All Result

Recent Post

Install Imagemagick on CentOS
CentOS

Install Imagemagick on CentOS

by How VPS
June 28, 2023
0

This is how I installed Imagemagick on a vanilla CentOS server Start off by installing the prerequisites yum install php-pear...

Read more
how to Check phpinfo

How to Check phpinfo of Hosting or VPS?

June 28, 2023
Failed to download metadata for repo 'appstream' on Centos 8

How to fix error: Failed to download metadata for repo ‘appstream’ on Centos 8

February 25, 2022
How to Fix MySQL Error "Plugin 'InnoDB' registration as a STORAGE ENGINE failed"?

How to Fix MySQL Error “Plugin ‘InnoDB’ registration as a STORAGE ENGINE failed”?

November 17, 2020
How to optimize Mysql or MariaDB

How to optimize Mysql or MariaDB

November 3, 2020

Recent News

  • Install Imagemagick on CentOS
  • How to Check phpinfo of Hosting or VPS?
  • How to fix error: Failed to download metadata for repo ‘appstream’ on Centos 8

Category

  • Arch
  • Authentication
  • Backups
  • BSD
  • Centmin Mod
  • CentOS
  • Control Panels
  • CoreOS
  • CWP
  • Debian
  • Directadmin
  • Encryption
  • Fedora
  • Firewalls
  • Hocvps Script
  • Hosting providers
  • Kloxo-MR
  • Linux
  • Mitigations
  • Operating System
  • Plesk
  • Reviews
  • Securing VPS/Servers
  • Security Patches
  • SSL Certificates
  • Uncategorized
  • Upgrading
  • VPS/Servers management guides
  • Vulnerability Detection
  • Web servers software
  • Webhosting Control Panel
  • About
  • Advertise
  • Careers
  • Contact

© 2025 JNews - Premium WordPress news & magazine theme by Jegtheme.

No Result
View All Result
  • Home
  • Management guides
    • Web servers software
      • Directadmin
      • Hocvps Script
      • Centmin Mod
      • CWP
      • Kloxo-MR
      • Plesk
    • Control Panels
    • Securing VPS/Servers
      • SSL Certificates
      • Upgrading
      • Authentication
  • Operating System
    • CentOS
    • Fedora
    • Debian
    • Linux
    • Arch
    • BSD
    • CoreOS
  • Reviews
  • Coupon
    • Domain Coupon
    • Hosting Coupon

© 2025 JNews - Premium WordPress news & magazine theme by Jegtheme.

Welcome Back!

Login to your account below

Forgotten Password?

Retrieve your password

Please enter your username or email address to reset your password.

Log In
Thabet