Easy way to update your PowerDNS records via Git and a Sinatra server.
This will delete all PowerDNS records when you sync
PowerDNS has this cool feature that allows you to host your DNS domains and records in a SQL (any many other) datastores.
My idea is that I would rather work with my CLI tools and have revision control on my DNS records than logging into a web interface and changing my records.
The essential idea is that you will be hosting an simple Sinatra application that will be talking to the PowerDNS database. There is a Github repo that has a post-commit hooking point to an web server.
When you update your
domains repo and push to
github the post-commit hook
github will send a HTTP request to our server. The application will
download a recent copy of the
domains repo and then run a the
If it finds a zone file the
luvdns binary will send a HTTP POST request to
server to update the PowerDNS records.
Soon after the database records have changed PowerDNS will become aware and start serving those out.
Have a recent version of Ruby installed ( >= 1.9.3 ). Have a recent version of LuaJIT installed. Have a Github repo that holds your domains with a post commit hook point to the new application.
The format that I have is based on ideas from
First I'm going to assume you are a savvy person if you are running your own DNS.
Two methods to deploying that I find really easy. First deploy to Heroku, this would mean that you host your PowerDNS database on Heroku which might add some latency for each record requested, you might be able to get around this with some caching methods in PowerDNS config. The second method is via hosting it on your own server, which is what I do.
Use my domains repo as an example.
First is to get the server installed on a public facing internet machine.
I typically use
ruby-build to setup everything on the server.
git clone https://github.com/silas/luvdns.git cd luvdns bundle
After you have setup Ruby site, now you need to setup the Lua side. This is a little more difficult.
Dependences you need for Lua are:
- lua-filesystem (lfs)
Find these and stick them into a
LUA_PATH that you have access to.
luarocks will likely help you with this.
Change the settings (
config/settings.yml) to point to your PowerDNS database.
`bundle exec foreman start`
Look at the testing section to see how you can simulate Github sending a post commit hook, or even just to populate the initial database.
For production you will want to either deploy to Heroku or create an
file in the application directory:
Then setup a proxy server to forward requests to your application.
We only allow
Security, make sure you only accept requests on
/ from Github (or maybe not)
Testing the post commit hook from Github. Note this is only a subset of what Github will send when it sends it's payload.