Here, I'll explain in detail how to set up an OpenVPN server on Microsoft Windows.
OpenVPN is a very powerful VPN whith several advantages: it's free, compatible with a very large number of operating systems, easy to set up (especially when you have this excellent tutorial at hand) and highly configurable.
In order to create the connection certificates, we need to install OpenSSL library. I personaly use the slproweb.com packages.
Download the latest version of OpenSSL Light.
We'll add OpenSSL to the environment variables.
Go to the official OpenVPN website: https://openvpn.net/ to download the lastest installer.
Here we're going to set up a pki to create our server and client certificates.
C:\Windows\system32>cd C:\Program Files\OpenVPN\easy-rsa
C:\Program Files\OpenVPN\easy-rsa>EasyRSA-Start.bat
# ./easyrsa clean-all
# ./easyrsa init-pki
# ./easyrsa build-ca nopass
[…]
Enter PEM pass phrase:PEMpa$$td
Verifying - Enter PEM pass phrase:PEMpa$$td
[…]
Common Name (eg: your user, host, or server name) [Easy-RSA CA]:ovpn
# ./easyrsa build-server-full server nopass
[…]
Enter pass phrase for C:/Program Files/OpenVPN/easy-rsa/pki/private/ca.key:PEMpa$$td
# ./easyrsa gen-dh
C:\Users\Administrator>cd C:\Program Files\OpenVPN\easy-rsa
C:\Program Files\OpenVPN\easy-rsa>EasyRSA-Start.bat
# ./easyrsa build-client-full client01 nopass
[…]
Enter pass phrase for C:/Program Files/OpenVPN/easy-rsa/pki/private/ca.key:PEMpa$$td
To do this, use the Windows Firewall Management Console or these two commands in an administrator's PowerShell console.
PS C:\ > New-NetFirewallRule -DisplayName "OpenVPN" -Direction Inbound -Protocol UDP -LocalPort 1194 -Action Allow
PS C:\ > New-NetFirewallRule -DisplayName "OpenVPN_Network" -Direction Inbound -RemoteAddress 10.50.8.0/24 -Action Allow
As administrator, create the file C:\Program Files\OpenVPN\config-auto\server.ovpn:
port 1194
proto udp
dev tun
ca ca.crt
cert server.crt
key server.key
dh dh.pem
server 10.50.8.0 255.255.255.0
ifconfig-pool-persist ipp.txt
keepalive 10 120
comp-lzo
persist-key
persist-tun
status openvpn-status.log
verb 3
Then, restart the OpenVPN service:
C:\Windows\system32>net stop openvpnservice
C:\Windows\system32>net start openvpnservice
C:\ PS> Restart-Service OpenVPNService
We're going to download the same package as for the server, and install it with the default settings.
client
dev tun
proto udp
remote OPENVPN_IP 1194
resolv-retry infinite
nobind
persist-key
persist-tun
ca ca.crt
cert client01.crt
key client01.key
comp-lzo
verb 3
To reach the server, we'll use the IP address 10.50.8.1.
⚠️ Troubleshooting: After a Windows Update, I no longer had access to the server share (OpenVPN could connect, however). For this to work again, I had to repair (available by re-running the installer) the OpenVPN program on the server.
Contact :