OpenVPN server on Windows
Introduction[edit | edit source]
OpenVPN is an open-source software application that implements virtual private network (VPN) techniques for creating secure point-to-point or site-to-site connections in routed or bridged configurations and remote access facilities.
This article contains step-by-step instructions on how to create and run an OpenVPN server on a PC that runs on Windows OS. The information provided here is geared towards users of almost any knowledge level. The instructions apply to Windows 7 and newer systems.
Configuration overview and prerequisites[edit | edit source]
Before we begin, let's overview the configuration that we are attempting to achieve and the prerequisites that make it possible.
- A PC or Laptop running on Windows 7 or a later version
- The computer in question must have a Public IP address
- And an active Internet connection
The purpose of this article is to provide the know-how needed to configure a working OpenVPN server on a Windows PC.
Step 1: installing OpenVPN software[edit | edit source]
- The first thing that we'll need to do is install the necessary OpenVPN software. You can download the OpenVPN installer file from here.
Simply run the downloaded file and follow the instructions of the installation guide.
- Important note: at one point before the installation begins, you will be prompted to select which components should be included in the installation. Make sure to select EasyRSA as it will be needed later on to generate keys and certificates. You can leave the rest as defaults:
Step 2: preparing EasyRSA[edit | edit source]
- Now we can start preparing to generate certificates and keys. For this we'll be using the EasyRSA application that was installed along with OpenVPN.
EasyRSA commands have to be executed via the Windows Command Prompt. It can be opened by typing cmd in the Windows search bar (Windows button + S). When you launch it, make sure you run it as administrator:
- Change the current directory to the EasyRSA folder. To do so, execute this command:
cd "C:\Program Files\OpenVPN\easy-rsa"
set KEY_COUNTRY=US set KEY_PROVINCE=CA set KEY_CITY=SanFrancisco set KEY_ORG=OpenVPN set KEY_EMAILfirstname.lastname@example.org
Step 3: generating certificates and keys[edit | edit source]
- Now we can start generating the certificates and keys. Begin with the certificate authority (CA) - the root certificate file that will be used to sign other certificates and keys:
NOTE: you can press the "Enter" key when prompted to enter the values set in the vars.bat file earlier. Doing this will set the values to the default specified in vars.bat. However, you should type in a meaningful Common Name.
NOTE: once again, don't forget to specify a different Common Name (use the name "server" for easier management purposes). When prompted the sign and commit the certificate, type y and press "Enter".
TIP: use the same Common Name as the certificate name (Client1 in this example). This will help you differentiate between clients easier. Pick meaningful names like "toms_PC", "company_maintenance", etc. Repeat this step as many times as you need, depending on the client quantity.
Step 4: OpenVPN server configuration[edit | edit source]
In this section we'l be discussing how to configure an OpenVPN Tunnel (TUN) server that uses:
- The UDP protocol
- TLS authentication
As a template, we'll be using the sample configuration file that comes along with the OpenVPN installation, but we'll be adding with some minor changes to it. You can find it in the OpenVPN installation directory, sample-config folder (default: C:\Program Files\OpenVPN\sample-config) under the name server.ovpn.
- When you locate the file, make a copy, rename it and place it in the config directory of the OpenVPN folder (default path: C:\Program Files\OpenVPN\config). You should also copy the certificates and keys to this directory (required files: ca.crt, server.crt, server.key, dh2048.pem).
- Open the config file with a text editor. You can use the Notepad, but for editing configuration files we recommend using Notepad++ for a better experience (you can download it from here).
- Locate the following lines:
ca ca.crt cert server.crt key server.key dh dh1024.pem
ca "C:\\Program Files\\OpenVPN\\config\\ca.crt" cert "C:\\Program Files\\OpenVPN\\config\\server.crt" key "C:\\Program Files\\OpenVPN\\config\\server.key" dh "C:\\Program Files\\OpenVPN\\config\\dh2048.pem"
NOTE: Diffie Hellman parameters file name will depend on the key size that you specified in the vars.bat file. Don't forget to change it accordingly.
The following changes were made to the sample file:
- Changed udp to udp4 to indicate that the connection should use only IPv4
- Added client-config-dir option for possible TLS client configuration
- Changed the ifconfig-pool-persist file path
- Changes to the certificate and key file paths
Step 5: configuring clients[edit | edit source]
We've already generated certificates and keys for the clients in this guide. The next step is to create a configuration file for the clients. For this purpose we have a separate article: OpenVPN client on Windows.
Since you already have the OpenVPN software installed and have generated the certificates and keys for the clients, you can skip to section 4 of that article by clicking here.
Step 6: launching the server[edit | edit source]
If you've followed all the steps until now, your OpenVPN server configuration is complete! The next thing to do is to simply launch the server.
- Run the OpenVPN GUI application as administrator in order for the application to be able to fill log files.
- Locate OpenVPN GUI in the Windows system tray. Right click it and click Connect:
See also[edit | edit source]
[edit | edit source]
- OpenVPN downloads: https://openvpn.net/index.php/open-source/downloads.html
- OpenVPN manual: https://openvpn.net/index.php/open-source/documentation/manuals.html
- Notepad++ downloads: https://notepad-plus-plus.org/download/v7.5.8.html