ldns
Local dns
server for development.
This basically allows you to have wildcard subdomains on your local machine, which /etc/hosts doesn't allow.
Installation
➜ npm install -g ldns
Usage
➜ ldns -h Usage: ldns [ <options> ... ] Options: --port Port to bind on.--zones Path to JSON file with zones info.--debug Switch logging level to debug.-h, --help Show this help.-v, --version Show ldns version.
Zones
By default the following zones are used.
These are based on my own use case, where I have a a proxy running on
my machine and a docker virtual machine. With the default zones the
dev
domain (and all its subdomains, ie: app1.dev
, app2.dev
, ...)
will resolve to 127.0.0.1
and the docker
domain and all its
subdomains resolve to 192.168.59.103
.
You can also configure records for subdomains. In the example below
vm-1.vms
and vm-2.vms
resolve to two different IP addresses.
Common pitfalls
By default ldns
will try to bind to port 53
, which means that you
need to run ldns
as root
, otherwise you will get an error like this:
➜ ldns | bunyan[2015-03-13T22:58:47.214Z] ERROR: ldns/1115 on Lupos-MacBook-Pro-Retina.local: bind EACCES Error: bind EACCES at errnoException at dgram.js:211:28 at dns.js:72:18 at process._tickCallback at Function.Module.runMain at startup at node.js:929:3
To run as root
on default port (53) and in the background try this:
➜ sudo ldns &>/dev/null &
Or using nohup
to dettach the process from the current shell.
➜ sudo nohup ldns &> /dev/null
Otherwise you can specify a higher port number via command line arguments.
➜ ldns --port 15353 | bunyan➜ ldns --port 15353 --debug | bunyan