# WireGuard - Ajouter un nouveau client

Ce tutoriel explique comment ajouter un nouveau client WireGuard sur le Raspberry Pi hébergeant AdGuard Home.

---

## 1. Créer le dossier du client

```bash

cd /opt/papa-network/wireguard/clients
mkdir -p windows
cd windows

```

---

## 2. Générer les clés

```bash

umask 077
wg genkey | tee windows.key | wg pubkey > windows.pub

```

---

## 3. Récupérer les clés

```bash

cat windows.key
cat windows.pub

```

---

## 4. Ajouter le client au serveur

Éditer :

```bash

sudo nano /etc/wireguard/wg0.conf

```

Ajouter à la fin du fichier :

```

[Peer]
PublicKey = <CONTENU_DE_WINDOWS.PUB>
AllowedIPs = 10.200.1.X/32

```

**Remplacer X** par une adresse IP libre.

Exemple :

```

10.200.1.4

```

---

## 5. Créer le fichier client

```bash

nano windows.conf

```

```

[Interface]
PrivateKey = <CONTENU_DE_WINDOWS.KEY>
Address = 10.200.1.4/32
DNS = 192.168.1.2
[Peer]
PublicKey = <CLE_PUBLIQUE_DU_SERVEUR>
Endpoint = papa.numericare.fr:51820
AllowedIPs = 192.168.1.0/24,10.200.1.0/24
PersistentKeepalive = 25

```

---

## 6. Recharger WireGuard

```bash

sudo systemctl restart wg-quick@wg0

```

---

## 7. Vérifier le serveur

```bash

sudo wg

```

Le nouveau **Peer** doit apparaître.

---

## 8. Générer le QR Code (Android / iPhone)

```bash

qrencode -o /opt/papa-network/wireguard/qr/windows.png < windows.conf

```

Ou directement dans le terminal :

```bash

qrencode -t ansiutf8 < windows.conf

```

---

## 9. Import du client

<table id="bkmrk-plateforme-action-wi"><tbody><tr><th>Plateforme</th><th>Action</th></tr><tr><td>Windows</td><td>Importer le fichier **windows.conf** dans WireGuard.</td></tr><tr><td>Linux</td><td>Copier le fichier dans **/etc/wireguard/wg0.conf** puis démarrer **wg-quick@wg0**.</td></tr><tr><td>Android / iPhone</td><td>Scanner le QR Code.</td></tr></tbody></table>

---

## 10. Vérification

Depuis le client :

```bash

ping 192.168.1.2

```

Puis :

```bash

nslookup google.fr

```

Le serveur DNS doit être :

```

192.168.1.2

```

---

## Bonnes pratiques

- 1 client = 1 paire de clés.
- Ne jamais réutiliser une clé privée.
- Une adresse IP WireGuard unique par client.
- Toujours redémarrer **wg-quick@wg0** après modification.
- Conserver les fichiers **.key**, **.pub** et **.conf** dans le dossier du client.