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

# Wireguard - Adding Nameserver entries to Client Configs

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 dynamically by asking a question.

Perform an HTTP GET request on the current page URL with the `ask` query parameter:

```
GET https://docs.vergeos-demo.com/knowledge-base/networking/wireguard--adding-nameserver-entries-to-client-configs.md?ask=<question>
```

The question should be specific, self-contained, and written in natural language.
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.
