How to create an OpenVPN Server in Proxmox.
In this tutorial, I’m going to walk you through the process of how to create OpenVPN server in Proxmox. OpenVPN, which is undeniably popular and completely open-source, provides an excellent way to fortify your internet connection as well as ensure your online activities stay private.
I’ll be making use of the Proxmox Virtual Environment (PVE) to create the container and then, we’ll move on to installing and configuring OpenVPN inside it. This not only beefs up security but also offers a shield for your online privacy. So, without further ado, let’s go!
Prerequisites:
– Specifically, you’ll need a Proxmox Virtual Environment (PVE) setup. If you don’t have one yet go check out my other blog post detailing how to install Proxmox it’s certainly helpful
– Basic knowledge of Proxmox and Linux command-line.
Step 1: Create an LXC Container
1. Firstly log in to your Proxmox environment.
2. Click “Create” to initiate the container creation process.
3. Enter a hostname and set a secure password for the container.
4. Click “Next.”
5. In the “Template” dropdown, select “debian-11-turnkey-openvpn-17.1-1.”
6. Additionally, If you don’t see the template in the dropdown, download it by navigating to “CT templates” under your node and wait for the task to complete.
7. Once the template is available, select it from the dropdown.
8. Click “Next.”
9. You can adjust the disk size if needed.
10. Click “Next.”
11. It’s recommended to allocate at least 2 CPU cores to the VPN container. Set your desired memory allocation.
12. For the network settings, set it to “dhcp.”
13. For DNS, input your preferred DNS servers , otherwise select “use host settings.”
14. Click “Finish,” but do not start the container immediately.
Step 2: Edit the LXC Configuration
1. To configure the container, access the Proxmox main console.
2. In the console, open a terminal and execute the following commands, replacing “420” with your container number:
# pct config 420
# nano /etc/pve/lxc/420.conf
3. At the end of the configuration file, add the following two lines:
lxc.cgroup2.devices.allow: c 10:200 rwm
lxc.mount.entry: /dev/net dev/net none bind,create=dir
4. Save the file by pressing `Ctrl+X`, then `Y`.
5. Set the owner for `/dev/net/tun` by running:
# chown 100000:100000 /dev/net/tun
6. Furthermore you can verify the ownership by entering:
# ls -l /dev/net/tun
It should display `crw-rw-rw` permissions.
7. Start the container and enter it by executing:
# pct start 420
# pct enter 420
Step 3: Install OpenVPN
1. Now, you’re inside your LXC container.
2. To ensure proper functionality, let’s start with the TurnKey OpenVPN template:
root@CT420:~# git clone https://github.com/Nyr/openvpn-install
cd openvpn-install
3. Run the OpenVPN installation script:
# bash openvpn-install.sh
4. The installer will welcome you as well as ask for your public IP address. Confirm it by pressing Enter.
5. Choose the OpenVPN protocol (Option 1 for UDP).
6. Specify the port to listen to. You can use the default or choose another port (make sure it’s not blocked by your ISP).
7. Select your DNS server.
8. Enter a name for your first OpenVPN client.
9. Last press any key to let the installation complete.
Congratulations! Now that is done, You have successfully set up an OpenVPN server within an LXC container in Proxmox. Additionally you can add multiple clients by running the bash script again. After all, you may want to allow friends and family to utilize this . Finally, now you can configure your network to let traffic through the port you specified and can access your home network while on the go!
In conclusion, when you follow these steps, you’ll unlock the benefits of hosting your own OpenVPN server within a container. This not only enhances security and privacy for your online activities but also puts you in charge of your internet connection. Consequently, you’ll experience an added layer of protection and peace of mind.