0

I am hosting a couple of websites at home, say example.com and sub.example.com, and, although my DNS records are set correctly (A record for example.com that points to my router's IP address, and CNAME for (*) with value 'example.com.'), my router does not seem to be able to resolve the subdomain. Here is the output of some drills, with my actual domain and subdomain names replaced by example.com and sub.example.com.

~ $ drill example.com @8.8.8.8    
;; ->>HEADER<<- opcode: QUERY, rcode: NOERROR, id: 55521
;; flags: qr rd ra ; QUERY: 1, ANSWER: 1, AUTHORITY: 0, ADDITIONAL: 0 
;; QUESTION SECTION:
;; example.com. IN  A

;; ANSWER SECTION:
example.com.    899 IN  A   109.133.244.17

;; AUTHORITY SECTION:

;; ADDITIONAL SECTION:

;; Query time: 70 msec
;; SERVER: 8.8.8.8
;; WHEN: Fri Oct 13 10:06:23 2017
;; MSG SIZE  rcvd: 41


~ $ drill sub.example.com @8.8.8.8                                                                                                                  <<<
;; ->>HEADER<<- opcode: QUERY, rcode: NOERROR, id: 33949
;; flags: qr rd ra ; QUERY: 1, ANSWER: 2, AUTHORITY: 0, ADDITIONAL: 0 
;; QUESTION SECTION:
;; sub.example.com. IN  A

;; ANSWER SECTION:
sub.example.com.    1799    IN  CNAME   example.com.
example.com.    899 IN  A   109.133.244.17

;; AUTHORITY SECTION:

;; ADDITIONAL SECTION:

;; Query time: 105 msec
;; SERVER: 8.8.8.8
;; WHEN: Fri Oct 13 10:06:33 2017
;; MSG SIZE  rcvd: 62


~ $ drill example.com @192.168.1.1
;; ->>HEADER<<- opcode: QUERY, rcode: NOERROR, id: 59107
;; flags: qr rd ra ; QUERY: 1, ANSWER: 1, AUTHORITY: 0, ADDITIONAL: 0 
;; QUESTION SECTION:
;; example.com. IN  A

;; ANSWER SECTION:
example.com.    781 IN  A   109.133.244.17

;; AUTHORITY SECTION:

;; ADDITIONAL SECTION:

;; Query time: 26 msec
;; SERVER: 192.168.1.1
;; WHEN: Fri Oct 13 10:06:43 2017
;; MSG SIZE  rcvd: 41

~ $ drill -V 10000 sub.example.com @192.168.1.1 
;; ->>HEADER<<- opcode: QUERY, rcode: NOERROR, id: 0
;; flags: rd ; QUERY: 1, ANSWER: 0, AUTHORITY: 0, ADDITIONAL: 0 
;; QUESTION SECTION:
;; sub.example.com. IN  A

;; ANSWER SECTION:

;; AUTHORITY SECTION:

;; ADDITIONAL SECTION:

;; Query time: 0 msec
;; WHEN: Fri Oct 13 10:17:39 2017
;; MSG SIZE  rcvd: 0
Error: error sending query: Could not send or receive, because of network error

For completeness, here are the DNS records associated with the domain:

@ 900 IN A 109.133.244.17
@ 10800 IN SOA ns1.gandi.net. hostmaster.gandi.net. 1507886704 10800 3600 604800 10800
sub 10800 IN CNAME example.com.
imap 10800 IN CNAME access.mail.gandi.net.
pop 10800 IN CNAME access.mail.gandi.net.
smtp 10800 IN CNAME relay.mail.gandi.net.
webmail 10800 IN CNAME webmail.gandi.net.

Would anyone know what might be causing this curious behaviour?

Thank you.

0

Your use of a CNAME on a "base" record is the problem. Its a common gotcha - a CNAME is not simply a redirect of a domain to another, its the delegation of the SOA from that domain - thus you would generally want to use a CNAME on www.example.com, but not example.com. (The rule is never use a CNAME on a domain name, only a subdomain)

The technical reasoning is difficult - its specified in 3.6.2 of rfc1034. "The domain system provides such a feature using the canonical name (CNAME) RR. A CNAME RR identifies its owner name as an alias, and specifies the corresponding canonical name in the RDATA section of the RR. 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."

  • 1
    The OP seems to be doing the reverse. – grawity Oct 13 '17 at 9:28
  • Thank you very much! I'm not really sure I understand though, as I don't have much experience with these type of things. What do you mean by "base" record? I have added my DNS records, in case it can help. – Rastapopoulos Oct 13 '17 at 9:31
  • It's ok for you to use a CNAME on www.example.com, but not on example.com. In this case example.com would be the base record (or zone origin) – davidgo Oct 13 '17 at 9:35
  • @grawity - you are right. I don't think you can can use a CNAME for a wildcard gor much the same reason (highlighted in my answer) – davidgo Oct 13 '17 at 9:37
  • Thanks. Do you know if there is a way to apply the record to all the subdomains but not to the domain itself? – Rastapopoulos Oct 13 '17 at 9:40

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.