> For the complete documentation index, see [llms.txt](https://docs.verge.io/llms.txt). Markdown versions of documentation pages are available by appending `.md` to page URLs; this page is available as [Markdown](https://docs.verge.io/knowledge-base/fr/networking/wireguard--adding-nameserver-entries-to-client-configs.md).

# WireGuard - Ajouter des entrées de serveur de noms aux configurations client

Comment ajouter des scripts PostUp et PostDown aux configurations client WireGuard pour la résolution des serveurs de noms DNS sous Windows et Linux.

Les instructions suivantes expliquent comment ajouter un **PostUp** et **PostDown** script à la **WireGuard** configuration.\
Pour **Windows**, cela ajoute **PowerShell** des commandes pour ajouter et supprimer une **règle client DNS** lorsque le client se connecte et se déconnecte.

## Clients Windows

1. Dans le **Windows** client WireGuard, **modifiez la config**.
2. Ajoutez les commandes suivantes dans la **\[Interface]** section :

```pwsh
PostUp = powershell -command "Add-DnsClientNrptRule -Namespace 'domainname.com' -NameServers '10.1.10.2'"
PostDown = powershell -command "Get-DnsClientNrptRule | Where { $_.Namespace -match '.*domainname\.com' } | Remove-DnsClientNrptRule -force"
```

3. Modifiez les entrées suivantes pour qu'elles correspondent à **votre** configuration :
   * **Namespace**: Une liste de noms de domaine séparés par des virgules à ajouter.
   * **NameServers**: Une liste d'adresses IP de serveurs de noms séparées par des virgules.

{% hint style="info" %}
**Pour -match, assurez-vous d'inclure une barre oblique inverse (\\) avant chaque point (.)**
{% endhint %}

***

## Clients Linux

Cela peut varier selon votre distribution Linux.

1. **Modifiez le fichier de configuration** sur le **client Linux** .
2. Dans le **\[Interface]** section, ajoutez ce qui suit :

```bash
PostUp = resolvectl dns %i 10.1.10.2; resolvectl domain %i domainname.com
PreUp = iptables -A INPUT -i wg -m state --state ESTABLISHED,RELATED -j ACCEPT
PreUp = iptables -A INPUT -i wg -j REJECT
PostDown = iptables -D INPUT -i wg -m state --state ESTABLISHED,RELATED -j ACCEPT
PostDown = iptables -D INPUT -i wg -j REJECT
```

3. Remplacez **10.1.10.2** avec l'adresse IP correcte de votre **serveur de noms**.
4. Remplacez **domainname.com** avec le nom de votre domaine.

***

{% hint style="info" %}
**Informations sur le document**

* Dernière mise à jour : 2024-08-29
* Version de vergeOS : 4.12.6
  {% endhint %}


---

# Agent Instructions
This documentation is published with GitBook. GitBook is the documentation platform designed so that both humans and AI agents can read, navigate, and reason over technical content effectively. Learn more at gitbook.com.

## Querying This Documentation
If you need additional information that is not directly available in this page, you can query the documentation by asking a question.

Perform an HTTP GET request on the following URL with the `ask` and `goal` query parameters:

```
GET https://docs.verge.io/knowledge-base/fr/networking/wireguard--adding-nameserver-entries-to-client-configs.md?ask=<question>&goal=<user_goal>
```

`ask` is the immediate question: it should be specific, self-contained, and written in natural language.
`goal` is what the user is ultimately trying to achieve, the reason they need the answer. Sharing it helps GitBook give you a better, more relevant answer. A goal is most helpful when it describes the outcome the user wants rather than restating the question. For example, with `ask=how do I create an API token`, a goal like `automate deployments from our CI pipeline` lets GitBook tailor the answer to that use case.

The response will contain a direct answer to the question and relevant excerpts and sources from the documentation.

Use this mechanism when the answer is not explicitly present in the current page, you need clarification or additional context, or you want to retrieve related documentation sections.
