How Do I Make My Raspberry Pi a DNS Server?


Heather Bennett

If you’re looking to set up your Raspberry Pi as a DNS server, you’ve come to the right place! In this tutorial, we will guide you through the process step by step. So let’s get started!

What is DNS?

DNS stands for Domain Name System. It is a system that translates domain names (such as into IP addresses (such as that computers can understand. Essentially, DNS acts as a phonebook of the internet, allowing us to access websites using human-readable domain names instead of remembering complex IP addresses.

Why Set Up a DNS Server on Raspberry Pi?

Setting up a DNS server on your Raspberry Pi can have several advantages:

  • Improved Network Performance: By running your own DNS server, you can reduce network latency and improve response times for accessing websites.
  • Filtering and Blocking: With your own DNS server, you have control over what content is accessible on your network. You can filter out unwanted websites or block specific categories.
  • Privacy: Using your own DNS server ensures that your browsing activity remains private and not tracked by third-party DNS providers.


To set up a Raspberry Pi as a DNS server, you will need the following:

  • A Raspberry Pi (any model should work)
  • An SD card with Raspbian or any other compatible operating system installed
  • A stable internet connection

Step 1: Update Your Raspberry Pi

The first step is to ensure that your Raspberry Pi is running the latest software packages. Open a terminal and run the following commands:

  sudo apt update
  sudo apt upgrade

Step 2: Install DNS Server Software

Next, we need to install the DNS server software on our Raspberry Pi. The most popular DNS server software for Linux is called BIND (Berkeley Internet Name Domain). To install BIND, run the following command in your terminal:

sudo apt install bind9

Step 3: Configure BIND

Once BIND is installed, we need to configure it. The main configuration file for BIND is located at /etc/bind/named.conf.options. Open this file using your preferred text editor:

sudo nano /etc/bind/named.options

In this file, you will find various options related to the DNS server configuration. Look for the following section:

  // forwarders {
  //      ..
  // };

To use your ISP’s DNS servers or any other public DNS servers, uncomment the “forwarders” section and add their IP addresses within curly brackets. For example:

  forwarders {

Note: Here, we have used Google’s public DNS servers (8.8 and 8.4) as an example.

Step 4: Create a Forward Zone File

The next step is to create a forward zone file, which will contain the DNS records for the domains you want to resolve. Create a new file called in the /etc/bind/ directory:

sudo nano /etc/bind/example.db

Add the following content to the file:

  $TTL 86400
  @       IN      SOA     ns1.example. admin. (
                                38400 )

  @       IN      NS      ns1.

  ns1     IN      A       YOUR_PI_IP_ADDRESS

  www     IN      A       DESTINATION_IP_ADDRESS

Note: Replace YOUR_PI_IP_ADDRESS with your Raspberry Pi’s IP address and DESTINATION_IP_ADDRESS with the IP address of the server or device you want to point the domain name ‘’ to.

Step 5: Update BIND Configuration

We need to update BIND’s configuration file to include our newly created forward zone file. Open /etc/bind/named.local:

sudo nano /etc/bind/named.local

Add the following line at the end of this file:

 zone "" {
         type master;
         file "/etc/bind/example.db";

Step 6: Restart BIND Service

To apply the changes, restart the BIND service by running:

sudo service bind9 restart

Step 7: Configure Client Devices

Finally, to use your Raspberry Pi as the DNS server, you need to configure the DNS settings on your client devices. Navigate to the network settings and set the DNS server address to your Raspberry Pi’s IP address.

That’s it! You have successfully set up your Raspberry Pi as a DNS server. You can now test it by accessing the domain names you have configured in your forward zone file.


In this tutorial, we have learned how to transform a Raspberry Pi into a DNS server using BIND. Running your own DNS server can provide faster response times, enhanced privacy, and custom content filtering on your network. Now you can take full control over your domain name resolutions and enjoy a more efficient internet experience!

Discord Server - Web Server - Private Server - DNS Server - Object-Oriented Programming - Scripting - Data Types - Data Structures

Privacy Policy