Take the 2-minute tour ×
Server Fault is a question and answer site for professional system and network administrators. It's 100% free, no registration required.

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/localhost.zone";
    allow-update { none; };
};

In localhost.zone:

$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     127.0.0.1

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

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

1 Answer 1

up vote 1 down vote accepted

The zone file you're working in is for the reverse lookup zone of 0.0.127.in-addr.arpa, 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 127.0.0.1
dubai IN CNAME @
share|improve this answer
    
I updated the question for localhost.zone 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 127.0.0.1 –  user4035 Apr 1 '13 at 0:43

Your Answer

 
discard

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.