In today’s increasingly remote work environment, the need for secure and efficient remote access to a company’s network has never been greater. One way to achieve this is by setting up your VPN (Virtual Private Network) server on a Windows operating system. In this article, we will walk you through the process of building a VPN server using OpenVPN, a widely used open-source VPN solution. This tutorial is perfect for you and your co-workers who often work remotely and need a secure connection to your organization’s network.
1: Installing Open VPN
To begin, you’ll need to install Open VPN on your Windows server. However, it’s essential to choose the manual installation option because the default installation might skip some necessary features. Two critical features you’ll want to include are the Open VPN service and OpenSSL.
2: Configuring the Open VPN Server in Windows
Once OpenVPN is installed, you’ll need to configure the server using the command line. Don’t worry; you’ll only need to use a few simple commands. Make sure to open a command prompt with administrative privileges.
First, navigate to the “easy-rsa” directory of OpenVPN, then run the “EasyRSA-Start.bat” file to initiate the configuration.
We start configuring openvpn with the initialization command
./easyrsa init-pki
Next you create the necessary files for the openvpn server.
./easyrsa build-ca nopass
Enter any common name like-netvn
3: Generating Certificate and Key Files
OpenVPN requires four essential files for the server: “ca.crt,” “server.crt,” “server.key,” and “dh.pem.” These files are used for encryption and authentication. Execute the necessary commands to generate these files.
./easyrsa build-server-full server nopass
Command creates a file dh.pem, which encrypts the data
./easyrsa gen-dh
4: Organizing Files
After generating the required files, copy and paste them into the “config” and “config auto” folders of the OpenVPN server. This step ensures that OpenVPN can locate and use these files.
Paste Here.
5: Creating the OpenVPN Configuration File
Using notepad with administrative rights, create a text file with the content provided earlier. Make sure that the list of file names in the configuration file matches the names of the files you created in the previous step. You can also set the IP address range for VPN connections; for example, “10.20.1.0” Save this file with the “.ovpn” extension in the “config auto” folder of OpenVPN.
Example: server
Please download sample server file and paste config-auto and modify according to your network.
For my network example: I set client-side assign ip is 10.20.1.0
My local ip is 192.168.50.0 range. And my openvpn server host ip is 192.168.50.5
6: Firewall Configuration
To allow OpenVPN to pass through the Windows firewall, you need to configure it to permit traffic on port 1194 using the UDP protocol. This is essential for the VPN to function correctly.
7: Port Forwarding and Static IP
To access your OpenVPN server from outside your network, you’ll need to forward port 1194 on your router to the server’s IP address. Ensure your server has a static IP address within your local network range.
Note: Change registry key and reboot windows. Serche (IPEnableRouter)
Navigate to Computer\HKEY_LOCAL_MACHINE\SYSTEM\CurrentControlSet\Services\Tcpip\Parameters Change IPEnableRouter value from0
to1
8: Setting Up OpenVPN Clients
./easyrsa build-client-full client01 nopass
You’ll need to create files for OpenVPN clients, including “ca.crt,” “client.crt,” and “client.key.” Send these files to the clients using your preferred method, such as email.
9: Configuring OpenVPN Clients
You go to the openvpn homepage and download the same file as the server
But when installing you just need to choose the default setting
You copy and paste these 3 files into the config folder of openvpn
Ensure they enter the correct domain name or IP address in the configuration file, depending on your setup.
Download sample client file and paste in config folder, If you use static public ip address then replace it there.
10: Testing the Connection
Finally, test the connection to ensure that the OpenVPN server is working correctly. If you have multiple clients, repeat the steps to create files for each client and configure them accordingly.
By following these steps, you can successfully set up a VPN server on a Windows operating system, providing a secure and reliable remote access solution for you and your co-workers. This will enable seamless and protected remote work, regardless of your physical location. If you are facing issue please restart VPN Server.