Accès à distance — WireGuard
WireGuard permet d'intervenir sur n'importe quel mini-PC hôtel depuis ton PC, sans se déplacer.
Comment ça fonctionne
Ton PC (10.0.0.2) ──► VPS ITDreamTech (10.0.0.1) ◄── Mini-PC Hôtel A (10.0.0.10)
◄── Mini-PC Hôtel B (10.0.0.11)
Le mini-PC initie une connexion sortante vers le VPS. Tu accèdes ensuite à l'hôtel via le tunnel.
Table des adresses VPN
| Adresse VPN | Machine |
|---|---|
| 10.0.0.1 | VPS ITDreamTech |
| 10.0.0.2 | Ton PC |
| 10.0.0.10 | Hôtel A |
| 10.0.0.11 | Hôtel B |
| 10.0.0.12 | Hôtel C |
Configuration — VPS ITDreamTech (une seule fois)
sudo apt install -y wireguard
# Générer les clés serveur
wg genkey | tee /etc/wireguard/server_private.key | wg pubkey > /etc/wireguard/server_public.key
# /etc/wireguard/wg0.conf
cat > /etc/wireguard/wg0.conf <<EOF
[Interface]
Address = 10.0.0.1/24
ListenPort = 51820
PrivateKey = $(cat /etc/wireguard/server_private.key)
EOF
sudo systemctl enable wg-quick@wg0
sudo systemctl start wg-quick@wg0
Ajouter un hôtel (un peer par hôtel)
Sur le mini-PC hôtel :
wg genkey | tee /etc/wireguard/client_private.key | wg pubkey > /etc/wireguard/client_public.key
cat > /etc/wireguard/wg0.conf <<EOF
[Interface]
Address = 10.0.0.10/24
PrivateKey = $(cat /etc/wireguard/client_private.key)
[Peer]
PublicKey = <SERVER_PUBLIC_KEY>
Endpoint = <IP_VPS>:51820
AllowedIPs = 10.0.0.1/32
PersistentKeepalive = 25
EOF
sudo systemctl enable wg-quick@wg0
sudo systemctl start wg-quick@wg0
Sur le VPS, ajouter dans /etc/wireguard/wg0.conf :
[Peer]
# Hôtel A — Ndinga Palace Yaoundé
PublicKey = <CLIENT_PUBLIC_KEY>
AllowedIPs = 10.0.0.10/32
Puis : sudo wg addconf wg0 <(wg-quick strip wg0) ou redémarrer WireGuard.
Utilisation quotidienne
# Connecter ton PC au VPN
sudo wg-quick up stayflow-vpn
# SSH vers un hôtel
ssh user@10.0.0.10
# Accès navigateur
# http://10.0.0.10
# Déconnecter
sudo wg-quick down stayflow-vpn
Dépannage
# Vérifier l'état WireGuard sur le mini-PC
sudo wg show
# Redémarrer le tunnel
sudo systemctl restart wg-quick@wg0