Launch Week Day 1:Rust Support in Socket Is Now Generally Available.Learn More
Socket
Book a DemoInstallSign in
Socket

dnsjack

Package Overview
Dependencies
Maintainers
1
Versions
6
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

dnsjack

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

Source
npmnpm
Version
0.3.0
Version published
Weekly downloads
1
-88.89%
Maintainers
1
Weekly downloads
 
Created
Source

DNSJack

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('www.google.com', '127.0.0.1'); // route all requests to www.google.com to localhost
jack.listen(); // it listens on the standard DNS port of 53 per default

// route all domains to 127.0.0.1
jack.route(function(domain, callback) {
	callback(null, '127.0.0.1');
});

// route all google domains to 127.0.0.1
jack.route(['google.com', '*.google.com'], function(domain, callback) {
	callback(null, '127.0.0.1');
});

// now all requests to google.com should be routed localhost
require('http').createServer(function(req, res) {
	res.writeHead(200);
	res.end('jack says hi!');
}).listen(80);

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 127.0.0.1 and visit http://www.google.com 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(domain) {
	console.log('Someone is resolving', domain);
});
jack.listen();

Keywords

dns

FAQs

Package last updated on 08 Oct 2014

Did you know?

Socket

Socket for GitHub automatically highlights issues in each pull request and monitors the health of all your open source dependencies. Discover the contents of your packages and block harmful activity before you install or update your dependencies.

Install

Related posts