How to add DNS record in Ubuntu/Linux

Point domain to unmanaged VPS/Dedicated server or add any DNS record in Ubuntu/CentOS

To serve DNS records we need to install DNS server package like BIND9
Update Package manager “apt-get update” or CentOS “yum update”

Install BIND9

apt-get install bind9

or CentOS

yum install bind9

Configure and Create Zone File for domains to add records
open file name.conf.local and insert zone file name for domain

cd /etc/bind/
vi name.conf.local
zone "abc.com" {
        type master;
        allow-transfer {none;};
        file "/etc/bind/pri.abc.com";
};
zone "zyx.com" {
        type master;
        allow-transfer {none;};
        file "/etc/bind/pri.xyz.com";
};

save and close file.

Create Zone File for domain

touch pri.abc.com
touch pri.xyz.com

To create name server ns1.abc.com and ns2.abc.com. added NS and A records. replace 000.000.000.000 with server IP

 vi pre.abc.com
$TTL        3600
@       IN      SOA     host.abc.com. info.abc.com. (
                        2015062803       ; serial, todays date + todays serial #
                        7200              ; refresh, seconds
                        540              ; retry, seconds
                        604800              ; expire, seconds
                        86400 )            ; minimum, seconds
;

abc.com. 3600 A        000.000.000.000
mail 3600 A        000.000.000.000
sv4 86400 A        000.000.000.000
sv4 86400 A        000.000.000.000
www 3600 A        000.000.000.000
abc.com. 3600      MX    10   mail.abc.com.
abc.com. 3600      NS        ns1.abc.com.
abc.com. 3600      NS        ns2.abc.com.

Now add ns1.abc.com and ns2.abc.com as child nameserver in domain register panel and also add in nameserver address in domain register.

To add another domain to same vps

vi pri.xyz.com
$TTL        3601
@       IN      SOA     host.abc.com. info.abc.com. (
                        2015062813       ; serial, todays date + todays serial #
                        7200              ; refresh, seconds
                        540              ; retry, seconds
                        604800              ; expire, seconds
                        86400 )            ; minimum, seconds
;

mail 3600 A        000.000.000.000
xyz.com. 3600 A        000.000.000.000
www 3600 A        000.000.000.000
xyz.com. 3600      NS        ns1.abc.com.
xyz.com. 3600      NS        ns1.abc.com.
service bind9 restart

Posted

in

by

Tags: