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

Seems the Public DNS, e.g. will be changed when you stop or terminated the instance.

So this mean they have the same life span as the ec2 public IP address, so why should I use this public DNS? They are not easy to remember, and rather meaningless..

share|improve this question
In certain cases, where you can setup only CNAME records., the public DNS comes into play. – Shyam Sundar C S May 15 '12 at 17:18
@CS3, you can do it by using A record to the instance. Since both the public IP and DNS have the same lifespan. – Ryan May 15 '12 at 17:38
'A' Records can be mapped to IP addresses. But if the same machine exposes different services with the same address, CNAMEs can help convey meaningful domain names. ( Eg: ftp.domain.tld, www.domain.tld ). – Shyam Sundar C S May 15 '12 at 18:02
There is only one difference between the public DNS and public IP. See my answer below. – Eric Hammond May 15 '12 at 19:06
up vote 20 down vote accepted

The public DNS name (whether elastic IP address or not) is exactly the same as using the public IP address (elastic IP or not) with the one following important difference:

If you query the public DNS name from outside of EC2, it resolves to the public IP address. If you query the public DNS name from inside of EC2, it resolves to the private IP address.

You can use this trick with or without Elastic IP addresses. I recommend using Elastic IP addresses as it keeps the public DNS name the same even after stop/start or moving your service to another EC2 instance. Because of this, you can always use the public DNS name of the Elastic IP address and it will resolve to the internal IP address of the current instance to which the Elastic IP is associated.

You can extend this by using a CNAME DNS entry where you map your preferred hostname to the external DNS name of the Elastic IP.

Here's an article I wrote about using this feature to save money and speed up network performance with internal EC2 communication without having to keep track of the current internal IP address for each instance on all your other instances:

Other than this one difference, I agree that you might as well use the public IP address instead of the public DNS name because:

  1. You save time by not doing a DNS lookup

  2. You avoid any security risks that occasionally arise in the DNS protocol.

so I suppose, in reality, right there are two more differences...

share|improve this answer
Thanks for your good points on money saving. – Ryan May 16 '12 at 5:22

You'd use the EC2 public address to do things like SSHing into that server, or for interconnecting EC2 instances, or any number of other things.

If you need a consistent address (say to point users at), you'd provision an Elastic Load Balancer or an Elastic IP to sit in front of your instance(s).

Also, within EC2, public DNS resolves to the instance's internal IP, but outside EC2 it resolves to the external IP. This can be useful at times, as communicating between EC2 nodes using the private IP saves you money.

share|improve this answer
Doesnt answer the question asked. Whatever you said, could be done using IP addresses also. – Shyam Sundar C S May 15 '12 at 17:20
@Yoga If you don't need it, don't use it. What, exactly, are you going for here? – ceejayoz May 15 '12 at 17:40
ceejayoz did answer the question in the third paragraph (DNS resolution inside and outside of EC2). I've expanded on this in my answer which only focuses on this difference. – Eric Hammond May 15 '12 at 19:08
@EricHammond In fairness, I was editing that in when Yoga posted. – ceejayoz May 15 '12 at 19:14

Well they only change when you stop the instance. If your instance is going to be long lived you can just point a CNAME to it and it will work. They're not completely useless, they are just transient.

share|improve this answer

You can use Elastic IP's

Here is an article on them

share|improve this answer

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.