Server Fault is a question and answer site for system and network administrators. Join them; it only takes a minute:

Sign up
Here's how it works:
  1. Anybody can ask a question
  2. Anybody can answer
  3. The best answers are voted up and rise to the top

I am doing web development and host the local versions of sites on my machine. I have Linux Slackware 14.0 with BIND 9.9.1-P3. In my named.conf I have this:

zone "localhost" IN {
    type master;
    file "caching-example/";
    allow-update { none; };


$TTL    86400
$ORIGIN localhost.
@           1D IN SOA   @ root (
                    56      ; serial (d. adams)
                    3H      ; refresh
                    15M     ; retry
                    1W      ; expiry
                    1D )        ; minimum

            1D IN NS    @
            1D IN A

Suppose, I have a domain, called dubai, that I want to reference to localhost. I tried to add a CNAME record for localhost into

dubai   IN  CNAME   localhost.

But it didn't work. How can I add a CNAME for localhost, so I could host multiple sites on my machine?

share|improve this question
up vote 1 down vote accepted

The zone file you're working in is for the reverse lookup zone of, you need to be working with a zone that can contain dubai. or localhost. to work with those records.

Seems like you really just want to be using your /etc/hosts file, not setting up a BIND service.

If you do want to use BIND, then you should create a forward lookup zone. To use those names you can make a zone ".", but that will break resolution of actual internet names for systems pointed to this DNS server. It'd probably be better to create something like zone "dev.localhost", with a zone file along these lines:

@ IN A
dubai IN CNAME @
share|improve this answer
I updated the question for file. I tried to add CNAME, using your approach, but it didn't work. – user4035 Apr 1 '13 at 0:40
@user4035 Have you restarted the service after making the change? What's returned from dig @localhost localhost any and dig @localhost dubai.localhost? – Shane Madden Apr 1 '13 at 0:42
Ahh, no it works! With exactly the same settings, I wrote in the question. Thx. – user4035 Apr 1 '13 at 0:42
Here is the dig answer: ;; ANSWER SECTION: dubai. 86400 IN A – user4035 Apr 1 '13 at 0:43

Your Answer


By posting your answer, you agree to the privacy policy and terms of service.

Not the answer you're looking for? Browse other questions tagged or ask your own question.