Server Fault is a question and answer site for system and network administrators. Join them; it only takes a minute:

Sign up
Here's how it works:
  1. Anybody can ask a question
  2. Anybody can answer
  3. The best answers are voted up and rise to the top

Couldn't find this exact same question so here it goes:

I'm trying to setup a CNAME record to an elastic ip linked to a ec2-instance, but this fails. When deassociating the elastic-ip from the instance and linking it to the public dns of the instance it works as expected.

Isn't it allowed to point a CNAME to a ip-address (instead of a dns-name ) ?

btw: i'm not using an A-record, because I already us this to redirect the naked domain (e.g: to using the free service:

EDIT: more explicitly: I'd like both to point to which is an amazon elastic-ip (although I think that doesn't matter for this discussion) . Moreover I want redirect to

Any other way to to this? Since from an answer below it seems that indeed a cname can't link to an ip-address

share|improve this question
If there's another setup that lets me both redirect the naked domain to the www subdomain AND lets me assign a domain name to an ip-address using another DNS-setup, please let me know.. I'm a real newbie to this DNS stuff – Gbrits Mar 7 '12 at 14:45
Tell us explicitly what DNS names you want to create and what IPs you want them to point to. There is surely an easy solution to this. – EEAA Mar 7 '12 at 14:52
I edited my question to answer you comment – Gbrits Mar 7 '12 at 15:58
I edited my answer with more details on how to accomplish what you're seeking. – EEAA Mar 7 '12 at 16:11
up vote 8 down vote accepted

CNAME resource records specify a domain as an alias of another canonical domain name. As such, it cannot point to an IP address.

A and AAAA records define the canonical name and point to IP addresses. CNAMEs must reference those.

Create an A record for that points to Then create a CNAME record for that points to

Then in your webserver on the EC2 server, create a vhost for that does a 301 redirect to Details of how to do this are out of scope for this question, but there are many examples to be found here on Serverfault and elsewhere.

share|improve this answer
Thanks, Jeff...that last sentence was in my head, but apparently didn't make it out through my fingers. :) – EEAA Mar 7 '12 at 14:53

You may prefer to make the CNAME point to the AMAZON Elastic IP's DNS name.

eg. as CNAME to (may NOT be the actual amazon hostname)

The benefit from doing this is that externally your hostname will resolve to a public IP, but internal to Amazon, it will resolve to an PRIVTE IP for your instance.

(this will make calls to your site more direct and possibly cheaper when inside AWS)

share|improve this answer
yep that would definitely solve it as well. I totally missed that I could refer to an elastic ip by dns name.. thanks – Gbrits Mar 7 '12 at 17:06

Your Answer


By posting your answer, you agree to the privacy policy and terms of service.

Not the answer you're looking for? Browse other questions tagged or ask your own question.