https://pimylifeup.com/raspberry-pi-dns-server/

Setting up a DNS Server on the Raspberry Pi

1. In this tutorial, we will be making use of the Raspbian operating system. Other operating systems might work, but is not guaranteed.

Before we can set up our Raspberry Pi as a DNS server, we must ensure everything is up to date.

We can do this by running the following two commands on our Raspberry Pi.

sudo apt update
sudo apt upgrade

2. Once the update has completed, we can proceed to install the software that we will be using to setup our Pi as a DNS server.

This software package that we are installing is called DNSmasq. DNSmasq is a lightweight and straightforward DNS server that was designed with small-scale networks in mind.

Thanks to its lightweight nature, DNSmasq is the perfect solution for setting up a DNS server on a Raspberry Pi as it won’t drain its limited resources.

We can install dnsmasq to our Raspberry Pi by running the following command.

sudo apt install dnsmasq

Configuring the DNS Server

1. Now that we have gone ahead and installed the dnsmasq software to our Raspberry Pi, we should now make some configuration changes to it.

The changes that we will make to its configuration file will allow your Raspberry Pi to work as a better DNS server.

We can begin making modifications to the file by running the following command.

sudo nano /etc/dnsmasq.conf

To find the sections that you are after easier, you can make use of CTRL + W to search for the required text.

Find

#domain-needed

Replace with