How To Create Domain Nameserver Using SSH CentOS 7

In this tutorial I will try to walk you through the process of creating new domain nameserver for your VPS or dedicated server. In order to achive this you will need SSH access, in this tutorial I will use PUTTY and centos 7. First thing we have to do is to install the bind utilities using yum. I will show a little below how to do that. After that there are few settings we have to do in order to create the nameservers with all DNS records. You have to login in putty as root, in order to have the right permissions.

Create Domain Nameserver Using ssh

First of all let's install the bind utilities, to do that run the following command in putty:

yum install bind bind-utils -y

The above command will install it, if it is already installed, it will return a message where it says that the package is already installed.

Now, we have to find the bind folder or named folder. This can depends on your OS version. Try the followind command in shell cd /etc/bind - if it return that the folder does not exists, this mean your centos version is a new one so we will use the following command:

cd /etc/named

Here we will have to create a new folder:

mkdir -p zones

In this folder we will create a new file:

cd zones
nano my-domain.com

The above commands will open the zones folder, and the second command will create a new file named: my-domain.com. In this file we will add the following bunch of code:

;
; BIND data file for my-domain.com
;
$TTL    3h
@       IN      SOA     ns1.my-domain.com. admin.my-domain.com. (
                          1        ; Serial
                          3h       ; Refresh after 3 hours
                          1h       ; Retry after 1 hour
                          1w       ; Expire after 1 week
                          1h )     ; Negative caching TTL of 1 day
;
@       IN      NS      ns1.my-domain.com.
@       IN      NS      ns2.my-domain.com.


my-domain.com.    IN      MX      10      my-domain.com.
my-domain.com.    IN      A       153.92.211.22
ns1                     IN      A       153.92.211.22
ns2                     IN      A       153.92.211.22
www                     IN      CNAME   my-domain.com.
mail                    IN      A       153.92.211.22
ftp                     IN      CNAME   my-domain.com.

Please don't forget to replace my-domain and this IP address with yours. 

The next step is to create a new file in named folder, to do that, we will go again to this folder using cd /etc/named or cd /etc/bind that's depends on your OS version.

Once we are in named folder run the following command:

nano named.conf.local

And add the following code:

zone "my-domain.com" {
       type master;
       file "/etc/bind/zones/my-domain.com";
};

Don't forget to replace the domain with yours. And create a new file using the following command:

nano named.conf.options

Where we will add the folowing code:

forwarders {
   8.8.4.4;
};

That's it, now we can check our configuration using the following command:

named-checkzone my-domain.com /etc/bind/zones/my-domain.com

And finally we have to restart the named service using this command:

systemctl restart named

Let me know if you need any help in comments section.

 

0 0 votes
Article Rating
Subscribe
Notify of
guest
0 Comments
Inline Feedbacks
View all comments
0
Would love your thoughts, please comment.x
()
x