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

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

; BIND data file for
$TTL    3h
@       IN      SOA (
                          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
@       IN      NS    IN      MX      10    IN      A
ns1                     IN      A
ns2                     IN      A
www                     IN      CNAME
mail                    IN      A
ftp                     IN      CNAME

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 "" {
       type master;
       file "/etc/bind/zones/";

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 {;

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

named-checkzone /etc/bind/zones/

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
Notify of
Inline Feedbacks
View all comments
Would love your thoughts, please comment.x