DNS Server – How to Setup a DNS Server for On-the-Fly Record Addition

domain-name-systemdynamiclinux

I need to host a subdomain-based SaaS application on a bunch of servers. Servers are xx1.example.com, xx2.example.com and so on. I want to have a bunch of yyy.example.com sites hosted on those servers.

Because sites are created on the fly, I need to be able to set up DNS records on the fly as well. A DNS wildcard zone doesn't really scale as eventually I will outgrow the first server and need to push new instances onto other machines. I therefore need to be able to point a specific subdomain to a specific IP address.

I looked around for API-based cloud DNS services (which would be great) but they seem outrageously expensive for my needs (lots of low volume instances). Rackspace has a free Cloud DNS service but it only goes up to 500 zones, and tech support told me they are rewriting the API so I would like to avoid their service for the time being.

Therefore I figured I will set up my own DNS server for these zones. Hence the questions: what's a good DNS server software for this specific need that will allow me to create zones without restarting?

Any suggestions? Thanks!

Best Answer

If all the records you will be adding are a sub-domain of a specific zone, then you could easily setup bind for dynamic updates. Then simply use nsupdate to submit an update to the zone.

This should work fine, if all the new records are records within an existing domain. If you need to dynamically add other domains, then this won't really help.

// zone config
// using ip only for authentication, should really use hmac auth
zone "example.com" {
        type master;
        file "/etc/bind/dyn/example.com.dns";
        allow-query {any;};
        allow-update {
                127.0.0.1;
                192.0.2.0/24;
        };
};

Update script using nsupdate.

#!/bin/bash
record=yyy.example.com
(
 echo "server xx1.example.com"
 echo "zone example.com"

 echo "update delete ${record} A"
 echo "update add ${record} ${ttl} A 192.0.2.1"
 echo "send"
) | /usr/bin/nsupdate
Related Topic