MongoDB configuration for Bind9
This is just a simple hack in order to use MongoDB as database with a REST backend.
Install :
- Install libcurl-dev and json-c library
- Clone git://github.com/guillaumerose/bind-http-json.git
- Build as usual
- ./configure
- make
- make install
- Run named with following configuration and web server
Sample configuration :
controls { /* empty */ };options { directory "/var/cache/bind";allow-transfer { any; }; // auth-nxdomain no; listen-on-v6 { any; }; };zone "example.com" { type master; database "remote http://127.0.0.1:4567"; };
Ruby server :
require 'rubygems' require 'mongo' require 'sinatra'db = Mongo::Connection.new('flame.local.mongohq.com', 27078).db('development') db.authenticate("***", "***") coll = db.collection('data')get '/example.com/lookup' do content_type "application/json"entry = coll.find_one({"name" => params[:name]})return '{}' if entry.nil?'{"type" : "' + entry['type'] + '", "field" : "' + entry['value'] + '"}' endget '/example.com/authority' do content_type "application/json"'{ "data" : [ { "type" : "SOA", "field" : [ "ns1.example.com.", "dns.example.com.", 2010122701 ] }, { "type" : "NS", "field" : "ns1.example.com." }, { "type" : "NS", "field" : "ns2.example.com." } ] }' end
This server assumes that your document looks like { “name” : “www”, “type” : “A”, “value” : “192.168.0.1”}
© Guillaume Rose
Under the same licence as Bind