Kennisbank › Apache › Networks and VPN on your own server: practical guide for developers
apache gemiddeld 17 July 2026

Networks and VPN on your own server: practical guide for developers

Learn how to install a professional VPN server with WireGuard or OpenVPN. Full control over your network traffic in a few steps.

As a developer or system administrator, you sometimes want to have control over your network connections yourself. Running a VPN on your own server offers privacy, security, and flexibility. In this article, you will learn how to implement a professional VPN solution with tools such as WireGuard and OpenVPN.

Why a VPN server of your own?

Commercial VPN services are convenient, but with a self-managed VPN server you get:

  • Full control over your data and logs
  • Better performance for personal or team use
  • The ability to apply specific network configurations
  • Cost savings with long-term use

WireGuard: the modern VPN standard

WireGuard is the new generation of VPN technology: lightweight, fast, and easy to configure. It uses state-of-the-art cryptography and has been included in the Linux kernel.

Installation and basic configuration

On Ubuntu/Debian, install WireGuard with:

sudo apt update && sudo apt install wireguard

Generate keys for the server and clients:

wg genkey | tee privatekey | wg pubkey > publickey

Creating the configuration file

Create /etc/wireguard/wg0.conf with this basic structure:

[Interface]
PrivateKey = [SERVER_PRIVATE_KEY]
Address = 10.0.0.1/24
ListenPort = 51820
PostUp = iptables -A FORWARD -i %i -j ACCEPT; iptables -t nat -A POSTROUTING -o eth0 -j MASQUERADE
PostDown = iptables -D FORWARD -i %i -j ACCEPT; iptables -t nat -D POSTROUTING -o eth0 -j MASQUERADE

Starting the tunnel

Activate the VPN tunnel with wg-quick:

wg-quick up wg0

Check the status:

wg show

PiVPN: a simple OpenVPN implementation

For those who prefer to use OpenVPN, PiVPN is an excellent tool. Although originally developed for the Raspberry Pi, it works on any Linux system.

Installation

Run this installation script:

curl -L https://install.pivpn.io | bash

The script guides you through the configuration:

  • Choose between OpenVPN or WireGuard
  • Select your network interface
  • Configure DNS settings

Adding clients

Create new client configurations with:

sudo pivpn add

This generates .ovpn files that you can import into client software.

Advanced network configurations

With your own VPN server, you can implement advanced network topologies:

Site-to-site VPN

Connect two locations via a permanent VPN tunnel for a secure corporate network.

Split tunneling

Route only specific traffic through the VPN, ideal for remote workers who need local resources.

Kill switch

Implement firewall rules that block all internet access if the VPN connection drops.

Practical tips for VPN management

  • Monitor bandwidth usage: Use vnstat or iftop to keep an eye on consumption
  • Automate updates: Make sure WireGuard/OpenVPN are always up to date
  • Make backups: Store copies of configuration files and keys
  • Restrict access: Use firewall rules to allow only known IPs

Alternatives to self-hosting

Sometimes a managed VPN service is more practical. Popular CLI clients:

  • Mullvad: mullvad account set [ACCOUNT_NUMBER]
  • ProtonVPN: protonvpn init

Conclusion

Running a VPN on your own server gives you full control over your network traffic. WireGuard offers a modern, high-performance solution, while PiVPN simplifies the process for OpenVPN. With the right configuration, you create a secure, private network environment that meets exactly your needs.

Start small, test thoroughly, and expand gradually. That is how you build a robust VPN solution that will last for years.

← Terug naar kennisbank