node package manager
Share your code. npm Orgs help your team discover, share, and reuse code. Create a free org »



A simple DNS proxy that lets you intercept domains and route them to whatever IP you decide.

It's available through npm:

npm install dnsjack

It's easy to use:

var jack = require('dnsjack').createServer();
jack.route('', ''); // route all requests to to localhost 
jack.listen(); // it listens on the standard DNS port of 53 per default 
// route all domains to 
jack.route(function(data, callback) {
    callback(null, '');
// route all google domains to 
jack.route(['', '*'], function(data, callback) {
    callback(null, '');
// now all requests to should be routed localhost 
require('http').createServer(function(req, res) {
    res.end('jack says hi!');

You probably need to run the above example with sudo as we need to listen to port 80 and 53. Now change your local DNS server to and visit in your browser.

DNSJack will forward all request that you don't route yourself to Google's DNS server or whatever DNS you provide in .createServer().

You can also use it to monitor your DNS resolutions which can be super useful for debugging:

var jack = require('dnsjack').createServer();
jack.on('resolve', function(data) {
    console.log(data.rinfo.address, 'is resolving', data.domain);

You can also pass along the TTL when responding to a DNS request:

jack.route(['', '*'], function(data, callback) {
    callback(null, {ip: '', ttl: 3600});