7

I've setting up a Hosting service, as part of that service I need to automatically create DNS records in our nameservers for all the domains hosted.

Currently I'm using the following template:

;
; [USER] - [DOMAIN]
;
$TTL    604800
@    IN    SOA    [PRIMARY-NS].    [NS-ADMIN]. (
                       [SERIAL] ; Serial
                           10800 ; Refresh
                            3600 ; Retry
                         1209600 ; Expire
                           43200 ; Negative Cache TTL
)
;
@    IN    NS    [NS1]. ; Nameserver
@    IN    NS    [NS2]. ; Nameserver
@    IN    A     [SERVER-IP] ; Primary IP
*    IN    A     [CATCH-ALL-IP] ; Catch-all IP
@    IN    MX    0 mail

What I'm interested in knowing is, if I replace the primary A record statement with a CNAME to that server's DNS entry - will there be any adverse affects? This would make IP management on my servers far easier as I would only need to update one DNS record.

@    IN    CNAME     [SERVER-DOMAIN-NAME]
*    IN    CNAME     [SERVER-DOMAIN-NAME]

Is this a good idea? Or will this only cause trouble for DNS lookups on those records?

  • The data portion of a CNAME resource record is a domain name, not an IP address. A CNAME resource record is a client-side alias, from one domain name to another. – JdeBP Jul 22 '11 at 15:27
  • @JdeBP Right, which is why it says SERVER-ADDRESS - IE: srv1.example.com instead of the IP address for that server. – Marco Ceppi Jul 22 '11 at 15:53
  • No. That (srv1.example.com) would be a server domain name, not an address. – JdeBP Jul 25 '11 at 16:03
  • 2
    Possible duplicate of Why can't a CNAME record be used at the apex (aka root) of a domain? – Jenny D Mar 20 '19 at 19:14
14

No, you can't do

@ IN CNAME ...

because the CNAME record type isn't allowed to co-exist with the (required) SOA and NS records that you have to have at your zone apex (or any other resource record type, for that matter, except for DNSSEC-related records).

See s3.6.2 of RFC 1034:

If a CNAME RR is present at a node, no other data should be present; this ensures that the data for a canonical name and its aliases cannot be different. This rule also insures that a cached CNAME can be used without checking with an authoritative server for other RR types.

  • I'd just symlink the zone file for all domains. – Simon Richter Jul 17 '11 at 22:54
0

No! That wouldn't work as CNAME allow "domainname" in value friend and you can not set with your server IP. You can add 1 A record for the IP address (* @ XXXX.XXXX.XXXX.XXXX) and add CNAME record for www

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

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