# dnsjack

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

Latest version **1.0.0** (published 2016-08-08) · 0 weekly downloads

## Install

```sh
npm install dnsjack
pnpm add dnsjack
yarn add dnsjack
bun add dnsjack
```

## Health

**Score 15/100 (F)** — status: abandoned.

Positive: no vulnerabilities.

Warnings: low downloads; no types; no esm support.

Negative: abandoned; low maintenance score.

## Facts

| | |
|---|---|
| Version | 1.0.0 |
| Published | 2016-08-08 |
| First published | 2012-03-14 |
| Weekly downloads | 0 |
| TypeScript types | none |
| Module format | CommonJS |
| Dependencies | 0 |
| Known vulnerabilities | 0 |
| Install scripts | no |
| GitHub stars | 173 |
| Author | Mathias Buus Madsen |
| Maintainers | mafintosh |
| Keywords | dns, proxy, intercept, debug |

## Links

- npm: https://www.npmjs.com/package/dnsjack
- Repository: https://github.com/mafintosh/dnsjack
- Homepage: https://github.com/mafintosh/dnsjack#readme
- Issues: https://github.com/mafintosh/dnsjack/issues
- npm.io page: https://npm.io/package/dnsjack

## Alternatives

- [jsforce](https://npm.io/package/jsforce.md) — 851.2K weekly downloads
- [react-native-qrcode-svg](https://npm.io/package/react-native-qrcode-svg.md) — 693.5K weekly downloads
- [@salesforce/plugin-data](https://npm.io/package/@salesforce/plugin-data.md) — 394.9K weekly downloads
- [@backstage/plugin-search-common](https://npm.io/package/@backstage/plugin-search-common.md) — 308.5K weekly downloads
- [@chain-registry/types](https://npm.io/package/@chain-registry/types.md) — 38.4K weekly downloads

## Recent versions

- 1.0.0 (latest) — 2016-08-08
- 0.3.0 — 2014-10-08
- 0.2.1 — 2013-11-05
- 0.2.0 — 2013-10-26
- 0.1.1 — 2013-02-18
- 0.1.0 — 2012-03-14

## README

# 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:

``` js
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(data, callback) {
	callback(null, '127.0.0.1');
});

// route all google domains to 127.0.0.1
jack.route(['google.com', '*.google.com'], function(data, 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:

``` js
var jack = require('dnsjack').createServer();

jack.on('resolve', function(data) {
	console.log(data.rinfo.address, 'is resolving', data.domain);
});
jack.listen();
```

You can also pass along the TTL when responding to a DNS request:
```js
jack.route(['google.com', '*.google.com'], function(data, callback) {
    callback(null, {ip: '127.0.0.1', ttl: 3600});
});
```

---
_Source: https://npm.io/package/dnsjack · Machine-readable twin of the npm.io package page. Health data is recomputed on every publish._
