tags:

views:

587

answers:

4

I would like to automatically update my DNS more multiple domains programmatically. I run a BIND server (on FreeBSD) as well as host domains and DNS at GoDaddy. I could not find a web service API for GoDaddy to access and update my DNS that they are hosting so I may have to use my BIND server to provide a dynamic solution.

Basically I just want to query which sub-domains already exist and add new ones.

Is BIND the best solution? Is there another way to automatically add new domains without me having to log into GoDaddy or update my BIND configuration manually?

+3  A: 

One approach would be to write a program that reads and/or updates the BIND configuration file (it's just a text file, with a specific format) and reloads the BIND daemon if any changes have been made. So, it would be as if you updated your BIND configuration manually, except you'd have written a program to do it for you.

Greg Hewgill
+2  A: 

The feature you need to add new sub-domains is Dynamic Updates, as specified in RFC 2136, and well supported by BIND.

It's reasonably easy (for example with Perl's Net::DNS module) to add and remove records from a zone file with the DNS "UPDATE" message.

To actually retrieve what's there, you've got two approaches:

  1. Treat some other database as definitive, and convert changes in that database into ddns updates, or.

  2. Permit DNS "AXFR" messages to allow you to download the entire zone content (albeit only to your zone management system, not to the whole world!)

Alnitak
+1  A: 

Just FYI: this is a systems/network administration question, not a programming question. You probably could have got better answers more quickly elsewhere.

That said... it's fairly simple: you just need a DNS server that supports a database backend for its data. Then you just write entries to the database, or query the database for what's in there, and the DNS records will be served out automatically. Ideally, use a database that supports triggers so you can have the DNS records' serial numbers update automatically on changes. Otherwise, you'll need to read/write the serial in every change from your code, doing the whole update within a transaction.

Edit: just saw the other comment above. Don't allow AXFR. That's considered a security risk these days.

Do have the domain TTLs set lowish so updates propagate to other servers quickly, though.

Lee B