May 25, 2012
tom

How do you set up dynamic cname records?

Question

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


For example:

ec2-176-34-163-40.eu-west-1.compute.amazonaws.com
would map to
gf53ef.domain.com

and

ec2-123-31-124-60.eu-west-1.compute.amazonaws.com
would map to
sdfrh5.domain.com


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.

Thanks

Asked by Matt Votsikas

Answer

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 "mydomain.com" {
  type master;
  file "master/mydomain.com";
  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"
server ns1.mynameserver.com
zone domain.com
update delete gf53ef.domain.com.
update add gf53ef.domain.com.   IN  CNAME   ec2-176-34-163-40.eu-west-1.compute.amazonaws.com.
send
EOF

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

This seems to be the configuration reference docs for named;
http://www.zytrax.com/books/dns/ch7/xfer.html

Examples can be obtained from these tutorials;

http://www.centos.org/docs/5/html/Deployment_Guide-en-US/s1-bind-rndc.html
http://dag.wieers.com/howto/bits/bind-ddns.php
http://linux.yyz.us/nsupdate/
http://www.semicomplete.com/articles/dynamic-dns-with-dhcp/

Answered by Tom H

Related posts:

  1. Network DNS Issues Complicated by Amazon EC2 DNS CNAME
  2. Why is my EC2 Instance Timing out with a CNAME?
  3. How to configure SRV records on Ubuntu (running on Amazon EC2)?
  4. Setting CNAME at abc.example.com to redirect to amazon EC2 instance
  5. Can you combine dhcp dynamic dns updates and static IPs in the same Bind zone?

Leave a comment