Discussion Forums



Thread: instance hostnames and dyndns

This question is answered. Helpful answers available: 1. Correct answers available: 1.

Welcome, Guest Help
Login Login


Permlink Replies: 13 - Pages: 1 - Last Post: Nov 27, 2007 9:58 AM by: G. Frank
brian mcqueen

Posts: 19
Registered: 10/21/06
instance hostnames and dyndns
Posted: Dec 28, 2006 10:08 PM PST
 
  Click to reply to this thread Reply

How do you folks handle the changing name of an instance?  If I want to put up a host for a third party, how am I to give them a single simple name, even their own domain name that goes to the instance.  Would I need to use dynamic dns and reregister the instances each time i start it up?

For example:

I want to give someone an instance with a name like:

www.coolinstance.com

but the real name of the instance is  somthing that changes each time its started.  How can I handle this?

Brian


richdougherty

Posts: 1
Registered: 1/1/07
Re: instance hostnames and dyndns
Posted: Jan 1, 2007 7:49 PM PST   in response to: brian mcqueen
 
  Click to reply to this thread Reply

Hi mcqueenorama

> Would I need to use dynamic dns and reregister the instances each time i start it up?

I think you're right - you'll need to re-register the IP address of an instance each time it starts.

> but the real name of the instance is somthing that changes each time its started. How can I handle this?

I'm not quite sure what you mean here. When you say 'real name', do you mean the default domain name that Amazon assigns the instance (eg domU-12-34-31-00-00-05.usma1.compute.amazonaws.com)?

If that's what you mean, then I wouldn't worry. Just go ahead and register the instance's IP address with another domain name - you can register more than one domain name an IP address.

Rich

--
Rich Dougherty
http://www.rd.gen.nz/

propelbill

Posts: 57
Registered: 9/1/06
Re: instance hostnames and dyndns
Posted: Jan 3, 2007 6:52 AM PST   in response to: brian mcqueen
Helpful
  Click to reply to this thread Reply

First of all, you'll need to employ a dynamic DNS service.  I like dnsmadeeasy.com
.  If you go there you'll find very clear instructions.

The basic process (after you have configured things at your dynamic DNS provider) is (on the EC2 host) to:
a. determine the IP address of that host
b. associate that IP address with a fullly-qualified-domain-name (FQDN) via an HTTP call to the dynamic DNS provider
If you're using dnsmadeeasy you might execute a command like this:

curl "https://www.dnsmadeeasy.com/servlet/updateip?username=mybigbidness&password=8dfn88ndYDI89&id=12345&ip=$(curl http://www.dnsmadeeasy.com/myip.jsp | tail -n 1)"
 
The inner http call determines the IP of your EC2 host dynamically.  The outer call associates that IP number with the FQDN associated with DNS record 12345 (given by the "id" parameter).

If you want this registration to happen each time a certain AMI is run (via ec2-run-instances) then you can add that line to /etc/rc.local -- I add it near the top after the "touch" line.  If you do that you'll probably also want to add this line immediately after:

hostname "my.customer.host.name.com"

Where the FQDN given to hostname matches the one you configured with your dynamic DNS provider.

If you do not want to "bake" this into the AMI -- but instead wish to have an agnostic AMI and determine the identity based on parameters sent to ec2-run-instances you can do that insteady.  In that case you have to add a little more sophistication to the the lines (shown above) for /etc/rc.local.  For more information on this approach see the Developer Connection article on Parameterized Launches: http://developer.amazonwebservices.com/connect/entry.jspa?externalID=531&categoryID=100


steveodom@mailshell.com

Posts: 18
Registered: 2/8/06
Re: instance hostnames and dyndns
Posted: Jan 12, 2007 11:51 AM PST   in response to: propelbill
 
  Click to reply to this thread Reply

This was a helpful post, propelbill.

I'm also using dnsmadeeasy. It took me a few minutes to figure out what the record id (id=12345) you reference. I figured it out once I added a record to my domain name, set it to dynamic, and then it gave me a record id. I get it now.

What does the hostname command do or why do I need it?

One bit of clarification needed. if my domain name is mydomain.com, then that command would be hostname "mydomain.com"?

thanks,

steve


propelbill

Posts: 57
Registered: 9/1/06
Re: instance hostnames and dyndns
Posted: Jan 12, 2007 12:34 PM PST   in response to: steveodom@mails...
 
  Click to reply to this thread Reply

The hostname command with parameter sets the hostname so that subsequent calls to hostname (with no parameters)will get that name.  This is used by many parts of the system including (often) the shell prompt.  So by setting it correctly, when you shell into the host you get a prompt that reminds you which host you're on.


Nikita Dubrovsky

Posts: 20
Registered: 1/15/07
Re: instance hostnames and dyndns
Posted: Jan 31, 2007 2:45 PM PST   in response to: propelbill
 
  Click to reply to this thread Reply

> The outer call associates that IP number with the FQDN associated with DNS record 12345 (given by the "id" parameter).

Do you know if it's possible to create a new DNS record programatically instead of having to use an existing one? This way an instance could just take the friendly DNS name "my.customer.host.name.com" string as a parameter and create a new DNS record for itself.


propelbill

