Openvpn Server and Client Setup On Windows

Download as docx, pdf, or txt
Download as docx, pdf, or txt
You are on page 1of 4

OpenVPN Server and Client Setup on

Windows
Posted on

14/01/2014 by Tomas

Setting up an OpenVPN server on a Windows Server 2008 VM hosted on AWS.

Install OpenVPN
Download the package from the official website here (OpenVPN 2.3.2) and install OpenVPN server on a Windows machine. Make sure you install OpenSSL
utilities and OpenVPN RSA certificate management scripts.
[EDIT: July 2014] Note that easy-rsa was included with 2.3.2, but is no longer bundled with OpenVPN source code archives (according to the OpenVPN
downloads page). To get it, visit the easy-rsa page on GitHub.
We will completely disable Windows Firewall on the server, as our VM is running on AWS. Well open UDP 11194 port on Amazon Firewall instead.

Optional: Rename TAP-Windows Adapter V9


Find which network interface is not connected to the Internet and has the device name listed as TAP-Windows Adapter V9. Rename the TAP adapter to
tap-vpn for the sake of clarification.

Generate the Master Certificate Authority


(CA) Certificate and Key
Open up a Command Prompt windows as Administrator and change directory to C:\Program Files\OpenVPN\easy-rsa:

C:\Users\Administrator>cd\ProgramFiles\OpenVPN\easyrsa
Run the following batch file to copy configuration files into place:

>initconfig
Now edit the vars file (its called vars.bat on Windows):

>notepadvars.bat
And set the parameters below appropriately:

KEY_COUNTRY=GB
KEY_PROVINCE=Midlands
KEY_CITY=Birmingham
KEY_ORG=Private
KEY_EMAIL=webmaster@example.com
KEY_CN=changeme
KEY_NAME=changeme
KEY_OU=IT
Dont leave any of these parameters blank. Next thing to do is to initialise the PKI:

>vars

>cleanall
>buildca

Generate a Certificate and a Private Key for the Server


>buildkeyserverserver

Generate a Certificate and a Private Key for the Client


Generating client certificates is very similar to the previous step. Make sure the Common Name value matches the servers value and the Name value is
specified. We can leave all other settings default.

>vars
>buildkeyclient

Generate a Diffie Hellman Parameter for the OpenVPN


Server
>builddh

Creating Configuration Files for a Server and


Clients
Copy template file C:\Program Files\OpenVPN\sample-config\server.ovpn to C:\Program Files\OpenVPN\config:
> copy ..\sample-config\server.ovpn ..\config

1file(s)copied.

Modify Configuration File For Server


Open the configuration file server.ovpn for editing:

>notepad..\config\server.ovpn
Make it look as below:
#listen on IPv4

local0.0.0.0
#we use a non-default port

port11194
#UDP protocol chosen for better protection against DoS attacks and port scanning

protoudp
#using routed IP tunnel

devtun
#relative paths to keys and certificates

ca..//easyrsa//keys//ca.crt
cert..//easyrsa//keys//server.crt
key..//easyrsa//keys//server.key
dh..//easyrsa//keys//dh1024.pem
#set OpenVPN subnet

server10.26.0.0255.255.255.0
#maintain a record of client-to-virtual-IP-address

ifconfigpoolpersistipp.txt
#ping every 10 seconds, assume that remote peer is down if no ping received during 60

keepalive1060
#cryptographic cipher, must be the same (copied) on the client config file as well

cipherAES256CBC
#enable compression on VPN link

complzo
maxclients20
#try to preserve some state across restarts

persistkey
persisttun
#log file

status..//log//openvpnstatus.log
#log file verbosity

verb3
We do not need to change anything else on the server.ovpn config. All should work just fine.

Start OpenVPN Server


Run from a command prompt window:

>openvpn..\config\server.ovpn
Once running in a command prompt window, OpenVPN can be stopped by the F4 key.
Service also can be controlled from Start Menu -> Administrative Tools -> Services.
To ensure that the OpenVPN server is running do:
> netstat -na | findstr /L 11194

UDP0.0.0.0:11194*.*

Setup OpenVPN Client


Download here and install an OpenVPN client on a Windows PC.
We need to copy the template file C:\Program Files\OpenVPN\sample-config\client.ovpn from the server to our local PC folder C:\Program Files\OpenVPN.
Also copy ca.crt, client.crt and client.key from C:\Program Files\OpenVPN\easy-rsa\keys to our local PC folderC:\Program Files\OpenVPN\config.

Modify Client Configuration File


Open the configuration file client.ovpn for editing and make it look as below:
client
dev tun
proto udp
remote openvpn.example.com 11194
resolv-retry infinite
nobind
persist-key
persist-tun
ca ca.crt
cert client.crt
key client.key
ns-cert-type server
cipher AES-256-CBC

comp-lzo
verb 3

Connect to OpenVPN server


Launch OpenVNP client, click Connection Profiles -> Local File and find client.ovpn, save the file. Click connect.
Alternatively run from a command prompt window:

>cd\ProgramFiles\OpenVPN\config
>openvpn.\client.ovpn
Jobs done. We should now be able to RDP to the server by using its private IP 10.26.0.X.

You might also like

pFad - Phonifier reborn

Pfad - The Proxy pFad of © 2024 Garber Painting. All rights reserved.

Note: This service is not intended for secure transactions such as banking, social media, email, or purchasing. Use at your own risk. We assume no liability whatsoever for broken pages.


Alternative Proxies:

Alternative Proxy

pFad Proxy

pFad v3 Proxy

pFad v4 Proxy