← 全部工具

dns-zonefile

热度 65 更新于 网络与系统管理

A DNS zone file parser and generator.

npmauto-collected

安装

npm
npm install -g dns-zonefile

通过 npm 安装。

dns-zonefile ============ An RFC1035 compliant DNS zone file parser and generator for Node.js and browser.

Installation

Deno

import zonefile from 'https://deno.land/x/zonefile@0.3.2/lib/zonefile.js';

Standalone

npm install dns-zonefile -g

Module

npm install dns-zonefile

Usage

Zone Information

dns-zonefile accepts both zone data expressed as a JSON object or plain text zone file. It supports SOA, NS, A, AAAA, CNAME, MX, PTR, SRV, SPF, CAA, DS and TXT record types as well as the $ORIGIN keyword (for zone-wide use only). Each record type (and the $ORIGIN keyword) is optional, though bind expects to find at least an SOA record in a valid zone file.

Examples

#### Forward DNS Zone

The following JSON produces a zone file for a forward DNS zone:

{
    "$origin": "MYDOMAIN.COM.",
    "$ttl": 3600,
    "soa": {
        "mname": "NS1.NAMESERVER.NET.",
        "rname": "HOSTMASTER.MYDOMAIN.COM.",
        "serial": "{time}",
        "refresh": 3600,
        "retry": 600,
        "expire": 604800,
        "minimum": 86400
    },

{ "host": "NS1.NAMESERVER.NET." }, { "host": "NS2.NAMESERVER.NET." } ], "a": [ { "name": "@", "ip": "127.0.0.1" }, { "name": "www", "ip": "127.0.0.1" }, { "name": "mail", "ip": "127.0.0.1" } ], "aaaa": [ { "ip": "::1" }, { "name": "mail", "ip": "2001:db8::1" } ], "cname":[ { "name": "mail1", "alias": "mail" }, { "name": "mail2", "alias": "mail" } ], "mx":[ { "preference": 0, "host": "mail1" }, { "preference": 10, "host": "mail2" } ], "txt":[ { "name": "txt1", "txt": "hello" }, { "name": "txt2", "txt": "world" } ], "srv":[ { "name": "xmpp-client.tcp", "target": "jabber", "priority": 10, "weight": 0, "port": 5222 }, { "name": "xmpp-server.tcp", "target": "jabber", "priority": 10, "weight": 0, "port": 5269 } ] }


_dns-zonefile_ will produce the following zone file from the above information,
while the following zone file can as well be parsed to produce the zone file
like above:

; Zone: MYDOMAIN.COM. ; Exported (yyyy-mm-ddThh:mm:ss.sssZ): 2014-09-22T21:10:36.697Z