top of page
Writer's pictureNOURA ALSHAREEF

Set your own DNS server

In a previous article, we discussed the concept and importance of DNS resolver servers. In this article, we will delve into the process of setting up a DNS resolver server on a Linux machine. It's important to note that the steps may vary depending on the Linux distribution you are using. For the purpose of this article, we will focus on Debian.


Step 1: Install bind9
sudo apt-get install bind9

Step 2: Configure bind9 as the primary DNS server

Edit the named.conf configuration file located in the /etc/bind/ directory. Use your preferred text editor to open the file.

vim  /etc/bind/named.conf.local

Within the named.conf file, you will need to configure the zone for your domain and specify the file where you will store the DNS records. In my scenario, I have created two distinct zones: one for my database servers and another for my application servers.

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

zone "api.noratech" {
    type master;
    file "/etc/bind/api.noratech";
};

Step 3: Create the zone files

let's create the db.noratech config file

sudo vim /etc/bind/db.noratech

Then write the following :

$TTL 86400
@   IN  SOA ns1.dns.noratech. admin.db.noratech. (
    2022021201  ; Serial
    3600        ; Refresh
    1800        ; Retry
    604800      ; Expire
    86400       ; Minimum TTL
)
@   IN  NS  ns1.dns.noratech.
@   IN  NS  ns2.dns.noratech.

ns1.dns.noratech.  IN  A   <DNS-resolver-IP>
ns2.dns.noratech.  IN  A   <DNS-resolver-IP>

<yourDbName>     IN  A   <yourDbIP>
<yourDbName>     IN  A   <yourDbIP>

In the provided DNS configuration snippet, the $TTL directive is responsible for setting the time-to-live value for the DNS records. If you would like to understand the other directives and their significance in more detail, I recommend referring to our previous article "How DNS Resolver Works."


Additionally, the A records play a crucial role in associating DNS names with their corresponding IP addresses. To customize the configuration for your specific setup, replace <DNS-resolver-IP> with the IP address of your DNS resolver server.


Similarly, substitute <yourDbName> with the desired name for your database server, and replace <yourDbIP>with the appropriate IP address assigned to your database server.


Don't forget to do the same with api.noratech


Step 4: Verify your configurations

Check the syntax using the following command:

named-checkconf

Restart the bind9 service:

systemctl restart bind9

To check the functionality, you can use the following command:

dig @<DNS-resolver-IP> <yourDbName>.db.noratech

These steps will help you set up a standalone DNS resolver server on your Linux machine.


Step 5: Test from a client machine

Now let's test it from a client machine running macOS, you can change the DNS configuration in the System Preferences. Here's how you can do it:


System Preferences > Network > select Wifi ( or Ethernet ) > Advanced > DNS > + > add the IP address of your DNS resolver server > OK


 

Then try to call your app server through curl or a browser.


That's a wrap!

We hope you found this article helpful in setting your own DNS Resolver


22 views0 comments

Recent Posts

See All

Opmerkingen


bottom of page