Simple DNS for Developers with DevDNS

Posted on August 5th, 2014 in Node.js, Development, Devops by Rich

I was working on a project recently whereby customers can point their own domain to the application and it directs to their part of the application. Due to confusion at the client side and a misconfiguration on the application, their domain went live pointing to the wrong part of the application; quite embarassing for all parties.

We all know what its like. "What do you mean it can take 24-48 hours to go live?!" with a time scale that long, it can be difficult to ensure everything is going to be ok. You can change your host file and thats great, but what about your PM or your AM? What if you're pointing to an AWS Elastic Load Balancer which requires DNS CNAME records?

Introducing DevDNS

DevDNS is a simple, easy to use DNS server which aids development and testing. You can run it on your development machine, your PM & AM can run it on theirs or you can sit it inside your network and have EVERYONE use it.

Why use DevDNS?

Simplicity is at the heart of DevDNS, as is usability. The server has a built in web interface allowing users to quickly and easily add new records as well as an API allowing developers to programmatically create records; perhaps as part of an integration test.

How do I get it?

Firstly, you need to download and install Node.js. Once you have, you can open up a terminal and install devdns via npm:

npm install -g devdns

Run devdns from the terminal as a user with elevated privileges as the DNS server runs on port 53:

sudo devdns

By default DevDNS uses a file-based store for its records, but it also has the ability to use MongoDB. To use MongoDB, pass the connection string via an argument:

sudo devdns --mongo mongodb://localhost:27017/devdns

DevDNS comes with a web interface which runs on port 3000 by default, but you can specify a different port by passing the --webport argument:

sudo devdns --webport 8888

What about the API?

A very simple REST API which you can access via http://address:port/api/dnsrecord/

GET /api/dnsrecord/
- Returns all DNS records
GET /api/dnsrecord/
- Returns single DNS record with ID
POST /api/dnsrecord/
- Create new DNS Record
PUT /api/dnsrecord/
- Update DNS Record with id
DELETE /api/dnsrecord/
- Delete DNS Record with id

Source is available on my BitBucket Repo if you want to contribute.

comments powered by Disqus