Sign up ×
Server Fault is a question and answer site for system and network administrators. It's 100% free, no registration required.

So I'm setting up this server right now that'll host multiple websites / domains. What are the current best practices with regard to DNS records? I admit to 'just having done something' up to now, which is pretty bad. Mea culpa. And though it has worked for me in the past, I'd like to know what the best way of doing things is, so here's a couple of questions about it:

  1. I think it probably makes the most sense to setup the main hostname like this   A   A
    www           CNAME

    and then a single PTR record for back to Should the www CNAME point to the or to the A records? What makes more sense and why?

  2. Would it then make the most sense to create a CNAME for each Virtualhost on this server to the A record (or the A record), or to create individual A records for each Virtualhost to the main IP address?

  3. The SMTP server on this host will identify itself as Is SPF uptake broad enough already that I can create an SPF record for each hosted domain and have that take care of other domains possibly rejecting mail from this host?

share|improve this question

5 Answers 5

Addressing 1 and 2: In most cases, I would recommend doing a single "A" record for the actual IP associated with the box and CNAME everything you need to that. If you are going to have a lot of, I would make use of a wildcard entry     A

The benefit being that you don't have to do a lot of DNS maintenance as whatever you use will already match. You just let apache figure out what to do with it based on the name given. This would result in 2 look-ups, and I would only do many CNAMEs to one A, and not try doing CNAME->CNAME. Additionally MX records must only point to an A record name.

If you ever need to break a vhost off to its own IP addres, you can then just add an "A" record for that one host and the most-specific answer will win.     A
share|improve this answer

Any given IP address can have as many A RR's pointing to it as you want. You can have then: IN A IN A 
: IN A

You only need one PTR for In this particular case the most appropriate seems to be: IN PTR

However, any of the other choices would be equally correct, as long as it is one.

This happens because when a machine (A) connects to a server (B), it does not know the name of A, only its IP address. By posing a PTR query on the DNS, it gets a name as a response. So now B knows that whoever connected on him is (probably) named A. To verify that is asks again the DNS "what is the IP address of A?" and expects the answer to contain the IP address it already knows about A from the connection data. What happens when the response does not match what is expected is a matter of server administration policy.

You can create CNAMEs instead of multiple records if you wish. This means that when someone wants to find out the IP address of B (so as to connect to it) it asks the DNS twice: First, "what is the real name of B?" and then "what is the IP address of that name?".

Note though that you cannot have CNAMEs combined with MX records, and therefore if for some particular reason you need to accept email directed to, then has to be an A record.

share|improve this answer
  1. You should point the PTR to to avoid mail delivery errors as adamo explains. You can point the CNAME to any host, I would prefer
  2. You could use either CNAME or A records for your virtual hosts but maybe A record resolution will be more efficient.
  3. You should set a SPF record to avoid mail delivery errors from some servers, "v=spf1 mx -all" is a good starting point and will allow only your MX to deliver for your domain.

Here you have a very good and free tool to check your configuration:

share|improve this answer

For each domain you need to create a separate zone file, e.g. for you'll create a file called

Next set up your SOA record:

$TTL 86400
@ IN SOA (
    2010102601 ; Serial
    7200       ; Refresh (how often slave nameservers check with master for changes)
    1200       ; Retry (how often slaves contact the master if XFER fails)
    2419200    ; Expire
    86400      ; Negative Cache TTL
    NS ns ; inet of our nameserver
    NS ; secondary dns
    MX 50 mail ; smtp server

; nameserver
ns A

; mail
mail A

; canonical names
www CNAME ns

It is largely up to you whether you use a www CNAME or www A record. Something to be aware of is that large organisations sometimes have trouble when there are too many CNAME chains. This is unlikely to be a problem for you, however.

The PTR record (reverse look-up) will not exist in this zone file. It will probably be located in a zone file operated by your internet service provider.


share|improve this answer
Thanks for answering, but I know how to create zone files. What I really wanted to know is what is the best layout for the CNAME's, A's and PTR's in relation to one-another. –  wzzrd Oct 26 '10 at 8:10
I just added a link, makes for interesting reading. –  PP. Oct 26 '10 at 8:10

Setting up records as A theoretically should be faster as in the CNAME scenario two DNS requests are needed.

share|improve this answer
2 DNS requests are not needed when the A record for the CNAME is configured in the same host. The DNS request will return with both records in a single request. –  Declan Shanaghy Oct 26 '10 at 16:45

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.