How Do I Setup a Custom DNS Server?


Larry Thompson

Setting up a Custom DNS Server


Setting up a custom DNS server can be a powerful solution for managing and controlling your network’s domain name resolution. With a custom DNS server, you can have more control over your network’s DNS queries, improve performance, and enhance security. In this tutorial, we will guide you through the process of setting up your own custom DNS server.


Before we begin, make sure you have the following prerequisites in place:

  • A dedicated server or a virtual private server (VPS)
  • A Linux operating system (such as Ubuntu or CentOS)
  • Root access to the server

Step 1: Installing BIND

The first step in setting up a custom DNS server is to install BIND (Berkeley Internet Name Domain), which is the most widely used DNS software on the internet. To install BIND on your Linux server, follow these steps:

  1. Open your terminal or SSH into your server.
  2. Update the package list using the command: sudo apt update (for Ubuntu) or sudo yum update (for CentOS).
  3. Install BIND by running the command: sudo apt install bind9 (for Ubuntu) or sudo yum install bind bind-utils -y (for CentOS).

Step 2: Configuring BIND

Once BIND is installed, you need to configure it to act as your custom DNS server. Here are the steps to configure BIND:

  1. Navigate to the BIND configuration directory using the command: cd /etc/bind.
  2. Edit the named.conf.options file using a text editor of your choice. For example, you can use the command: sudo nano named.options.
  3. Within the file, locate the forwarders directive and add the IP addresses of your preferred DNS resolvers.

    These resolvers will be used for external DNS queries. For example:

    forwarders {
  4. Save and exit the file.

Step 3: Creating Zone Files

Now it’s time to create zone files for your custom DNS server. Zone files contain the mapping between domain names and IP addresses.

  1. Create a forward zone file by running the command: sudo nano /etc/bind/
  2. Add the following content to the file, replacing “” with your own domain name:
    $TTL    86400
    @       IN      SOA admin. 
                            2022010101 ; Serial
                            3600       ; Refresh
                            1800       ; Retry
                            604800     ; Expire
                            86400      ; Minimum TTL
    @       IN      NS      ns1. ns1     IN      A       YOUR_SERVER_IP_ADDRESS 
    www     IN      A       YOUR_SERVER_IP_ADDRESS
    mail    IN      A       YOUR_SERVER_IP_ADDRESS

    Don’t forget to replace “YOUR_SERVER_IP_ADDRESS” with your server’s IP address.

  3. Save and exit the file.
  4. Create a reverse zone file by running the command: sudo nano /etc/bind/" with your own domain name and "YOUR_SERVER_IP_ADDRESS" with your server's IP address:
    $TTL    86400
    @ IN SOA ns1. @ IN PTR ns1.


    Don't forget to replace "YOUR_SERVER_IP_ADDRESS" and "" accordingly.

Step 4: Restarting BIND

After configuring the zone files, you need to restart BIND for the changes to take effect. Run the following command to restart BIND:

sudo systemctl restart bind9

Step 5: Updating DNS Settings

The final step is to update your DNS settings to start using your custom DNS server. This can typically be done through your domain registrar or DNS hosting provider. Point your domain's nameservers to your custom DNS server's IP address (

Note: It may take some time for the DNS changes to propagate across the internet.


You have successfully set up your own custom DNS server. You now have more control over your network's domain name resolution and can enjoy the benefits of improved performance and enhanced security.


In this tutorial, we have covered the step-by-step process of setting up a custom DNS server. We started by installing BIND, configuring it, creating zone files, restarting BIND, and finally updating DNS settings. By following these steps, you can take control of your network's DNS resolution and optimize it according to your specific needs.