Here we'll look at how to set up an OpenVPN server on Microsoft Windows Server.
This is a continuation of the previous "How To" I wrote, see here, but with Windows 2019 (which doesn't change much). However, I'd also mention the possibility of enabling routing to be able to access LAN machines from our remote clients.
OpenVPN is a very powerful VPN with several advantages: it's free, compatible with most operating systems, easy to implement and highly configurable.
In order to create connection certificates, we need to install the OpenSSL software library. I personally use the https://slproweb.com packages.
Download the latest OpenSSL Light version.
We need to add the OpenSSL path to the environment variables.
We need to open port 1194 udp to allow OpenVPN client connections.
C:\Windows\system32>netsh advfirewall firewall add rule name="OpenVPN" dir=in localport=1194 remoteport=0-65535 protocol=UDP action=allow remoteip=any localip=any
PS C:\ > New-NetFirewallRule -DisplayName "OpenVPN" -Direction Inbound -Protocol UDP -LocalPort 1194 -Action Allow
Go to the official OpenVPN website here: https://openvpn.net and download the latest 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:MyPassW0rd
Verifying - Enter PEM pass phrase:MyPassW0rd
[…]
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:MyPassW0rd
# ./easyrsa gen-dh
# ./easyrsa build-client-full client01 nopass
[…]
Enter pass phrase for c:\Program Files\OpenVPN\easy-rsa\pki\private\ca.key:MyPassW0rd
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
The OpenVPN service must be restarted for the configuration file to take effect.
C:\Windows\system32>net stop openvpnservice
C:\Windows\system32>net start openvpnservice
PS C:> Restart-Service OpenVPNService -PassThru
We're going to download the same package, and here 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 access 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 relaunching the installer) the OpenVPN program on the server side.
At this stage, we have an operational OpenVPN server that is reachable from our remote client. But do we reach the server on its private ip (192.168.0.254) or other computers on the local network? That's what we're going to find out here, by enabling routing on our OpenVPN Windows server.
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
push "route 192.168.0.0 255.255.255.0"
push "dhcp-option DNS 192.168.0.200"
keepalive 10 120
#comp-lzo
persist-key
persist-tun
status openvpn-status.log
verb 3
PS C:> Restart-Service OpenVPNService -PassThru
PS C:> Install-WindowsFeature -Name Routing -IncludeManagementTools
Contact :