hostless DNS CNAME record - dns

We are running BIND 9.9.7 on Centos 6.5 and for a long time I have been creating "hostless" DNS entries so that sites work with or without the www.
Eg:
www IN A 192.168.1.1
domain.com. IN A 192.168.1.1
However, our client wants to use a CNAME record to a cloudfront host and the "hostless" entry doesn't work as a CNAME record.
In fact, it more than doesn't work, BIND won't even load the zone file. The error is
"failed: CNAME and other data"
domain.com. IN CNAME host.cloudfront.net.
www IN CNAME host.cloudfront.net.
It will load and resolve fine without the domain.com entry. I have tried a few variations, but nothing seems to work. including "", "."
Can anyone tell me the correct syntax for this entry?

There is no correct syntax for this (and it is not BIND specific, it is a side effect of RFC1912 which states that A CNAME record is not allowed to coexist with any other data.
Detailed explanation: Why can't a CNAME record be used at the apex (aka root) of a domain?
Some DNS providers might offer workaround hacks.

Related

How to configure www. CNAME

This question must be so basic that I am bewildered why I cannot find a clear answer.
I want to configure my DNS for a new domain name. I configure the A record with the IP address of my host server. domain.com works fine. But how do I configure the CNAME to create the www. alias? It won't accept an IP address, and aliasing it to domain.com does not seem to work.
The following record should work:
www IN CNAME domain.com.
Make sure you have the . at the end of domain.com.. Names that don't end with . automatically get the origin appended, so it would be treated as domain.com.domain.com..

Requests not routed through CloudFlare

I have my domain example.com on CloudFlare and a subdomain, fo.example.com, delegated to another name server.
This is the setting on CloudFlare
A www.example.com 1.2.3.4
CNAME test www.example.com
CNAME test2 www.google.com
CNAME test3 fo.example.com
plus the NS for fo. All the above have the orange icon, i.e. requests should go through CloudFlare.
and this is the setting on the other nameserver
A fo.example.com 5.6.7.8
Now, when I traceroute www.example.com, test.example.com and test2.example.com I can see that it goes through CloudFlare but when I traceroute test3.example.com it goes direct exactly as I traceroute fo.example.com. This looks incorrect to me, why requests to a CNAME pointing to an extrenal domain (google.com) goes through cloudflare and the one pointing to a delegated subdomain does not?
Very difficult to look at without knowing the actual subdomain in question. There are some records that can't be proxied (pointing to other CDNs, for example, does create DNS lookup issues in some cases).
CloudFlare supports answer:
That's not possible, no way around it either. I've tried.
Unfortunately our current system doesn't allow this. This has been a
feature request for awhile, it will get added eventually, but no ETA
as of right now, sorry.

Is it normal that a subdomain's CNAME record is suffixed with my domain?

I am using the Alternc control panel for shared hosting.
I am setting up a subdomain to point to github pages, as described here.
I need to point the CNAME record for my subdomain to .github.io, which I did with the alternc interface as seen in this image.
After waiting more than 24 hours, I got this message from github:
CNAME record should point to `your-username.github.io`, but it does not.
In effect, when visiting http://mxtoolbox.com/SuperTool.aspx?action=cname%3asommet.terredesjeunes.org&run=toolpage#, the CNAME record seems to be set to:
alberto56.github.io.terredesjeunes.org
not
alberto56.github.io
Same thing when running dig:
$ dig sommet.terredesjeunes.org +nostats +nocomments +nocmd
...
;sommet.terredesjeunes.org. IN A
sommet.terredesjeunes.org. 86400 IN CNAME alberto56.github.io.terredesjeunes.org.
I would be expecting to see the CNAME being alberto56.github.io, not alberto56.github.io.terredesjeunes.org. Is this a glitch with alternc, or am I not understanding something?
Thanks!
Albert.
Full DNS names need to end in a ., the root zone, otherwise the current zone is appended to the name. So, you want to set your CNAME to alberto56.github.io. with the terminal period to indicate that resolution should start from the root zone.

Adding A record to DNS in WHM's Zone Editor?

I'm trying to add a subdomain to my site and I'm not sure if my formatting is correct. I'm using WHM through cPanel, using the tool called "Edit Zone Templates".
Here's what I'm using now (a bit of context has been included):
localhost.%domain%. IN A 127.0.0.1
%domain%. IN MX 0 %domain%.
mail IN CNAME %domain%.
www IN CNAME %domain%.
ftp IN CNAME %domain%.
subdomain.%domain%. IN A 162.162.162.162
The last line is my addition (example IP used).
It takes a while to propagate, so I'd rather find a solution than keep trying new solutions and waiting a day to see if it worked properly.
If doesn't work, maybe it's
subdomain IN A 162.162.162.162
I don't know really know
I found the answer. It turns out WHM uses a standard DNS zone file.
So, the answer should be:
subdomain IN A 162.162.162.162
Here's a source:
http://en.wikipedia.org/wiki/Zone_file

Dynamic subdomain redirection

How do I redirect a dynamic subdomain to the same subdomain on a different domain?
*.example.com to *.example2.com
Can this be handled with Zerigo?
Depending on your exact requirements, you could achieve that with a DNAME record:
For example, you could have the following in your example.com zone file:
example.com. IN DNAME example2.com.
and a pretty standard example2.com zone, you can mostly achieve the effect.
Querying dig www.example.com, you'd get:
example.com. IN DNAME exmaple2.com.
www.example.com. IN CNAME www.exmaple2.com.
However, if you had DNS records that you need directly under either zones, e.g. an A, MX or TXT record, they don't "alias" so you need to store them in both zones.
In any case, DNAME is not supported in most DNS providers (Zerigo included) that only gives you a web interface, so you'd need to run your own DNS server.
In DNS you can not redirect, that is an HTTP function. But what you can do is use CNAMEs. A CNAME take a dns name and under the covers resolves it to another name. For example:
www.example.com resolves to www.example2.com. In the web browser the user will see www.example.com though.
What you will want to do is look into "wilcard CNAME". There is a limitation though. A wildcard CNAME will only point to a single address. This means that:
*.example.com will only ever point to a single address at example.com2 (let's say you pick bang.example2.com)
foo.example.com -> bang.example2.com
bar.example.com -> bang.example2.com
baz.example.com -> bang.example2.com
cux.example.com -> bang.example2.com
It is also important to note that not every DNS provider allows for wildcard CNAMEs. Also, not every DNS server allows wildcard CNAMEs. If you really want to have a wildcard CNAME point to the corresponding entry in example2.com, then you may want to look into powerDNS. It allows for 3rd party plugins written in various languages like lua. It also can be backed by a mysql, postgress, ldap, or a sqlite backed. This means that you can add that functionality yourself if it does not already exist.
Good luck

Resources