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

I want to set my server's IP as DNS and then be able to to make domains like myproject.com, and also www.myproject.com, and *.applications.com point to the same server where I will be hosting these files in apache.

I installed macports, and here is my configuration file: /opt/local/etc/named.conf

    // Declares control channels to be used by the rndc utility.
    //
    // This must be enabled on Mac OS X Server for Server Status to provide valid
    // information! (Remove the leading slashes to enable.)
    //
    //        **** STUFF YOU MIGHT NEED TO ENABLE ****
    //
     controls {
          unix "/var/run/ndc" perm 0600 owner 0 group 0;
          inet 127.0.0.1 port 54 allow {any; };
     };
    // It is recommended that 127.0.0.1 be the only address used.
    // This also allows non-privileged users on the local host to manage
    // your name server.

    options {
            directory "/opt/local/var/named";

            // uncomment the following lines to turn on DNS forwarding,
            // and change the forwarind ip address(es) :
            //forward first;
            //forwarders {
            //      123.123.123.123
            //      123,123.123.123;
            //};

            listen-on-v6 { none; };
            listen-on { 127.0.0.1; };

            // to allow only specific hosts to use the DNS server:
            //allow-query {
            //      127.0.0.1;
            //};

            dnssec-validation auto;
            pid-file "/opt/local/var/run/named.pid";
    };

    //
    // a caching only nameserver config

    zone "." IN {
            type hint;
            file "db.cache";
    };

    zone "localhost" IN {
            type master;
            file "db.localhost";
            allow-update { none; };
    };

    zone "0.0.127.in-addr.arpa" IN {
            type master;
            file "db.127.0.0";
            allow-update { none; };
    };

So I wanna be able to make all these point to the same server where bind is installed:

www.myproject.com
myproject.com
*.applications.com

How can I do this? I would also like to ask how can I get a good documentation or book about bind. The documents I found on web were either too technical or too simplistic.

Or is there an easier interface to work with bind?

share|improve this question
    
As for bind guides - there's excellent (and free) DNS for Rocket Scientists: zytrax.com/books/dns and Oreilly's DNS and BIND is great. –  Sandman4 Nov 26 '11 at 16:13
    
That book is pretty hardcore, not suitable for someone who doesn't wanna be a dns Einstein, but only wants to make the thing work once and for all, It seems to be the most popular book on bind though, many thanks for sharing –  user893730 Nov 26 '11 at 22:28
    
Oreilly's first chapters are quite simple how-to with an example of config file and zone. Should be enough to start with. I think there's some GUI for bind, maybe it doesn't work on mac. And doesn't macos have it's own DNS server ? –  Sandman4 Nov 27 '11 at 7:16
    
Btw, if you want it easy, why not to use some hosted DNS service ? like freedns.afraid.org. - should be easier and more reliable. –  Sandman4 Nov 27 '11 at 7:18

2 Answers 2

up vote 1 down vote accepted

You need to edit you named.conf to add a zone like:

zone "myproject.com" IN {
    type master;
    file "myproject.com.zone";
    allow-update { none; };
}

Then create a zone file in /opt/local/var/named named myproject.com.zone. That file should look like:

$ORIGIN myproject.com.
$TTL 21600 
@                      3600 SOA   <your ns A record>. (
                              sysadmins.stackoverflow.com.    ; address of responsible party
                              2011072601                          ; serial number
                              3600                       ; refresh period
                              600                        ; retry period
                              604800                     ; expire time
                              60                       ) ; minimum ttl
                                NS    <YOUR_NS_A_RECORD>.

                                A     <YOUR_IP>
*               IN      A     <YOUR_IP>

Wildcarding it is you best options since you then don't have to worry about it again.

I highly recommend getting a copy of DNS and BIND

share|improve this answer
    
Thank you Zypher, can you tell me how I can find my ns A record? –  user893730 Nov 26 '11 at 4:34
    
You need to set it in your zone file - if everything is under <YOUR_IP> then the * will cover you (however you should really manually specify it as nsX IN NS <IP> –  Zypher Nov 26 '11 at 5:45

This is what worked for me in the zone file, I used what Zypher suggested in named.conf

$TTL 10800
myproject.com. IN SOA myservername.myproject.com. admin.mymyproject.com. (
    2011071800  ;Serial
    86400       ;Refresh
    3600        ;Retry
    604800      ;Expire
    345600      ;Negative caching TTL
 ) 

www.projects.com. IN  A <SERVER IP>
projects.com. IN  NS myservername.myproject.com. 
projects.com. IN  A <SERVER IP> 
www IN  CNAME myproject.com. 
share|improve this answer

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.