Score:0

bind9 doesn't load zone with only CNAME record

ua flag

I'm trying to set up a subdomain to point to Google Sites, so I made a simple zone file:

$ttl 38400
subdomain.mydomain.net.    IN CNAME ghs.googlehosted.com.

This doesn't work:

zone subdomain.mydomain.net/IN: has 0 SOA records
zone subdomain.mydomain.net/IN: has no NS records
zone subdomain.mydomain.net/IN: not loaded due to errors.

But adding an NS or SOA record gives a "CNAME and other data" error. How do I fix this?

Michael Hampton avatar
cz flag
Why do you bother with a zone file? Do you already use bind? Why didn't you just put this CNAME record in the domain's zone?
buildist avatar
ua flag
@MichaelHampton I had always used separate zone files for subdomains before and it worked, but those were pointed to the same server using its IP address. I tried adding the CNAME entry to the zone file for mydomain.net instead of creating a separate file, but I get the same error.
Michael Hampton avatar
cz flag
You made a separate zone file for every DNS record?!?
buildist avatar
ua flag
For every domain/subdomain. What should I have done instead?
Michael Hampton avatar
cz flag
Put them all in your zone file, as normal.
Score:3
cn flag

You can't have a CNAME at apex of your domain name, per design of the DNS.

And you can't have a valid zone without SOA and NS records which is exactly why you can't have a CNAME record at apex, since CNAME is incompatible, besides DNSSEC related records, with any other records on the same name, for obvious reasons of ambiguity otherwise.

buildist avatar
ua flag
I got it working by adding the subdomain to the zone file for mydomain.net rather than creating a new file.
Score:0
bw flag

You should only create subdomains if you want to transfer authority for that subdomain to a different team/entity. If you manage all those subdomains yourself, there isn't really a good reason for creating different subdomains.

Below you can see an example configuration file for a zone (source)

$ORIGIN example.com.
$TTL 86400
@       SOA    dns1.example.com. hostmaster.example.com. (
               2001062501 ; serial
               21600      ; refresh after 6 hours
               3600       ; retry after 1 hour
               604800     ; expire after 1 week
               86400 )    ; minimum TTL of 1 day
;
;
        NS     dns1.example.com.
        NS     dns2.example.com.
dns1    A      10.0.1.1
        AAAA   aaaa:bbbb::1
dns2    A      10.0.1.2
        AAAA   aaaa:bbbb::2
;
;
@       MX     10 mail.example.com.
        MX     20 mail2.example.com.
mail    A      10.0.1.5
        AAAA   aaaa:bbbb::5
mail2   A      10.0.1.6
        AAAA   aaaa:bbbb::6
;
;
; This sample zone file illustrates sharing the same IP addresses for
; multiple services:
;
services  A      10.0.1.10
          AAAA   aaaa:bbbb::10
          A      10.0.1.11
          AAAA   aaaa:bbbb::11

ftp       CNAME  services.example.com.
www       CNAME  services.example.com.
;
; The items below I have added myself.
;
subdomain                    CNAME  ghs.googlehosted.com.
mailserver.other-subdomain   A      192.0.2.25
webserver.other-subdomain    A      203.0.113.80
cname.other-subdomain        CNAME  webserver.other-subdomain.example.com.

As you can see from the example, you do not have to create a separate zone for "other-subdomain" or for "subdomain". You can add all those records to the master zone file for the domain.

mangohost

Post an answer

Most people don’t grasp that asking a lot of questions unlocks learning and improves interpersonal bonding. In Alison’s studies, for example, though people could accurately recall how many questions had been asked in their conversations, they didn’t intuit the link between questions and liking. Across four studies, in which participants were engaged in conversations themselves or read transcripts of others’ conversations, people tended not to realize that question asking would influence—or had influenced—the level of amity between the conversationalists.