How Do I Set Up a New DNS Server?


Scott Campbell

How Do I Set Up a New DNS Server?

Setting up a new DNS server can seem like a daunting task, but with the right guidance, it can be a relatively straightforward process. In this tutorial, we will walk you through the steps involved in setting up your own DNS server.

Step 1: Choose a DNS Server Software

There are several popular DNS server software options available, including BIND (Berkeley Internet Name Domain), PowerDNS, and NSD (Name Server Daemon). Each software has its own unique features and configuration requirements.

In this tutorial, we will focus on setting up a DNS server using BIND, which is one of the most widely used DNS software.

Step 2: Install BIND

To install BIND on your server, follow these steps:

  • Open a terminal or shell prompt on your server.
  • Type the command to install BIND. For example, if you are using Ubuntu, you can use the following command: sudo apt-get install bind9.
  • Wait for the installation to complete.

Step 3: Configure BIND

Once BIND is installed, you need to configure it to act as your DNS server. Here’s how:

  • Navigate to the BIND configuration directory. On most Linux distributions, this directory is located at /etc/bind/.
  • Edit the main configuration file named named.conf.

    This file contains all the necessary settings for your DNS server.

  • Add or modify the zone configurations in the file. Zones define how your DNS server will handle different domains and subdomains.

Example Zone Configuration:

Here’s an example of a zone configuration for a domain named

zone "" {
  type master;
  file "/etc/bind/zones/";

In this example, we define a master zone for The zone file location is specified as /etc/bind/zones/

Step 4: Create Zone Files

Zone files contain the actual DNS records for your domains. To create a zone file:

  • Navigate to the directory specified in your zone configuration (/etc/bind/zones/ in our example).
  • Create a new file with the same name as your zone file location ( in our example).
  • Edit the zone file and add the necessary DNS records, such as A records, CNAME records, and MX records.

Example Zone File:

$TTL    86400
@       IN      SOA     ns1.example. admin. (
                        2022122201 ; Serial
                        3600       ; Refresh
                        1800       ; Retry
                        604800     ; Expire
                        86400 )    ; Minimum TTL

        IN      NS      ns1.
        IN      NS      ns2.

ns1     IN      A
ns2     IN      A       192.20

www     IN      A       192.30
mail    IN      A       192.40

In this example, we define the Start of Authority (SOA) record, nameservers (NS) records, and some A records for the domain example.

Step 5: Start BIND Service

Once your DNS server is configured and the zone files are created, you can start the BIND service by running the appropriate command for your operating system.

  • If you are using Ubuntu or Debian, use: sudo systemctl start bind9.
  • If you are using CentOS or Fedora, use: sudo systemctl start named.

Step 6: Test Your DNS Server

To ensure that your DNS server is working correctly, you can perform a few tests:

  • Use the dig command to query your DNS server for specific records.
  • Update your computer's DNS settings to point to your new DNS server and verify that it resolves domain names correctly.
  • Use online DNS testing tools to check the status and functionality of your DNS server.

Congratulations! You have successfully set up a new DNS server using BIND.

Note: Remember to regularly update and maintain your DNS server to ensure optimal performance and security.