With the help of a control panel it is very easy to setup name-servers on any server. Here,  I am explaining how to setup nameservers on centos/rhel servers without using a control panel.

Step 1 : Setting up nameservers

Checking the version of centOS

[[email protected]]# cat /etc/redhat-release
CentOS release 6.2 (Final)

[[email protected]]# uname -a
Linux server.2adesigns.com 2.6.18-308.8.2.el5.028stab101.1 #1 SMP Sun Jun 24 20:25:35 MSD 2012 x86_64 x86_64 x86_64 GNU/Linux

I recently bought two vps and wanted one of them as a hosting server for my website 2adesigns.com and also setup private nameservers on it.

We can now start installing bind software. Since i have root access to vps server i will try to do everything as root user.

Install bind server with the below command

[[email protected]]# yum install bind

Checking the installed bind version

[[email protected] named]# rpm -qa bind

If you may want to consider installing bind-utils to do nslookup,dig,host

[[email protected]]# yum install bind-utils

Now we can configure named.conf by adding zones.

[[email protected]]# vi /etc/named.conf

Go ahead and add the server ip to listen on port 53
options {
        listen-on port 53 {;; };
Also change
 allow-query     { localhost; };
 allow-query     { any; };

Now start entering zones at the end of named.conf

zone "server.2adesigns.com" {
type master;
file "/var/named/server.2adesigns.com.db";
zone "2adesigns.com" {
type master;
file "/var/named/2adesigns.com.db";

Here you can see that i have added two zones one for my server hostname and other for the domain itself.

Now we will go to /var/named/ directory and start creating files we pointed in /etc/named.conf file.

[[email protected] named]# vi server.2adesigns.com.db

To make thing faster i’m going to redirect contents of named.loopback file found in /var/named/ to the above file. Heres how it is done.

[[email protected] named]# cat named.loopback > server.2adesigns.com.db
Confirm it by
[[email protected] named]# cat server.2adesigns.com.db
@       IN SOA  @ rname.invalid. (
                                        0       ; serial
                                        1D      ; refresh
                                        1H      ; retry
                                        1W      ; expire
                                        3H )    ; minimum
        NS      @
        AAAA    ::1
        PTR     localhost.

We can use parts of these zone file to add our settings easily. Take a look the zone file and its records below. TTL setting is globally set to 1D and i will be leaving it that way but you can alter the TTL to your need. Source of authority SOA is set to ns1.2adesigns.com and mail rijo.2adesigns.com. Serial number to ten digit number but you can choose any number.
Added NS records for the hostname of your server rijo.2adesigns.com. and also A record to point the hostname to the server with IP 176.2527.2519.952. Add MX record if you want this server to be the mail server.

[[email protected] named]# cat server.2adesigns.com.db
@        IN SOA ns1.2adesigns.com. rijo.2adesigns.com. (
                                        1      ; serial
                                        1D      ; refresh
                                        1H      ; retry
                                        1W      ; expire
                                        3H )    ; minimum
server.2adesigns.com. IN  NS      ns1.2adesigns.com.
server.2adesigns.com. IN  NS      ns2.2adesigns.com.

server.2adesigns.com. IN  A       176.2527.2519.952
server.2adesigns.com. IN   MX     0 server.2adesigns.com.

Now we can add zone recoreds for our domain 2adesigns.com. Cat the conents of our above file to the file /var/named/2adesigns.com.db
[[email protected] named]# touch 2adesigns.com.db
[[email protected] named]# cat server.2adesigns.com.db > 2adesigns.com.db

We will have a copy of server.2adesigns.com.db in 2adesigns.com.db file. Lets edit it to work

[[email protected] named]# cat 2adesigns.com.db
@        IN SOA ns1.2adesigns.com. server.2adesigns.com. (
                                        0      ; serial
                                        1D      ; refresh
                                        1H      ; retry
                                        1W      ; expire
                                        3H )    ; minimum
2adesigns.com. IN       NS      ns1.2adesigns.com.
2adesigns.com. IN       NS      ns2.2adesigns.com.
2adesigns.com. IN       A       176.2527.2519.952
2adesigns.com. IN   MX        0  2adesigns.com.

www 		IN 	CNAME  2adesigns.com.

Above you will find a CNAME record for www. This setting will load your website even if you call the website with www.2adesigns.com. Otherwise only 2adesigns.com will load the website.

Start the named service

[[email protected] named]# service named start
Starting named:                                            [  OK  ]

Check the log here 
[[email protected] named]# cat /var/named/data/named.run
zone 0.in-addr.arpa/IN: loaded serial 0
zone loaded serial 0
zone loaded serial 0
zone 2adesigns.com/IN: loaded serial 0
zone server.2adesigns.com/IN: loaded serial 1
zone localhost.localdomain/IN: loaded serial 0
zone localhost/IN: loaded serial 0
managed-keys-zone ./IN: loaded serial 0
zone 2adesigns.com/IN: sending notifies (serial 0)
zone server.2adesigns.com/IN: sending notifies (serial 1)

You are almost done now.

Lets check the changes from within our server.

[[email protected] named]# dig @localhost 2adesigns.com

; <<>> DiG 9.8.2rc1-RedHat-9.8.2-0.17.rc1.el6_4.6 <<>> @localhost 2adesigns.com
; (2 servers found)
;; global options: +cmd
;; Got answer:
;; ->>HEADER<

All perfect.

2. Registering name servers you just created

The world won’t know anything about the nameservers you created just now. So how are we supposed to publish it to other dns servers on the planet ?
Simple, register them on domain registrar portal.
2adesigns.com is registred with godaddy.com, so i will go there and register my newly created nameservers. Godaddy will update our private nameservers to the root servers and so on and so forth. Soon within 24-48 hrs the dns will propogate and your website will show up for everyone.
What are our name servers again ?

How to register them at your registrar ?
Set them with ip we added in zone files.
ns1.2adesigns.com 176.2527.2519.952
ns2.2adesigns.com 5.176.2527.952

Adding the above nameservers with ip to register private nameservers will vary on the registrar, but the concept is the same.