# How to set up your own DNS server

## Introduction <a href="#introduction" id="introduction"></a>

Once the internet connection is set up in your home, it is usually configured to use the internet service provider’s DNS addresses. Using such DNS can lead to a number of inconveniences: longer website loading times, unwanted URL blocking, and query logging. All of these factors can make the browsing experience feel like a chore. Thankfully, there are various ways to overcome these hindrances, such as configuring a personal DNS server. A tool that allows you to do exactly this is [dnsmasq](https://en.wikipedia.org/wiki/Dnsmasq).

By using the free dnsmasq[ ](https://en.wikipedia.org/wiki/Dnsmasq)software, your device can function as a DNS forwarder and DHCP server. It has an integrated DNS caching feature. This means that any website that is saved in the cache will open nearly instantly. Such behavior leads to a much smoother and more enjoyable browsing experience. Additionally, you are in control of your DNS records, as you can monitor them directly on your device or disable logging altogether.

The drawback of dnsmasq is that it is designed to work only on the local network. However, with the addition of [Meshnet](https://nordvpn.com/meshnet/), you can use your dnsmasq configuration no matter how far away from home you are.

In this article, you will find instructions on how to set up a personal DNS server using dnsmasq on macOS and Linux.

{% hint style="info" %}
**Note**

This setup cannot be used on mobile devices using cellular data. Changing the DNS addresses and keeping the Meshnet connection is not possible with such a connection method.
{% endhint %}

{% tabs %}
{% tab title="macOS" %}

## Before you begin

Because dnsmasq uses port 53 for its functionality, it is important to ensure that this port is available on your system before configuring dnsmasq. To do so, open Terminal and execute the following command:

```bash
sudo lsof -i -n -P | grep :53
```

If port 53 is being used, in the output, you will see the name of the process that is using it.

In case the port is occupied, you will need to free it up by killing the other process which is using port 53 or changing its port to a different one.

### Install Homebrew <a href="#install-homebrew" id="install-homebrew"></a>

To install dnsmasq, you can use the [Homebrew](https://brew.sh/) package manager. Install Homebrew by taking these steps:

1. Open Terminal.
2. Enter the following command:<br>

   <pre class="language-bash" data-overflow="wrap"><code class="lang-bash">/bin/bash -c "$(curl -fsSL https://raw.githubusercontent.com/Homebrew/install/HEAD/install.sh)"
   </code></pre>

   \
   For additional information about the installation process, refer to [Homebrew documentation](https://docs.brew.sh/Installation).
3. Follow the on-screen instructions to finish the installation.

### Find the Meshnet network interface <a href="#find-the-meshnet-network-interface" id="find-the-meshnet-network-interface"></a>

Communication between devices in Meshnet is done via the Meshnet network interface. The name of the interface can differ for each device. To find the correct name on your device:

1. [Enable Meshnet on macOS](https://meshnet.nordvpn.com/~/changes/5hiVtBuK6qwLGxb0SjCm/getting-started/how-to-start-using-meshnet/using-meshnet-on-macos#enable-meshnet-on-macos).

2. Open **Terminal**.

3. Run the following command:<br>

   ```bash
   ifconfig
   ```

4. Locate the interface with your Meshnet IP and note its name. For example, `utun3`.<br>

   <div align="left"><figure><img src="https://3559400189-files.gitbook.io/~/files/v0/b/gitbook-x-prod.appspot.com/o/spaces%2F0cTezbT2vN0lurEio8Z5%2Fuploads%2F1whJdNa3Xn1KhdtmmazP%2Fmac_utun.png?alt=media&#x26;token=d563b95b-7b07-409f-9523-cdf6bf7514ea" alt="Meshnet network interface"><figcaption></figcaption></figure></div>

## Install dnsmasq <a href="#install-dnsmasq" id="install-dnsmasq"></a>

To start configuring your DNS server, you will need to install dnsmasq on your machine.

1. Open **Terminal**.
2. Install dnsmasq by running the following command:<br>

   ```bash
   brew install dnsmasq
   ```

The dnsmasq application will be installed.

## Configure dnsmasq <a href="#configure-dnsmasq" id="configure-dnsmasq"></a>

Dnsmasq settings are controlled via its configuration file called `dnsmasq.conf`.

1. Open the `dnsmasq.conf` file using the Nano text editor by running this command in **Terminal**:\
   \
   For Intel Macs:

   ```bash
   nano /usr/local/etc/dnsmasq.conf
   ```

   \
   For [Apple silicon Macs](https://support.apple.com/en-us/HT211814):

   ```bash
   nano /opt/homebrew/etc/dnsmasq.conf
   ```

   &#x20;

2. Using the **Control** ⌃ + **W** keyboard shortcut, locate and uncomment the following lines by removing the hash (#) symbol at the start:\
   • `domain-needed`\
   • `bogus-priv`\
   • `no-resolv`<br>

   <div align="left"><figure><img src="https://3559400189-files.gitbook.io/~/files/v0/b/gitbook-x-prod.appspot.com/o/spaces%2F0cTezbT2vN0lurEio8Z5%2Fuploads%2Fa4d1pMatktKRkCrKnAhG%2Fmac_bogus_domain.png?alt=media&#x26;token=2c041fbd-83ba-41b6-865f-8fd411bbc2e3" alt="domain-needed and bogus-priv lines"><figcaption></figcaption></figure></div>

   <div align="left"><figure><img src="https://3559400189-files.gitbook.io/~/files/v0/b/gitbook-x-prod.appspot.com/o/spaces%2F0cTezbT2vN0lurEio8Z5%2Fuploads%2FxlFhJVfwhVpJZbP0uGgv%2Fmac_no_resolv.png?alt=media&#x26;token=a9e409f1-ecbd-454d-9a56-ba74fab145c8" alt="no-resolv line"><figcaption></figcaption></figure></div>

3. Find the `cache-size` line, uncomment it, and change the value to 1000.\
   &#x20;

   <div align="left"><figure><img src="https://3559400189-files.gitbook.io/~/files/v0/b/gitbook-x-prod.appspot.com/o/spaces%2F0cTezbT2vN0lurEio8Z5%2Fuploads%2FDBzk8duRauudOvPXd9ez%2Fmac_cache.png?alt=media&#x26;token=56647441-8ca4-4d78-8c33-3f4e1fd9a540" alt="cache-size line"><figcaption></figcaption></figure></div>

4. Locate the `interface` line, uncomment it, and append the name of the network interface from the [Find the Meshnet network interface](#find-the-meshnet-network-interface) section after the equals (=) sign.\
   &#x20;

   <div align="left"><figure><img src="https://3559400189-files.gitbook.io/~/files/v0/b/gitbook-x-prod.appspot.com/o/spaces%2F0cTezbT2vN0lurEio8Z5%2Fuploads%2FsZLsD7eMRKL9lsPJRpQd%2Fmac_interface.png?alt=media&#x26;token=667fb697-94e5-4d09-a39f-4ced24696c42" alt="interface line with the Meshnet network interface name"><figcaption></figcaption></figure></div>

5. Find the `#server=/localnet/192.168.0.1` line and replace it with the following two lines:<br>

   ```
   server=1.1.1.1
   server=8.8.8.8
   ```

   <div align="left"><figure><img src="https://3559400189-files.gitbook.io/~/files/v0/b/gitbook-x-prod.appspot.com/o/spaces%2F0cTezbT2vN0lurEio8Z5%2Fuploads%2FkTYLY5kAeKkmqbh5qIa7%2Fmac_servers.png?alt=media&#x26;token=3efeca86-ecd0-4282-ad6b-43b6780a4157" alt="Edited server lines"><figcaption></figcaption></figure></div>

   Instead of the `1.1.1.1` and `8.8.8.8` DNS addresses, you can use your preferred DNS provider for the upstream DNS.

6. Press **Control** + **X**, **Y**, and **Return** to save changes and exit.

Start the dnsmasq process as the root user via the following command:

```bash
sudo brew services start dnsmasq
```

{% hint style="info" %}
**Note**

Detailed information about the altered parameters can be found in the Options section of the [dnsmasq manual page](https://thekelleys.org.uk/dnsmasq/docs/dnsmasq-man.html).
{% endhint %}

### Enable query logging (optional)

You can enable query logging in the `dnsmasq.conf` file to monitor for any failed DNS resolutions or inconsistencies in website loading.

1. Open **Terminal** and run the following command:\
   \
   For Intel Macs:

   ```bash
   nano /usr/local/etc/dnsmasq.conf
   ```

   &#x20;

   For [Apple silicon Macs](https://support.apple.com/en-us/HT211814):

   ```bash
   nano /opt/homebrew/etc/dnsmasq.conf
   ```

2. Locate the `log-queries` line and uncomment it by removing the hash (#) symbol at the start.

3. Append a new `log-facility=/usr/local/var/log/dnsmasq.log` line below `log-queries`.\
   &#x20;

   <div align="left"><figure><img src="https://3559400189-files.gitbook.io/~/files/v0/b/gitbook-x-prod.appspot.com/o/spaces%2F0cTezbT2vN0lurEio8Z5%2Fuploads%2F2FRxQgu4s5FeQLmMuJZ9%2Fmac_log.png?alt=media&#x26;token=5d22ae8a-dd16-418e-87f3-8cc6c250b920" alt="Lines for query logging"><figcaption></figcaption></figure></div>

4. Press **Control** + **X**, **Y**, and **Return** to save changes and exit.

5. Restart the dnsmasq process by running:<br>

   ```bash
   sudo brew services restart dnsmasq
   ```

All of the DNS queries will now be logged in the `/usr/local/var/log/dnsmasq.log` file.

## Test dnsmasq

To test if dnsmasq was configured properly and is working, do the following:

1. Open **Terminal**.

2. Check the status of the dnsmasq service via this command:<br>

   ```bash
   sudo brew services list
   ```

   &#x20;

   <div align="left"><figure><img src="https://3559400189-files.gitbook.io/~/files/v0/b/gitbook-x-prod.appspot.com/o/spaces%2F0cTezbT2vN0lurEio8Z5%2Fuploads%2FcEeZjBvr5Sn3bkRuqQst%2Fmac_status.png?alt=media&#x26;token=294eac8a-58b5-4a61-9ba5-3f0dfe5b38fa" alt="Status of the dnsmasq service"><figcaption></figcaption></figure></div>

3. Check if the domain name resolution is working properly by using `dig`:<br>

   ```bash
   dig nordvpn.com @localhost
   ```

   <div align="left"><figure><img src="https://3559400189-files.gitbook.io/~/files/v0/b/gitbook-x-prod.appspot.com/o/spaces%2F0cTezbT2vN0lurEio8Z5%2Fuploads%2F917Fxn605r6LJ39n5pbh%2Fmac_dig.png?alt=media&#x26;token=4fdeba81-7d48-4ebf-9af8-c5357c033c98" alt="Output of the &#x27;dig&#x27; command"><figcaption></figcaption></figure></div>

If you receive an answer to the `dig` command, it indicates that your DNS server is working properly and ready for use.
{% endtab %}

{% tab title="Linux" %}

## Before you begin <a href="#prerequisites" id="prerequisites"></a>

Because dnsmasq uses port 53 for its functionality, it is important to ensure that this port is available on your system before configuring dnsmasq. To do so, open Terminal and execute the following command:

```bash
sudo netstat -tulpn | grep :53
```

{% hint style="info" %}
**Note**

The `net-tools` package is required to use the `netstat` command.

It can be installed by running the following:

<pre class="language-bash"><code class="lang-bash"><strong>sudo apt install net-tools
</strong></code></pre>

{% endhint %}

If port 53 is being used, in the output, you will see the name of the process that is using it.

For example, in the screenshot below, you can see that the `systemd-resolve` is listening on port 53.

<div align="left"><figure><img src="https://3559400189-files.gitbook.io/~/files/v0/b/gitbook-x-prod.appspot.com/o/spaces%2F0cTezbT2vN0lurEio8Z5%2Fuploads%2FyYY76n7xWvJ8rDhxb5ib%2Fsysd-resol.png?alt=media&#x26;token=69ce8433-ff8e-4b73-928c-251218bd7895" alt="Systemd-resolved listening on port 53"><figcaption></figcaption></figure></div>

In case the port is occupied, you will need to free it up by killing the other process which is using port 53 or changing its port to a different one.

### Free up port 53 used by systemd-resolve <a href="#free-up-port-53-used-by-systemd-resolve" id="free-up-port-53-used-by-systemd-resolve"></a>

Many Linux distributions use systemd-resolve for DNS query resolution. To disable the systemd-resolved service from binding to port 53:

1. Open Terminal.

2. Open the `resolved.conf` file using the Nano text editor by running this command:<br>

   ```bash
   sudo nano /etc/systemd/resolved.conf
   ```

3. At the end of the file, append this line:<br>

   ```bash
   DNSStubListener=no
   ```

   <div align="left"><figure><img src="https://3559400189-files.gitbook.io/~/files/v0/b/gitbook-x-prod.appspot.com/o/spaces%2F0cTezbT2vN0lurEio8Z5%2Fuploads%2FDx5EbfJnZprhBXKc5iQC%2Fdnsstub.png?alt=media&#x26;token=58e7c24a-c2e5-4172-a36d-594f9d20fa87" alt="DNSStubListener line"><figcaption></figcaption></figure></div>

4. Press **Ctrl** + **X**, **Y**, and **Enter** to save changes and exit.

5. Run the following command to restart the systemd-resolved process:<br>

   ```bash
   sudo systemctl restart systemd-resolved
   ```

## Install dnsmasq <a href="#install-dnsmasq" id="install-dnsmasq"></a>

To start configuring your DNS server, you will need to install dnsmasq on your machine.

1. Open Terminal.
2. Update all of your repositories and install dnsmasq by running the following command:<br>

   ```bash
   sudo apt update && sudo apt install dnsmasq
   ```

The dnsmasq application will be installed and started automatically.

## Configure dnsmasq <a href="#configure-dnsmasq" id="configure-dnsmasq"></a>

Dnsmasq settings are controlled via its configuration file called `dnsmasq.conf`.

1. Open the `dnsmasq.conf` file using the Nano text editor by running this command in Terminal:<br>

   ```bash
   sudo nano /etc/dnsmasq.conf
   ```

2. Using the **Ctrl** + **W** keyboard shortcut, locate and uncomment the following lines by removing the hash (#) symbol at the start:\
   • `domain-needed`\
   • `bogus-priv`\
   • `no-resolv`<br>

   <div align="left"><figure><img src="https://3559400189-files.gitbook.io/~/files/v0/b/gitbook-x-prod.appspot.com/o/spaces%2F0cTezbT2vN0lurEio8Z5%2Fuploads%2Fw9ZfPyI9Xwp8MKLNL7HE%2Fdomain_needed_bogus_priv.png?alt=media&#x26;token=4e190175-5789-4220-a6b3-ca979625eb0c" alt="domain-needed and bogus-priv lines"><figcaption></figcaption></figure></div>

   <div align="left"><figure><img src="https://3559400189-files.gitbook.io/~/files/v0/b/gitbook-x-prod.appspot.com/o/spaces%2F0cTezbT2vN0lurEio8Z5%2Fuploads%2Ft7y8QoF43bri7m1EZVUK%2Fno_resolv.png?alt=media&#x26;token=559bff79-2254-4d0d-ae60-723b984c8df0" alt="no-resolv line"><figcaption></figcaption></figure></div>

3. Find the `cache-size` line, uncomment it, and change the value to 1000.<br>

   <div align="left"><figure><img src="https://3559400189-files.gitbook.io/~/files/v0/b/gitbook-x-prod.appspot.com/o/spaces%2F0cTezbT2vN0lurEio8Z5%2Fuploads%2F7CJReAGLmbzoSwO4ZqgN%2Fcache_size.png?alt=media&#x26;token=9fef98b9-9f6b-444b-a63b-74e9fa7077bf" alt="cache-size line"><figcaption></figcaption></figure></div>

4. Locate the `interface` line, uncomment it, and append `nordlynx` after the equals (=) sign.<br>

   <div align="left"><figure><img src="https://3559400189-files.gitbook.io/~/files/v0/b/gitbook-x-prod.appspot.com/o/spaces%2F0cTezbT2vN0lurEio8Z5%2Fuploads%2F2TC6ZPlsjMFrb2vHcQnV%2Finterface.png?alt=media&#x26;token=4d94b841-6b2f-4e41-a755-d01e167a8928" alt="interface line with &#x27;nordlynx&#x27; appended"><figcaption></figcaption></figure></div>

5. Find the `#server=/localnet/192.168.0.1` line and replace it with the following two lines:<br>

   ```
   server=1.1.1.1
   server=8.8.8.8
   ```

   &#x20;

   <div align="left"><figure><img src="https://3559400189-files.gitbook.io/~/files/v0/b/gitbook-x-prod.appspot.com/o/spaces%2F0cTezbT2vN0lurEio8Z5%2Fuploads%2FxljPlyJvRBYUc9n3bj3w%2Fservers.png?alt=media&#x26;token=b67bef45-ae35-4372-88d3-fef15d7a0325" alt="Edited server lines"><figcaption></figcaption></figure></div>

   \
   Instead of the `1.1.1.1` and `8.8.8.8` DNS addresses, you can use your preferred DNS provider for the upstream DNS.

6. Press **Ctrl** + **X**, **Y**, and **Enter** to save changes and exit.

To ensure that the changes are applied, restart the dnsmasq process via the following command:

```bash
sudo systemctl restart dnsmasq
```

### Enable query logging (optional) <a href="#enable-query-logging-optional" id="enable-query-logging-optional"></a>

You can enable query logging in the `dnsmasq.conf` file to monitor for any failed DNS resolutions or inconsistencies in website loading.

1. Open Terminal and run the following command:<br>

   ```bash
   sudo nano /etc/dnsmasq.conf
   ```

2. Locate the `log-queries` line and uncomment it by removing the hash (#) symbol at the start.

3. Append a new `log-facility=/var/log/dnsmasq.log` line below `log-queries`.

   <div align="left"><figure><img src="https://3559400189-files.gitbook.io/~/files/v0/b/gitbook-x-prod.appspot.com/o/spaces%2F0cTezbT2vN0lurEio8Z5%2Fuploads%2FIkZhsDxQTCJ8kST3KO00%2Flog-queries.png?alt=media&#x26;token=224c302c-41b7-410c-8a5f-b1e8ec7043c6" alt="Lines for query logging"><figcaption></figcaption></figure></div>

4. Press **Ctrl** + **X**, **Y**, and **Enter** to save changes and exit.

5. Restart the dnsmasq process by running:<br>

   ```bash
   sudo systemctl restart dnsmasq
   ```

All of the DNS queries will now be logged in the `/var/log/dnsmasq.log` file.

## Test dnsmasq <a href="#test-dnsmasq" id="test-dnsmasq"></a>

To test if dnsmasq was configured properly and is working, do the following:

1. Open Terminal.

2. Run the following command to check the syntax in the `dnsmasq.conf` file:<br>

   ```bash
   dnsmasq --test
   ```

   <div align="left"><figure><img src="https://3559400189-files.gitbook.io/~/files/v0/b/gitbook-x-prod.appspot.com/o/spaces%2F0cTezbT2vN0lurEio8Z5%2Fuploads%2FHVLf2la9rdGJsFuJpalZ%2Ftest.png?alt=media&#x26;token=33002118-3c37-432c-8360-a87b68cc636d" alt="dnsmasq syntax check"><figcaption></figcaption></figure></div>

3. Install the `dnsutils` tool by running this command:<br>

   ```bash
   sudo apt install dnsutils
   ```

4. Check if the domain name resolution is working properly by using `dig`:<br>

   ```bash
   dig nordvpn.com @localhost
   ```

   <div align="left"><figure><img src="https://3559400189-files.gitbook.io/~/files/v0/b/gitbook-x-prod.appspot.com/o/spaces%2F0cTezbT2vN0lurEio8Z5%2Fuploads%2F5PzdvpE6jpeLafKIygFD%2Fdig.png?alt=media&#x26;token=25b16ea3-ac61-4158-b70e-7b87d3d452d5" alt="Output of the &#x27;dig&#x27; command"><figcaption></figcaption></figure></div>

If you receive an answer to the `dig` command, it indicates that your DNS server is working properly and ready for use.
{% endtab %}
{% endtabs %}

## Use your dnsmasq DNS over Meshnet <a href="#change-dns-addresses" id="change-dns-addresses"></a>

With dnsmasq fully set up, you can start using it on your devices. For usage via Meshnet, you must set the server device’s Meshnet IP address as the DNS server on each client device.

{% tabs %}
{% tab title="Windows" %}

### Windows 11 <a href="#windows-11" id="windows-11"></a>

1. Right-click **Start**![](https://3559400189-files.gitbook.io/~/files/v0/b/gitbook-x-prod.appspot.com/o/spaces%2F0cTezbT2vN0lurEio8Z5%2Fuploads%2FOtP5XWC64gJfapJxZksb%2Fwindows_start_11.svg?alt=media\&token=ba30bb06-e18d-4b98-890f-1a16c24b24db) and select **Network connections**.
2. Choose the network type your device is using (Wi-Fi or Ethernet).
3. Find the **DNS server assignment** option and click **Edit**.
4. Choose **Manual** from the dropdown menu and enable **IPv4**.
5. Fill in the DNS fields.\
   • Under **Preferred DNS**, enter the Meshnet IP of the dnsmasq device.\
   • Under **Alternate DNS**, enter the DNS address of another provider.

   ![dnsmasq and alternate DNS addresses entered in Windows settings.](https://3559400189-files.gitbook.io/~/files/v0/b/gitbook-x-prod.appspot.com/o/spaces%2F0cTezbT2vN0lurEio8Z5%2Fuploads%2Fj12OVBv64jkwptE5CKIP%2Fimage.png?alt=media\&token=c362d7e9-a788-4383-9055-254afe36ffd9)

   &#x20;
6. Click **Save**.

### Windows 10 <a href="#windows-10" id="windows-10"></a>

1. Right-click **Start**![](https://3559400189-files.gitbook.io/~/files/v0/b/gitbook-x-prod.appspot.com/o/spaces%2F0cTezbT2vN0lurEio8Z5%2Fuploads%2FVSqL9yfpIONQtu4tl0pI%2Fwindows_start_10.svg?alt=media\&token=9b75053d-e0d8-4a6e-8624-51f60b0fd3b2) and select **Network connections**.

2. Select **Change adapter options**.

3. Right-click your current network adapter (Wi-Fi or Ethernet) and choose **Properties**.

4. In the new window, select **Internet Protocol Version 4 (TCP/IPv4)** and click **Properties**.

5. Select **Use the following DNS server addresses** and fill in the fields underneath.

   * **Preferred DNS server**: the Meshnet IP of the dnsmasq device.
   * **Alternate DNS server**: the DNS address of another provider.

   &#x20;

   <div align="left"><figure><img src="https://3559400189-files.gitbook.io/~/files/v0/b/gitbook-x-prod.appspot.com/o/spaces%2F0cTezbT2vN0lurEio8Z5%2Fuploads%2FnuJqdUzw289LIRPcvZsq%2Fimage.png?alt=media&#x26;token=d0165b59-5060-4dba-b822-45b482147d1b" alt="dnsmasq and alternate DNS addresses entered."><figcaption></figcaption></figure></div>

6. Click **OK** twice to apply the changes.
   {% endtab %}

{% tab title="Android" %}

1. Open the **Settings** menu.
2. Go to **Connections** and select **Wi-Fi**.
3. Find your current Wi-Fi network and tap the gear button.
4. Go to **Advanced**/**View more**.
5. Change the **IP settings** value to **Static**.
6. Fill in the required DNS addresses:\
   \
   Under **DNS 1**, enter the Meshnet IP of the dnsmasq device.\
   Under **DNS 2**, enter the DNS address of another provider.<br>

   ![dnsmasq and alternate DNS entered in Android settings.](https://3559400189-files.gitbook.io/~/files/v0/b/gitbook-x-prod.appspot.com/o/spaces%2F0cTezbT2vN0lurEio8Z5%2Fuploads%2FCGYSQVo4rpWTJYAXg7Zw%2Fimage.png?alt=media\&token=67f7e47f-06ed-40db-bb99-19bbed5ef50a)

   &#x20;
7. Tap **Save** (if such a button is present).
   {% endtab %}

{% tab title="iOS" %}

1. Open **Settings**.
2. Tap **Wi-Fi**, find your current network, and tap the Info![](https://3559400189-files.gitbook.io/~/files/v0/b/gitbook-x-prod.appspot.com/o/spaces%2F0cTezbT2vN0lurEio8Z5%2Fuploads%2FwzE1Q17LTv7SC9DLtPaZ%2Finfo.svg?alt=media\&token=3906cd76-81b4-4a74-bf22-1d7de4b5c8c5) button.
3. Tap **Configure DNS** and choose **Manual**.
4. Select **Add server** and enter the Meshnet IP of the dnsmasq device.<br>

   ![dnsmasq Meshnet IP entered in iOS DNS settings.](https://3559400189-files.gitbook.io/~/files/v0/b/gitbook-x-prod.appspot.com/o/spaces%2F0cTezbT2vN0lurEio8Z5%2Fuploads%2FhLqoIIENCSocHjMmBpxZ%2Fimage.png?alt=media\&token=5b80dff5-f17b-4ee8-ba86-b297f3c01df9)

   &#x20;
5. Ensure that the added IP address is at the top.
6. Tap **Save**.
   {% endtab %}

{% tab title="macOS" %}

### macOS Ventura 13 and newer <a href="#macos-ventura-version-13-and-newer" id="macos-ventura-version-13-and-newer"></a>

1. Go to **System settings** and click **Network**.

2. Select the network interface you use (Wi-Fi or Ethernet) and click **Details**.

3. Open the **DNS** tab and click the plus (+) button at the bottom to add the Meshnet IP address of the dnsmasq device.

4. Ensure that the added IP address is at the top.<br>

   <figure><img src="https://3559400189-files.gitbook.io/~/files/v0/b/gitbook-x-prod.appspot.com/o/spaces%2F0cTezbT2vN0lurEio8Z5%2Fuploads%2Fc07NGJ99bM97mgMKYIMI%2Fimage.png?alt=media&#x26;token=ffb832ec-6211-4331-9a2e-d805515249fe" alt="dnsmasq Meshnet IP entered in macOS DNS settings."><figcaption></figcaption></figure>

5. Click **OK** to save the changes.

### macOS Monterey 12 and older <a href="#macos-monterey-version-12-and-older" id="macos-monterey-version-12-and-older"></a>

1. Go to **System preferences** and click **Network**.

2. Select the network interface you use (Wi-Fi or Ethernet) and click **Advanced.**

3. Open the **DNS** tab and add the Meshnet IP address of the dnsmasq device by clicking the plus (+) icon.

4. Ensure that the added IP address is at the top.

   <div align="left"><figure><img src="https://3559400189-files.gitbook.io/~/files/v0/b/gitbook-x-prod.appspot.com/o/spaces%2F0cTezbT2vN0lurEio8Z5%2Fuploads%2FwqSMP0h9WG5GTrq3K4D5%2Fimage.png?alt=media&#x26;token=36fbd3ab-107c-4e1a-8bd6-77e796ac70fc" alt="dnsmasq Meshnet IP entered in macOS DNS settings."><figcaption></figcaption></figure></div>

5. Click **OK** and then click **Apply**.
   {% endtab %}

{% tab title="Linux" %}

### Method 1: Using Network Manager <a href="#linux-gui" id="linux-gui"></a>

1. Open **Settings**, and then select either **Network** or **Wi-Fi** based on your network type.

2. Click the gear button and go to the **IPv4** tab.

3. Next to **DNS**, disable the **Automatic** toggle.

4. In the **DNS** field, enter the Meshnet IP of the dnsmasq device and the DNS of another provider, separated by a comma.<br>

   <div align="left"><figure><img src="https://3559400189-files.gitbook.io/~/files/v0/b/gitbook-x-prod.appspot.com/o/spaces%2F0cTezbT2vN0lurEio8Z5%2Fuploads%2FW43YYlrt8eaC1YFozXAH%2Fimage.png?alt=media&#x26;token=09497bbb-c5f4-4084-ac31-b3688f46ade1" alt="dnsmasq Meshnet IP and alternate DNS address entered in Linux network settings."><figcaption></figcaption></figure></div>

5. Click **Apply**.

6. Open **Terminal** and run the following command to restart the Network Manager daemon:<br>

   <pre class="language-bash" data-overflow="wrap"><code class="lang-bash">sudo systemctl restart NetworkManager
   </code></pre>

7. Enter your sudo password.&#x20;

### Method 2: Using Terminal <a href="#linux-cli" id="linux-cli"></a>

1. Open **Terminal** and run the following command:<br>

   <pre class="language-bash" data-overflow="wrap"><code class="lang-bash">sudo nano /etc/systemd/resolved.conf
   </code></pre>

2. Locate the `DNS` and `FallbackDNS` lines.

3. Uncomment the lines by removing the hash (#) symbols.

4. Enter the appropriate DNS addresses after the equals (=) sign, as shown:\
   \
   `DNS=<Meshnet IP of the dnsmasq device>`\
   `FallbackDNS=<DNS of another provider>`

   <div align="center"><figure><img src="https://3559400189-files.gitbook.io/~/files/v0/b/gitbook-x-prod.appspot.com/o/spaces%2F0cTezbT2vN0lurEio8Z5%2Fuploads%2FU8O1pQ8hs46Gw5XNKopT%2Flinux_dns_change.png?alt=media&#x26;token=b7647373-1ff0-441d-9c55-0fb5a85d584a" alt="Changed DNS on Linux"><figcaption></figcaption></figure></div>

5. Press **Ctrl** + **X**, **Y**, and **Enter** to exit and save the changes.

6. Run the following command to ensure that the network changes are applied:<br>

   ```bash
   sudo systemctl restart systemd-resolved
   ```

7. Enter your sudo password.&#x20;

{% hint style="info" %}
**Note**

Changes in the `/etc/systemd/resolved.conf` file take priority over settings in the Network Manager. Therefore, if you apply the DNS change directly via the Network Manager settings, ensure that there are no custom configurations in the previously mentioned `resolved.conf` file. Otherwise, the specified DNS addresses will not be used.
{% endhint %}
{% endtab %}
{% endtabs %}

{% hint style="success" %}
**Tip**

If you're looking for alternate DNS addresses, here are some of the most popular free DNS providers:

* Google — 8.8.8.8 and 8.8.4.4
* Cloudflare — 1.1.1.1 and 1.0.0.1
* Adguard — 176.103.130.130 and 176.103.130.131
* Quad9 — 9.9.9.9 and 149.112.112.112
* OpenDNS — 208.67.222.222 and 208.67.220.220

You can also use the same upstream DNS addresses from the `dnsmasq.conf` file.
{% endhint %}

With the DNS changes applied, you have finished the setup process. Your personal DNS server can now be used remotely, with the help of Meshnet.
