Installer WireGuard VPN
WireGuard est un VPN moderne, léger et rapide. Sur un VPS Linux HolyCloud, il permet d'accéder à SSH, bases de données ou panels sans les exposer publiquement, en ne laissant ouvert que le port UDP de WireGuard.
Prérequis
- VPS HolyCloud Ubuntu/Debian, kernel récent (WireGuard inclus)
- Accès sudo
- Port UDP choisi (ex. 51820) ouvert dans UFW et le pare-feu HolyCloud
- Clients : Windows, macOS, Linux, iOS, Android (application WireGuard)
Étape 1 : installation
sudo apt update
sudo apt install -y wireguard qrencode
Étape 2 : clés serveur
umask 077
wg genkey | tee /etc/wireguard/server_private.key | wg pubkey > /etc/wireguard/server_public.key
sudo chmod 600 /etc/wireguard/server_private.key
Étape 3 : configuration serveur
sudo nano /etc/wireguard/wg0.conf
[Interface]
Address = 10.8.0.1/24
ListenPort = 51820
PrivateKey = CONTENU_DE_server_private.key
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
[Peer]
# Client 1 — laptop
PublicKey = CLE_PUBLIQUE_CLIENT
AllowedIPs = 10.8.0.2/32
Remplacez eth0 par l'interface publique (ip -o -4 route show to default | awk '{print $5}').
Générez les clés client :
wg genkey | tee client1_private.key | wg pubkey > client1_public.key
Étape 4 : IP forwarding et pare-feu
echo 'net.ipv4.ip_forward=1' | sudo tee /etc/sysctl.d/99-wireguard.conf
sudo sysctl --system
sudo ufw allow 51820/udp comment 'WireGuard'
sudo systemctl enable --now wg-quick@wg0
Étape 5 : configuration client (exemple)
Fichier client1.conf à importer dans l'app WireGuard :
[Interface]
PrivateKey = CLE_PRIVEE_CLIENT
Address = 10.8.0.2/24
DNS = 1.1.1.1
[Peer]
PublicKey = CLE_PUBLIQUE_SERVEUR
Endpoint = IP_PUBLIQUE_VPS_HOLYCLOUD:51820
AllowedIPs = 10.8.0.0/24
PersistentKeepalive = 25
QR code (mobile) :
qrencode -t ansiutf8 < client1.conf
Pour router tout le trafic Internet via le VPS, utilisez AllowedIPs = 0.0.0.0/0, ::/0 (responsabilité légale et charge réseau à votre charge).
Vérification
sudo wg show
ping -c 3 10.8.0.2
Côté client : tunnel « actif », ping vers 10.8.0.1, accès SSH via IP VPN :
ssh [email protected]
Besoin d'aide HolyCloud
- Pas de handshake : vérifiez UDP 51820 (UFW + espace client),
Endpointet clés publiques - Pas d'Internet via tunnel :
ip_forward, règlesMASQUERADE, bonne interface réseau - Support HolyCloud :
sudo wg show, interface par défaut, capturejournalctl -u wg-quick@wg0