With increasing risks to online privacy, creating your own VPN with WireGuard offers a secure and high-performance solution. This tutorial shows you how to install and configure WireGuard on a VPS with the IP address 51.0.0.27, to route all your Internet traffic securely.
📌 Why Choose WireGuard?
- Speed: Modern protocol (better performance than OpenVPN/IPSec)
- Simplicity: Minimalist configuration (~100 lines of code)
- Security: Encryption with ChaCha20 and key authentication
ℹ️ Technical comparison: WireGuard offers twice the throughput of OpenVPN with reduced latency.
🛠️ Prerequisites
- A VPS (Ubuntu/Debian recommended) with IP 51.0.0.27
- Root access via SSH
- 10 minutes available
🔧 WireGuard installation
1. Connecting to the VPS
ssh root@51.0.0.27
2. Installing packages
On Ubuntu/Debian :
sudo apt update && sudo apt install wireguard resolvconf -y
📂 Server Configuration
1. Generation of cryptographic keys
umask 077
wg genkey | tee /etc/wireguard/privatekey | wg pubkey > /etc/wireguard/publickey
2. Server configuration
Create the file /etc/wireguard/wg0.conf
:
[Interface]
Address = 10.8.0.1/24
PrivateKey = <CONTENU_PRIVATEKEY>
ListenPort = 51820
PostUp = iptables -A FORWARD -i wg0 -j ACCEPT; iptables -t nat -A POSTROUTING -o eth0 -j MASQUERADE
PostDown = iptables -D FORWARD -i wg0 -j ACCEPT; iptables -t nat -D POSTROUTING -o eth0 -j MASQUERADE
3. Service activation
sudo systemctl enable --now wg-quick@wg0
📱 Client Configuration
1. Creating customer keys
wg genkey | tee client_private.key | wg pubkey > client_public.key
2. Adding the client to the server
Edit /etc/wireguard/wg0.conf
and add :
[Peer]
PublicKey = <CLIENT_PUBLIC_KEY>
AllowedIPs = 10.8.0.2/32
3. Client configuration file
Create a client.conf
file with :
[Interface]
PrivateKey = <CLIENT_PRIVATE_KEY>
Address = 10.8.0.2/24
DNS = 1.1.1.1
[Peer]
PublicKey = <SERVER_PUBLIC_KEY>
Endpoint = 51.0.0.27:51820
AllowedIPs = 0.0.0.0/0
PersistentKeepalive = 25
🌍 Functionality Test
- Import
client.conf
into the WireGuard application - Enable the VPN connection
Check your public IP address:
curl ifconfig.me
→ Should display 51.0.0.27
Stop the connection via VPN
sudo wg-quick down /etc/wireguard/wg0.conf
Useful resource:
https://docs.vultr.com/how-to-install-wireguard-vpn-on-debian-12