Using a CNAME to forward traffic from a naked domain

5,080

Solution 1

You cannot have a CNAME for the domain.

CNAMEs can only exist as single records and not combined with any other resource records. Since a domain always has a SOA and NS record, you cannot use a CNAME for the domain. This is specified in RFC 1034, section 3.6.2.

The reason that email specifically breaks is found in RFC 5321, section 5.1:

That domain name, when queried, MUST return at least one address record (e.g., A or AAAA RR) that gives the IP address of the SMTP server to which the message should be directed. Any other response, specifically including a value that will return a CNAME record when queried, lies outside the scope of this Standard. The prohibition on labels in the data that resolve to CNAMEs is discussed in more detail in RFC 2181, Section 10.3.

In other words - as long as your provider does not allowed A records, what you want cannot be done.

Solution 2

It doesn't sound like you know the correct definition of FQDN. It also doesn't sound like you know what a CNAME is for.

You will need to add in an MX record for your domain if you plan on sending mail there. Make sure that is added correctly and that your server is correctly configured to process mail.

Solution 3

The solution is buried in the comments and not explained well. Here is the full solution from Micheal Hampton:

  1. Setup a CNAME from www.flyh2.com to flyh2.elasticbeanstalk.com. When using www. this will redirect web requests to the Amazon web server.
  2. Setup an A Record from flyh2.com to 174.129.25.170. That IP has a web server that redirects naked domains to www. subdomains. This will redirect web traffic from the naked domain flyh2.com to www.flyh2.com. www.flyh2.com will redirect to flyh2.elasticbeanstalk.com (because of the cname above.)
  3. Setup a MX record from flyh2.com to its mail server. Mail sent to flyh2.com will ignore the CNAME since it only applies to www.flyh2.com. The mail will ignore the A record and instead use the MX record, which points at the mail server. Web traffic will go to elasticbeanstalk and mail to the mail server.
Share:
5,080

Related videos on Youtube

sparkyspider
Author by

sparkyspider

I have a passion for writing complex code in such a simple and understandable (followable) manner that a kid can understand and maintain it.

Updated on September 18, 2022

Comments

  • sparkyspider
    sparkyspider over 1 year

    I have a domain, flyh2.com.

    I use a CNAME to forward www.flyh2.com to flyh2.elasticbeanstalk.com where my web site is hosted. This is the only way Amazon allows custom domain names. A records aren't allowed.

    I'd like people to simply type http://flyh2.com (without the www) and still have visitors see my web site.

    Originally I used CNAME to forward both the naked and the www records to my web site, but it seemed to cause problems.

    Incoming mail was being returned to sender:

    Fwd: Returned mail: see transcript for details
    <[email protected]>... Deferred: Connection timed out with flyh2.elasticbeanstalk.com.
    Message could not be delivered for 6 hours
    Message will be deleted from queue
    

    Seems that the CNAME on the naked domain was overriding the MX records.

    Now I've changed the CNAME on the flyh2.com record to point to www.flyh2.com and in turn www.flyh2.com to CNAME to flyh2.elasticbeanstalk.com.

    My MX records are set up correctly, but the CNAME on the naked domain seems to override them. Do I have to use an A record?

    • NickW
      NickW about 10 years
      How is your zone set up, I used to put in an A record for my unprefixed domains pointing to the web server that hosted the site..
    • MadHatter
      MadHatter about 10 years
      I fear you may be quite badly confused. flyh2.com is not an unqualified domain name; www is an unqualified domain name. That said, you may find that looking into MX records helps you solve your problem. And thank you for not redacting the domain name, at least!
    • sparkyspider
      sparkyspider about 10 years
      @NickW I can't use an A record. It has to be a CName.
    • sparkyspider
      sparkyspider about 10 years
      @MadHatter, I changed my terminology to naked domain. I hope that's more correct.
    • NickW
      NickW about 10 years
      @MarkvanWyk If you're sure (a CNAME could work too), I'd still like to see how you have the zone set up.
    • Michael Hampton
      Michael Hampton about 10 years
  • sparkyspider
    sparkyspider about 10 years
    Read up on FQDN. True. I was confused. I have to use CNames. Thats how Amazon Web Services works. The MX records are set up correctly and working. Mostly.
  • Fathpath
    Fathpath about 10 years
    This doesn't even apply because 'www' is a subdomain.
  • Jenny D
    Jenny D about 10 years
    Yes, 'www' is a subdomain. However, the question is how to use a CNAME for the domain itself, in addition to the subdomain.
  • Fathpath
    Fathpath about 10 years
    I understand CNAMEs. Your post if quite difficult to understand so sorry if I misunderstood you.
  • Fathpath
    Fathpath about 10 years
    In that case, OP is very bad at explaining this. The sentence "I use a CName to forward www.flyh2.com to flyh2.elasticbeanstalk.com where my web site is hosted. This is the only way Amazon allows custom domain names. A records aren't allowed." conveys that the issue is with the subdomain.
  • Jenny D
    Jenny D about 10 years
    Try reading the rest of the question.
  • sparkyspider
    sparkyspider about 10 years
    Now using an A record to point the naked domain to a free redirect service - wwwizer.com/naked-domain-redirect - working like a charm...
  • Jenny D
    Jenny D about 10 years
    I'm glad it works!