Posts: 57
Registered: 9/1/06
Re: instance hostnames and dyndns
Posted: Feb 1, 2007 2:57 PM PST   in response to: Nikita Dubrovsky
 
  Click to reply to this thread Reply

I don't think you'd want to create a DNS record like that even if you could since the point of a DNS entry is that users/customers know the name. None of your users/customers will know that name so it won't do any good to have a DNS entry for it.

DNS is useful for mapping a well known name to a (not well known or changing) IP number.

Nikita Dubrovsky

Posts: 20
Registered: 1/15/07
Re: instance hostnames and dyndns
Posted: Feb 1, 2007 3:32 PM PST   in response to: propelbill
 
  Click to reply to this thread Reply

The idea is that the customer would be the one to request a name. After validating that the name is not already taken, I would like to start an EC2 instance with the requested name as a subdomain of my domain: customerRequestedName.mydomain.com. The requested name can be passed to the instance as a parameter, and a startup script on the instance would create a new DNS record and email the URL to the customer.

Any help on how to create the new DNS record programatically would be much apreciated.

Nikita Dubrovsky

Posts: 20
Registered: 1/15/07
Re: instance hostnames and dyndns
Posted: Feb 11, 2007 12:02 PM PST   in response to: brian mcqueen
 
  Click to reply to this thread Reply

> Any help on how to create the new DNS record programatically would be much apreciated.

You can do this with zoneedit (the query will automatically update or create a new record):

wget -q -O - --http-user=<YOUR-USERNAME> --http-passwd=<YOUR-PASSWORD> " http://dynamic.zoneedit.com/auth/dynamic.html?host=new.mydomain.com"

More info here: http://www.zoneedit.com/doc/dynamic.html


mcdonaec

Posts: 23
Registered: 2/8/06
Re: instance hostnames and dyndns
Posted: Feb 11, 2007 1:40 PM PST   in response to: Nikita Dubrovsky
 
  Click to reply to this thread Reply

ZoneEdit is a good choice. I use the following in a startup script that gets run on boot to assign hostnames:

wget -q -O /tmp/user-data.out http://169 . 254 . 169 . 254 / 1 . 0 /user-data
HN=`cat /tmp/user-data.out`
rm -f /tmp/user-data.out
wget -q -O - --http-user=<username> --http-passwd=<password>" http://dynamic.zoneedit.com/auth/dynamic.html?host=$HN" > /dev/null 2 > /dev/null
hostname $HN

Then when I create an instance I can use the metadata to give the instance a name:

ec2-run-instances ami-2bb65342 -k gsg-keypair -d "www09.example.com"


Jeff Condal

Posts: 8
Registered: 6/14/07
Re: instance hostnames and dyndns
Posted: Jun 14, 2007 8:57 AM PDT   in response to: brian mcqueen
 
  Click to reply to this thread Reply

I am looking into all of these Dynamic DNS services, and it definitely seems like people have had a lot of success using them. Especially the ability that they have to do load balancing via round robin. But, I have another question to add to this thread.

It seems that IPs are no longer guaranteed for the life of an instance, according to what I've read in the forums lately, specifically this thread:
http://developer.amazonwebservices.com/connect/thread.jspa?messageID=49282&#49282
(look for Quinton's post)

Do dnsmadeeasy and/or zoneedit allow for programmatic access to the CNAME property so we can use the supplied DNS Name for the instance? It would be nice to use a script to update the CNAME with these services, as it seems like it's the safest way to go.

razvandragomirescu

Posts: 25
Registered: 6/19/06
Re: instance hostnames and dyndns
Posted: Jun 14, 2007 9:41 AM PDT   in response to: brian mcqueen
 
  Click to reply to this thread Reply

Are they serious about the IP addresses changing while an instance is running??? This would be ridiculous, especially if you have ongoing connections established with other servers. For instance, in our streaming environment, we need to be able to rely on at least the public IP of the server (it needs to be present in the Darwin Streaming Server config files and it is sent to clients). A change of public IP would mean restarting the streaming server and killing all the existing clients. NAT is already messing things up for this kind of scenario, but a variable IP address would mess things up even more.

Razvan

Brent@AWS

Posts: 85
Registered: 10/25/06
Re: instance hostnames and dyndns
Posted: Jun 14, 2007 2:52 PM PDT   in response to: razvandragomire...
 
  Click to reply to this thread Reply

While Quinton points out that this is something we would like to thinkabout, IP addresses are stable for the lifetime of the instance.  Wewould not consider changing this behavior without significant dialoguewith our customers.

G. Frank
RealName(TM)

Posts: 2
Registered: 11/27/07
Re: instance hostnames and dyndns
Posted: Nov 27, 2007 9:58 AM PST   in response to: mcdonaec
 
  Click to reply to this thread Reply

I've found that the easiest is to install one of the automatic updating clients from dyndns.  http://www.dyndns.com/support/clients/unix.html.  That way you don't have to worry about the IP changing mid-session - it's always kept up to date. 
And dyndns also works with most hardware routers (eg. I have a router flashed with DD-WRT firmware and it has a built-in dyndns updating client).





Point your RSS reader here for a feed of the latest messages in all forums