npm package discovery and stats viewer.

Discover Tips

  • General search

    [free text search, go nuts!]

  • Package details

    pkg:[package-name]

  • User packages

    @[username]

Sponsor

Optimize Toolset

I’ve always been into building performant and accessible sites, but lately I’ve been taking it extremely seriously. So much so that I’ve been building a tool to help me optimize and monitor the sites that I build to make sure that I’m making an attempt to offer the best experience to those who visit them. If you’re into performant, accessible and SEO friendly sites, you might like it too! You can check it out at Optimize Toolset.

About

Hi, 👋, I’m Ryan Hefner  and I built this site for me, and you! The goal of this site was to provide an easy way for me to check the stats on my npm packages, both for prioritizing issues and updates, and to give me a little kick in the pants to keep up on stuff.

As I was building it, I realized that I was actually using the tool to build the tool, and figured I might as well put this out there and hopefully others will find it to be a fast and useful way to search and browse npm packages as I have.

If you’re interested in other things I’m working on, follow me on Twitter or check out the open source projects I’ve been publishing on GitHub.

I am also working on a Twitter bot for this site to tweet the most popular, newest, random packages from npm. Please follow that account now and it will start sending out packages soon–ish.

Open Software & Tools

This site wouldn’t be possible without the immense generosity and tireless efforts from the people who make contributions to the world and share their work via open source initiatives. Thank you 🙏

© 2024 – Pkg Stats / Ryan Hefner

dnsgen

v0.0.1

Published

Generate DNS files using json

Downloads

14

Readme

DNS Generator

Generate DNS files using json

Install

Install the command line tool dnsgen

npm install -g dnsgen

Install locally to use as a module

npm install dnsgen

Usage

Command line

dnsgen bind reverse < example.json

As a module

var dnsgen = require('dnsgen');

Example

Command line tool

The command line tool reads json from stdin, and pipes the output to stdout

$ dnsgen bind < example.json
; Bind file for example.com (10.0.0.0/23)
@	IN	SOA	ns1.example.com.	admin.example.com. (
    2012081701	; serial
    28800	; refresh
    7200	; retry
    864000	; expire
    86400	; ttl
)
example.com.	IN	NS	ns1.example.com.
example.com.	IN	NS	ns2.example.com.
gw	IN	A	10.0.0.1
zelda	IN	A	10.0.0.2	; Testing Box
link	IN	A	10.0.0.3	; Another box for testing
gw2	IN	A	10.0.1.1

You can also generate reverse lookup files

$ dnsgen bind reverse < example.json
; Bind file for example.com (10.0.0.0/23)
@	IN	SOA	ns1.example.com.	admin.example.com. (
    2012081701	; serial
    28800	; refresh
    7200	; retry
    864000	; expire
    86400	; ttl
)
    IN	NS	ns1.example.com.
    IN	NS	ns2.example.com.
0.1	IN	PTR	gw.example.com.
0.2	IN	PTR	zelda.example.com.	; Testing Box
0.3	IN	PTR	link.example.com.	; Another box for testing
1.1	IN	PTR	gw2.example.com.

Tiny dns is also cool

$ dnsgen tinydns < example.json
# tinydns file for example.com (10.0.0.0/23)
Zexample.com:ns1.example.com:admin.example.com:2012081701:28800:7200:864000
&example.com::ns1.example.com:86400
&example.com::ns2.example.com:86400
=gw:10.0.0.1
=zelda:10.0.0.2	# Testing Box
=link:10.0.0.3	# Another box for testing
=gw2:10.0.1.1

Node Module

The exports of dnsgen return a stream that you can pipe anywhere you want

var dnsgen = require('dnsgen'),
    json = require('./example.json');

// Generate forward lookup file
dnsgen.bind(json).pipe(process.stdout);

// Generate reverse lookup file
dnsgen.bindReverse(json).pipe(process.stdout);

// Generate tinydns config
dnsgen.tinydns(json).pipe(process.stdout);

example.json

{
  "domain": "example.com",
  "admin": "admin.example.com",
  "time": {
    "refresh": 28800,
    "retry": 7200,
    "expire": 864000,
    "ttl": 86400
  },
  "ns": [
    "ns1.example.com",
    "ns2.example.com"
  ],
  "netmask": "10.0.0.0/23",
  "hosts": {
    "10.0.0.1": "gw",
    "10.0.0.2": {
      "name": "zelda",
      "comment": "Testing Box"
    },
    "10.0.0.3": {
      "name": "link",
      "comment": "Another box for testing"
    },
    "10.0.1.1": "gw2"
  }
}

Tests

npm test

Known Limitations

  • This module only supports outputting files suitable for BIND and tiny DNS servers.
  • Only A, NS and PTR records can be generated

License

MIT Licensed