How to Add New Domains to BIND DNS Server

DNS (Domain Name System) Server is an essential part to any computer network. So, it is always suggest keeping a DNS Server in every network. How to configure a DNS Server with BIND package was discussed in my previous article. A common question among the fresher admins of BIND DNS is how to add a new domain to BIND DNS Server. For this, this article is designed to discuss the proper way to add multiple domains to BIND DNS Server.

Adding New Domain to BIND DNS Server

The DNS zone file contains a specific domain/subdomain collection in BIND DNS Server. Each domain may have its own zone file or multiple domains may use one global zone file. So, new domain in BIND DNS Server can be added following the below two methods.

  • Adding new domain using one global zone file or
  • Adding new domains using its own zone file.

I configured a DNS server with BIND package (in my previous article) with the following information.

  • Domain name:net
  • FQDN:systemzone.net
  • Nameserver:systemzone.net
  • Host IP:168.40.100
  • Forward Zone File:net.for
  • Reverse Zone File:net.rev

We will now add a new domain in this BIND DNS Server according to the following information.

  • Domain name:com
  • Nameserver:systemzone.com
  • Host IP:168.40.101 (systemzone.com domain point to this IP address)
  • FQDN:systemzone.com

Method 1: Adding New Domain Using One Global Zone File

According to the previous DNS Server configuration with BIND package, the global zone file is systemzone.net.for. So, we will use this global zone file to keep new domains’s DNS Resource Records (RRs). To add a new domain that will use one global zone file, we have to edit the following two files.

  • Zone file to insert new domain and
  • Global zone file to keep new domain’s RRs.

Editing Zone File to Insert New Domain

According to the previous DNS Server configuration, DNS Zone entries are kept in the named.rfc1912.zones file. So, open this file and put the following lines to insert new domain (systemzone.com).

[root@ns1 ~]# vim /etc/named.rfc1912.zones

 

zone “systemzone.com” IN {

type master;

file “systemzone.net.for”;

allow-update { none; };

};

Note that the new domain (systemzone.com) and the old domain (systemzone.net) are pointing the same forward zone file (systemzone.net.for).

Editing Global Zone File to Keep New Domain’s Resource Records

According to our previous DNS configuration, the global forward zone file is systemzone.net.for. Currently, the forward zone file looks like below.

[root@ns1 named]# cat sytemzone.net.for

 

$TTL 1D

$ORIGIN systemzone.net.

@       IN SOA  ns1.systemzone.net. root.systemzone.net. (

0       ; serial

1D      ; refresh

1H      ; retry

1W      ; expire

3H )    ; minimum

@       IN NS ns1.systemzone.net.

@       IN A 192.168.40.100

ns1     IN A 192.168.40.100


Now open this forward zone file and modify this according to the following lines and then save and exit the file.

[root@ns1 named]# vim sytemzone.net.for

 

$TTL 1D

@       IN SOA  ns1.systemzone.net. root.systemzone.net. (

0       ; serial

1D      ; refresh

1H      ; retry

1W      ; expire

3H )    ; minimum

@       IN NS ns1.systemzone.net.

$ORIGIN systemzone.net.

@       IN A 192.168.40.100

ns1     IN A 192.168.40.100

$ORIGIN systemzone.com.

@        IN A 192.168.40.101

www      IN A 192.168.40.101

webserver IN A 192.168.40.101

In the above lines, we have changed the $ORIGIN directive’s position for systemzone.net domain as well as we have added a new $ORIGIN directive for systemzone.com domain and have kept three host entries for the systemzone.com pointed server.

So, the above two steps describe how to add new domain to BIND DNS Server using global zone file. We will now see another method to add a new domain in BIND DNS Server.

Method 2: Adding New Domain Using Its Own Zone File 

New domain in BIND DNS Server can be added creating a new zone file for that domain. In this case, we have to also insert new domain in zone file as well as have to create a new zone file for that domain. So, adding new domain in BIND DNS Server by creating new zone file can also be divided into the following two steps.

  • Inserting new domain in BIND zone file and
  • Creating new zone file for that domain.

Inserting New Domain in BIND Zone File

According to the previous DNS Server configuration, DNS Zone entries are kept in the named.rfc1912.zones file. So, open this file and put the following lines to insert new domain (systemzone.com).

[root@ns1 ~]# vim /etc/named.rfc1912.zones

 

zone “systemzone.com” IN {

type master;

file “systemzone.com.for”;

allow-update { none; };

};

Note that the new domain (systemzone.com) is now pointing a new forward zone file (systemzone.com.for) for its DNS Resource Records. So, we will now create this forward zone file and keep RRs for the new domain.

Creating New Zone File for New Domain

As we have declared new zone file for the new domain, we have to create this file now. So, issue the following command to create the declared forward zone file in the default BIND directory.

[root@ns1 named]# touch systemzone.com.for

As this file has been created with the  root user, we have to change group permission to named user. Otherwise BIND cannot access this file. To change group permission, issue the following command.

[root@ns1 named]# chgrp named systemzone.com.for

Now open the new forward zone file and insert the following lines and then save and exit the file.

[root@ns1 named]# vim systemzone.com.for

 

$TTL 1D

$ORIGIN systemzone.com.

@       IN SOA  ns1.systemzone.net. root.systemzone.com. (

0       ; serial

1D      ; refresh

1H      ; retry

1W      ; expire

3H )    ; minimum

@       IN NS ns1.systemzone.net.

@       IN A 192.168.40.101

www     IN A 192.168.40.101

webserver  IN A 192.168.40.101

Adding new domain using its own zone file has been completed. It is always suggest adding a reverse DNS record (PTR) for every Host entry. According to the previous DNS configuration, the reverse zone file is systemzone.net.for. So, open this file and put the following PTR record at the bottom and then save and exit the file.

101     IN PTR webserver.systemzone.com.

Now restart the BIND service and test your configuration.

[root@ns1 named]# systemctl restart named

Testing New Domain Entry

After adding new domain to BIND DNS Server successfully, we can now test domain entry with the following nslookup tool.

[root@ns1 named]# nslookup systemzone.com

 

Server:         192.168.40.100

Address:        192.168.40.100#53

Name:   systemzone.com

Address: 192.168.40.101

If you get the above result, your configuration for adding a new domain to BIND DNS Server has been completed successfully. Similarly, you can add as many domains as you want in your BIND DNS Server following the above methods.

If you face any confusion to follow the above steps properly, watch the below video about adding new domain to BIND DNS Server. I hope it will reduce your any confusion.

How to add new domains to BIND DNS Server has been discussed in this article. I hope you will  now be able to add your desired domain in your BIND DNS Server. However, if you face any confusion to follow the above steps properly, feel free to discuss in comment or contact me from Contact page. I will try my best to stay with you.

Why not a Cup of COFFEE if the solution?

how-to-add-new-domains-to-bind-dns-server

ABU SAYEED

I am a system administrator and like to share knowledge that I am learning from my daily experience. I usually work on MikroTik, Redhat/CentOS Linux, Windows Server, physical server and storage, virtual technology and other system related topics. Follow Me: Facebook, Twitter and Linkedin.

Your name can also be listed here. Have an IT topic? Submit it here to become a System Zone author.

Leave a Reply

Your email address will not be published. Required fields are marked *

*