« Wireguard » : différence entre les versions
Apparence
Aucun résumé des modifications |
Aucun résumé des modifications |
||
| (2 versions intermédiaires par le même utilisateur non affichées) | |||
| Ligne 1 : | Ligne 1 : | ||
=== Générer paire de clés pour un client === | |||
=== 🟢 Générer paire de clés pour un client === | |||
<syntaxhighlight lang="bash" line copy> | <syntaxhighlight lang="bash" line copy> | ||
wg genkey | tee client1.key | wg pubkey > client1.pub | wg genkey | tee client1.key | wg pubkey > client1.pub | ||
</syntaxhighlight> | </syntaxhighlight> | ||
=== 🟢 Ajouter une PresharedKey (PSK) à un peer === | |||
<syntaxhighlight lang="bash" line> | |||
mkdir -p /etc/wireguard/keys | |||
chmod 700 /etc/wireguard/keys | |||
</syntaxhighlight> | |||
<syntaxhighlight lang="bash" line> | |||
wg genpsk | tee /etc/wireguard/keys/client1.psk | |||
chmod 600 /etc/wireguard/keys/client1.psk | |||
</syntaxhighlight> | |||
👉 récupère la clé : | |||
<syntaxhighlight lang="bash" copy> | |||
cat /etc/wireguard/keys/client1.psk | |||
</syntaxhighlight> | |||
1. Modifier ton `wg0.conf` (serveur) | |||
<syntaxhighlight lang="bash" copy> | |||
nano /etc/wireguard/wg0.conf | |||
</syntaxhighlight> | |||
Ajoute dans le peer concerné : | |||
<syntaxhighlight lang="bash" line> | |||
[Peer] | |||
PublicKey = CLIENT_PUBLIC_KEY | |||
PresharedKey = TA_PSK_ICI | |||
</syntaxhighlight> | |||
2. Ajouter la PSK côté client | |||
<syntaxhighlight lang="bash" copy> | |||
nano /etc/wireguard/client1.conf | |||
</syntaxhighlight> | |||
<syntaxhighlight lang="bash" line> | |||
[Peer] | |||
PublicKey = SERVER_PUBLIC_KEY | |||
PresharedKey = TA_PSK_ICI | |||
</syntaxhighlight> | |||
=== 🟢 Commandes === | |||
Démarrer l'interface : | Démarrer l'interface : | ||
<syntaxhighlight lang="bash" line copy> | <syntaxhighlight lang="bash" line copy> | ||
| Ligne 47 : | Ligne 97 : | ||
sudo watch -n 1 wg show wg0 | sudo watch -n 1 wg show wg0 | ||
</syntaxhighlight> | </syntaxhighlight> | ||
=== 🟢 QR‑code WireGuard === | |||
*[[ Wireguard_qrcode | Wireguard qrcode ]] | |||
== Sources == | == Sources == | ||
Dernière version du 29 mars 2026 à 18:05
🟢 Générer paire de clés pour un client
wg genkey | tee client1.key | wg pubkey > client1.pub
mkdir -p /etc/wireguard/keys
chmod 700 /etc/wireguard/keys
wg genpsk | tee /etc/wireguard/keys/client1.psk
chmod 600 /etc/wireguard/keys/client1.psk
👉 récupère la clé :
cat /etc/wireguard/keys/client1.psk
1. Modifier ton `wg0.conf` (serveur)
nano /etc/wireguard/wg0.conf
Ajoute dans le peer concerné :
[Peer]
PublicKey = CLIENT_PUBLIC_KEY
PresharedKey = TA_PSK_ICI
2. Ajouter la PSK côté client
nano /etc/wireguard/client1.conf
[Peer]
PublicKey = SERVER_PUBLIC_KEY
PresharedKey = TA_PSK_ICI
🟢 Commandes
Démarrer l'interface :
sudo wg-quick up wg0
Arrêter l'interface :
sudo wg-quick down wg0
Redémarrer l'interface
systemctl restart wg-quick@wg0
Les logs de WireGuard sont également enregistrés dans le journal système
sudo journalctl -u wg-quick@wg0
sudo journalctl -u wg-quick@wg0 -p err
1. Afficher des informations sur l'état des interfaces WireGuard, y compris les adresses IP des pairs, les données transférées, etc.
sudo wg show wg0
2. Pour voir les connexions actives sur le port WireGuard
sudo ss -anu | grep 51820
ou
sudo netstat -anu | grep 51820
3. Capturer le trafic WireGuard
sudo tcpdump -i wg0 udp port 51820
4. Vérifier les connexions actives
sudo wg show wg0 | grep -A 2 "peer:"
5. Surveiller les connexions en temps réel
sudo watch -n 1 wg show wg0
🟢 QR‑code WireGuard
Sources
blog.flozz.fr exemple installation manuelle blog.flozz.fr Fichiers de configuration