> 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/networking/wireguard--adding-nameserver-entries-to-client-configs.md).

# Wireguard - Adding Nameserver entries to Client Configs

How to add PostUp and PostDown scripts to WireGuard client configurations for DNS nameserver resolution on Windows and Linux.

The following are instructions for adding a **PostUp** and **PostDown** script to the **Wireguard** config.\
For **Windows**, this adds **Powershell** commands for adding and removing a **DNS Client Rule** when the client connects and disconnects.

## Windows Clients

1. In the **Windows** Wireguard client, **edit the config**.
2. Add the following commands in the **\[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. Change the following entries to match **your** setup:
   * **Namespace**: A comma-separated list of domain names to add.
   * **NameServers**: A comma-separated list of nameserver IP addresses.

{% hint style="info" %}
**For the -match, make sure to include a backslash (\\) before each period (.)**
{% endhint %}

***

## Linux Clients

This may vary based on your Linux distribution.

1. **Edit the config file** on the **Linux** client.
2. In the **\[Interface]** section, add the following:

```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. Replace **10.1.10.2** with the correct IP of your **nameserver**.
4. Replace **domainname.com** with your domain name.

***

{% hint style="info" %}
**Document Information**

* Last Updated: 2024-08-29
* vergeOS Version: 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/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.
