1

I am fairly new to DNS managing. I have been attempting for a while now to point both my root domain @ and www to my GitHub account page user.github.io.

I have a CNAME pointing www to user.github.io., but for some reason I can't do a CNAME that points @ to user.github.io..

The error I'm getting is CNAME records cannot share a name with other records.

I don't have the slightest clue what that's supposed to mean, please help.

If it makes a difference I'm using DigitalOcean's DNS controls

Luiz Berti
  • 155
  • 1
  • 2
  • 5

1 Answers1

1

You'll need a host that acts as a URL rewriter / redirector. You'll point your DNS for domain.tld to a host running a web server (preferrably something super lightweight. Stripped down Apache, or nginx, or heck lighthttpd). That web server will then accept for domain.tld and immediately 301 redirect to user.github.io.

As for www.domain.tld, you can use a CNAME record for that, but then you'll have two different behaviors:

  • People go to domain.tld and are then redirect to a different URL: user.github.io
  • People go to www.domain.tld and stay at www.domain.tld but see the content of user.github.io (Assuming github allows that, which I won't go into the details of)

So you probably don't want the above behavior. Instead you probably want to add www.domain.tld to the list of URLs that your lightweight web server will handle redirects for.

Don't read this:

You can find DNS hosts that do apex CNAMEs but they're bad. Don't do it. It probably won't work for what you want it to do anyway.

Wesley
  • 32,320
  • 9
  • 80
  • 116
  • 1
    It's fine to recommend the non-standardized DNS features such as ANAME and ALIAS "records", but apex CNAMEs are violations of standards that should only be spoken of in single pixel font heights. – Andrew B Feb 16 '15 at 23:28
  • is there anything that won't require me to setup a whole webserver just for that purpose, or any "hack" such as what you mentioned of alias records that might do the trick? – Luiz Berti Feb 16 '15 at 23:30
  • @Luiz No, sadly. This is a well-known shortcoming of the DNS standards as they are written, which is why certain popular DNS hosting companies provide custom "fake" record types to accomplish this. Examples would be how DNSimple provides [ALIAS](http://support.dnsimple.com/articles/differences-between-a-cname-alias-url/), and DNSMadeEasy provides [ANAME](http://www.dnsmadeeasy.com/services/aname-records/). Short of this you're stuck with webserver redirection. (which is basically what these custom record types are doing on your behalf) – Andrew B Feb 16 '15 at 23:40
  • Well thats a shame. But what part of it is actually forbidden? 2 records pointing to the same resource or redirecting `@` with `CNAME`? Cause I haven't been able to `CNAME @ -> www` either. Does it detect the 2 hops and enforce the previous rule or what? Sorry for my stupidity but DNS is my biggest weakpoint... – Luiz Berti Feb 16 '15 at 23:43
  • 2
    Aliasing the apex with a `CNAME` is illegal per the standards, and Michael already linked to the technical explanation. Two records pointing to the same resource is fine. The error is because BIND is detecting that you are defining a `CNAME` at the top of your zone and refusing to allow it. Be careful with your usage of `@` in this discussion...the meaning of `@` is [the origin](http://www.zytrax.com/books/dns/ch8/origin.html), which defaults to the apex. It's the apex that is illegal, not `@`. – Andrew B Feb 16 '15 at 23:46