≡ Menu

How To Setup Vanity DNS Name Server Using BIND 9

Q. I’ve nameserver like ns1.example.com and ns2.example.com. I’d like to provide Vanity DNS for each domain such as ns1.yourdomain.com and ns2.yourdomain.com. Basically, my users should able to call my dns server as their own servers. This will create the illusion that my user run their own name servers. How do I setup vanity DNS using BIND 9 under UNIX / Linux?

A. It is pretty easy to setup nameserver for each domain using BIND. For example, ns1.nixcraft.net and ns2.nixcraft.net can be used as vanity DNS for theos.in domain.

Our sample setup

Your real DNS serverVanity DNSIP address for both Real and Vanity servers

So instead of using ns1.nixcraft.net, you use ns1.theos.in for theos.in. Please replace domain name and IPs according to your requirements.

How do I setup Vanity DNS for theos.in domain?

You need to register ns1.theos.in and ns2.theos.in with your domain service provider or ISP with the following settings:

  1. ns1.theos.in :
  2. ns2.theos.in :

Next, you need to setup named.conf as follows on master bind 9 server, enter:
# vi named.conf
Append zone as follows, enter:

zone "theos.in" {
        type master;
        file "/etc/bind/zones/master.theos.in";
        allow-transfer { };

Save and close the file. Run following command to check named.conf for error:
# named-checkconf
Now, create /etc/bind/zones/master.theos.in zone file:
# vi /etc/bind/zones/master.theos.in
Append zone as follows, enter:

$ORIGIN theos.in.
$TTL 3h
@        IN SOA ns1.theos.in. hostmaster.theos.in. (
                       2008071801        ; Serial yyyymmddnn
                       3h                ; Refresh After 3 hours
                       1h                ; Retry Retry after 1 hour
                       1w                ; Expire after 1 week
                       1h)             ; Minimum negative caching of 1 hour
; Vanity DNS 
@                      86400    IN NS    ns1.theos.in.
@                      86400    IN NS    ns2.theos.in.

@                     86400     IN MX 10 smtp.theos.in.

; Vanity DNS must point to IP of ns1.nixcraft.net and ns2.nixcraft.net
ns1                    86400    IN A
ns2                    86400    IN A

; host stuff
@                      86400    IN A
www                    86400    IN A
ftp                    86400    IN A

Save and close the file. Run zone file validity checking for theos.in, enter:
# named-checkzone theos.in /etc/bind/zones/master.theos.in
Sample output:

zone theos.in/IN: loaded serial 2008071801

Now just reload bind 9, enter:
# rndc reload

Slave server configuration

Open named.conf on slave server and append following code:

     zone "theos.in" {
                type slave;
                file "/etc/bind/zones/slave.theos.in";
                masters {; };
                allow-transfer { none; };

Save and close the file. Run following command to check named.conf for error:
# named-checkconf
Reload named, enter:
# rndc reload
It may take anywhere from 24-48 hrs to propagate a domain across the internet. You can test your setup with the following command:
$ host -t ns theos.in
Sample output:

theos.in name server ns1.theos.in.
theos.in name server ns2.theos.in.
Share this tutorial on:

Your support makes a big difference:
I have a small favor to ask. More people are reading the nixCraft. Many of you block advertising which is your right, and advertising revenues are not sufficient to cover my operating costs. So you can see why I need to ask for your help. The nixCraft, takes a lot of my time and hard work to produce. If you use nixCraft, who likes it, helps me with donations:
Become a Supporter →    Make a contribution via Paypal/Bitcoin →   

Don't Miss Any Linux and Unix Tips

Get nixCraft in your inbox. It's free:

{ 9 comments… add one }
  • M B Richards December 20, 2008, 5:12 pm

    When you try to click on the Printable version link above, it comes up with an error 404 pages

  • nixCraft December 20, 2008, 5:35 pm

    @M B Richards,

    Thanks for the heads up. I’ve fixed the problem. Let me know if you’ve any other problem.

  • Danny December 21, 2008, 5:15 pm

    Great tutorial! Thank you for your kindness.

    Best regards,

  • M.S. Babaei February 4, 2010, 10:36 am

    I’ve got a new FreeBSD VPS and I’m in trouble with this dns stuff:


    Is there anybody to help me. I’ll be apperciated.

  • Robert September 19, 2011, 1:29 am

    “You need to register ns1.theos.in and ns2.theos.in with your domain service provider or ISP” Can you explain this more? Even if you run your own nameservers you still cant do it yourself? But you need to engage I presume whoever owns the ip ranges your using for you DNS servers?

    • Robert September 19, 2011, 1:40 am

      I understand now you mean the domain registrar.

      They obviously provide some information back to the central dns servers? I guess some registrar’s might have automated this process, others would only do it manually and others may refuse to support this at all?

  • govind (TIS) August 14, 2012, 7:30 pm

    I used the DNS ip ‘s provided by my network provider . is it ok or should i own from ISP .please let me know . I am using ubuntu 12.04 (bind9 to configure)

  • shufil February 10, 2015, 2:00 pm


    I setup dns server on my server
    and create entry in /etc/named/name.conf and mention zone file information ,
    then i edit zone file and added rest of the information, yes i will show my configuration below , but problem is i did not getting result when i try to run dig .

    options {
    listen-on port 53 {; };
    listen-on-v6 port 53 { ::1; };
    directory “/var/named”;
    dump-file “/var/named/data/cache_dump.db”;
    statistics-file “/var/named/data/named_stats.txt”;
    memstatistics-file “/var/named/data/named_mem_stats.txt”;
    allow-query { any; };
    allow-transfer { localhost; };
    recursion no;

    dnssec-enable yes;
    dnssec-validation yes;
    dnssec-lookaside auto;

    /* Path to ISC DLV key */
    bindkeys-file “/etc/named.iscdlv.key”;

    managed-keys-directory “/var/named/dynamic”;

    zone “mydomain.net.in” IN {
    type master;
    file “/var/named/mydomain.net.in.zone”;
    allow-update { none; };
    zone “ns1.mydomain.net.in” {
    type master;
    file “/var/named/ns1.mydomain.net.in.zone”;
    zone “ns2.mydomain.net.in” {
    type master;
    file “/var/named/ns2.mydomain.net.in.zone”;
    $TTL 14400
    $ORIGIN mydomain.net.in.

    ; SOA Record
    ; Specify Primary nameserver ns1.mydomain.net.in
    ; Serial should increment every update
    @ 14400 IN SOA ns1.mydomain.net.in. webmaster.technozone.net.in. (
    2015012902 ; Serial in YYYYMMDDXX (XX is increment)
    10800; refresh seconds
    3600; retry
    604800; expire
    38400; minimum
    ; Website IP Address specified in A record

    IN A

    ; Minimum 2 DNS nameserver names

    IN NS ns1.mydomain.net.in.
    IN NS ns2.mydomain.net.in.

    ; Mapping all Nameservers and their corresponding IPs (GLUE)

    ns1 IN A
    ns2 IN A

    ; Specify any subdomains and www entry here using CNAME record

    www IN CNAME mydomain.net.in.
    ftp IN CNAME mydomain.net.in.
    server IN CNAME mydomain.net.in.
    webmail IN CNAME mydomain.net.in.

    ; Setup MX record (mail exchanger with priority)
    mydomain.in. IN MX 10 mail.mydomain.net.in.

    ; set A record for mail
    mail IN A;====================================
    For ns1
    $TTL 14400
    @ 86400 IN SOA ns1.mydomain.net.in. wemaster.mydomain.net.in. (
    3013040200 ; serial, todays date+todays
    86400 ; refresh, seconds
    7200 ; retry, seconds
    3600000 ; expire, seconds
    86400 ) ; minimum, seconds

    ns1.mydomain.net.in. 86400 IN NS ns1.mydomain.net.in.
    ns1.mydomain.net.in. 86400 IN NS ns2.mydomain.net.in.
    ns1.mydomain.net.in. IN A
    ns2.mydomain.net.in. IN A
    ;localhost.ns1.mydomain.net.in. IN A
    ;ns1.mydomain.net.in. IN MX 0 ns1.mydomain.net.in.
    ;mail IN CNAME ns1.mydomain.net.in.
    ;www IN CNAME ns1.mydomain.net.in.
    ;ftp IN CNAME ns1.mydomain.net.in.

    $TTL 14400
    @ 86400 IN SOA ns2.mydomain.net.in. wemaster.mydomain.net.in. (
    2014013001 ; serial, todays date+todays
    86400 ; refresh, seconds
    7200 ; retry, seconds
    3600000 ; expire, seconds
    86400 ) ; minimum, seconds

    ns2.mydomain.net.in. 86400 IN NS ns2.mydomain.net.in.
    ns2.mydomain.net.in. 86400 IN NS ns1.mydomain.net.in.
    ns2.mydomain.net.in. IN A
    ns1.mydomain.net.in. IN A
    ;localhost.ns2.mydomain.net.in. IN A
    ;ns2.mydomain.net.in. IN MX 0 ns1.mydomain.net.in.
    ;mail IN CNAME ns2.mydomain.net.in.
    ;www IN CNAME ns2.mydomain.net.in.
    ;ftp IN CNAME ns2.mydomain.net.in.

  • shufil February 14, 2015, 12:02 pm


    any one can reply me pleaseeee…….

Security: Are you a robot or human?

Leave a Comment

You can use these HTML tags and attributes: <strong> <em> <pre> <code> <a href="" title="">

   Tagged with: , , , , , , , , , , , , ,