« Wireguard » : différence entre les versions
Apparence
Aucun résumé des modifications |
Aucun résumé des modifications |
||
| (Une version intermédiaire par le même utilisateur non affichée) | |||
| 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> | <syntaxhighlight lang="bash" line> | ||
| Ligne 95 : | Ligne 51 : | ||
PresharedKey = TA_PSK_ICI | PresharedKey = TA_PSK_ICI | ||
</syntaxhighlight> | </syntaxhighlight> | ||
=== 🟢 Commandes === | |||
Démarrer l'interface : | |||
<syntaxhighlight lang="bash" line copy> | |||
sudo wg-quick up wg0 | |||
</syntaxhighlight> | |||
Arrêter l'interface : | |||
<syntaxhighlight lang="bash" line copy> | |||
sudo wg-quick down wg0 | |||
</syntaxhighlight> | |||
Redémarrer l'interface | |||
<syntaxhighlight lang="bash" line copy> | |||
systemctl restart wg-quick@wg0 | |||
</syntaxhighlight> | |||
Les logs de WireGuard sont également enregistrés dans le journal système | |||
<syntaxhighlight lang="bash" line copy> | |||
sudo journalctl -u wg-quick@wg0 | |||
</syntaxhighlight> | |||
<syntaxhighlight lang="bash" line copy> | |||
sudo journalctl -u wg-quick@wg0 -p err | |||
</syntaxhighlight> | |||
1. Afficher des informations sur l'état des interfaces WireGuard, y compris les adresses IP des pairs, les données transférées, etc. | |||
<syntaxhighlight lang="bash" line copy> | |||
sudo wg show wg0 | |||
</syntaxhighlight> | |||
2. Pour voir les connexions actives sur le port WireGuard | |||
<syntaxhighlight lang="bash" line copy> | |||
sudo ss -anu | grep 51820 | |||
</syntaxhighlight> | |||
ou | |||
<syntaxhighlight lang="bash" line copy> | |||
sudo netstat -anu | grep 51820 | |||
</syntaxhighlight> | |||
3. Capturer le trafic WireGuard | |||
<syntaxhighlight lang="bash" line copy> | |||
sudo tcpdump -i wg0 udp port 51820 | |||
</syntaxhighlight> | |||
4. Vérifier les connexions actives | |||
<syntaxhighlight lang="bash" line copy> | |||
sudo wg show wg0 | grep -A 2 "peer:" | |||
</syntaxhighlight> | |||
5. Surveiller les connexions en temps réel | |||
<syntaxhighlight lang="bash" line copy> | |||
sudo watch -n 1 wg show wg0 | |||
</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