Sign up ×
Server Fault is a question and answer site for system and network administrators. It's 100% free, no registration required.

The project I'm working on requires that we mask AWS EC2 host names with our own subdomains.

For example: would map to

and would map to

There will always be list available that stores the relationship between the domains.

This list changes ALL THE TIME. Meaning in one minute we could have 100+ new ec2 instances started, and the next all could terminate.

I'm wondering how to set up our Ubuntu server to handle this case.


share|improve this question
Have you checked out Route53 ? – Shyam Sundar C S May 26 '12 at 6:18
Have done now thanks. Check out the answer. – Matt Votsikas May 27 '12 at 13:47

2 Answers 2

I am dong something similar on an openstack cloud for instance DNS name updates (probably not as dynamically as your requirement ;-), basically we have a bind named instance that accept dynamic updates.

I used webmin to configure the remote control using RNDC, and the basic bind configuration.

enter image description here

and then generate a key for remote access, and distribute it to your control node;

dnssec-keygen -a hmac-md5 -b 128 -n HOST remote-key  

the zone-file ends up like this;

zone "" {
  type master;
  file "master/";
  allow-update { key "remote-key"; };

allow-update provides the permission to update the master zone, allow-notify is the slave zone equivalent.

and then you can do something like this (nsupdate from bind-utils) to update the records from a client, I've not tested a CNAME update, but it should look something like this;

cat <<EOF | nsupdate -d -k "$KEY"
update delete
update add   IN  CNAME

(you might have to double check the format for the CNAME example...)

This seems to be the configuration reference docs for named;

Examples can be obtained from these tutorials;

share|improve this answer
I am using ubuntu and your line didn't not work for me, but this nsupdate command did "add 3600". The following is logged in syslog "....named.....updating zone '': adding an RR at '' CNAME". When "I grep CNAME /var/cache/bind/" the output is "CnameHost CNAME hostname_with_a_record". – Keith Reynolds Jul 1 at 2:19
up vote 1 down vote accepted

Thanks @CS3

Our solution is Route53 for now.

Here's how we set it up (PHP). We used this library:

private function getDomain() {
    $sub = "e-".substr(md5($this->instance->dnsName), 2, 4);
    $domain = $sub."";

    $dnsRecords = $this->route53->listResourceRecordSets('/hostedzone/123');

    $exists = false;
    foreach($dnsRecords["ResourceRecordSets"] as $dnsRecord) {
        if($dnsRecord["Name"] == $domain."." 
            AND $dnsRecord["Type"] == "CNAME") {
                $exists = true;

    if(!$exists) {
        $change = $this->route53->prepareChange('CREATE', $domain.".", 'CNAME', 300, $this->instance->dnsName);
        $this->route53->changeResourceRecordSets('/hostedzone/123', $change);

    return $domain;

private function removeDomain() {
    $change = $this->route53->prepareChange('DELETE', $this->domain.".", 'CNAME', 300, $this->instance->dnsName);
    $this->route53->changeResourceRecordSets('/hostedzone/123', $change);
    $this->domain = null;
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.