Skip to content
This repository
branch: master
Fetching contributors…

Cannot retrieve contributors at this time

file 146 lines (116 sloc) 3.132 kb
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 94 95 96 97 98 99 100 101 102 103 104 105 106 107 108 109 110 111 112 113 114 115 116 117 118 119 120 121 122 123 124 125 126 127 128 129 130 131 132 133 134 135 136 137 138 139 140 141 142 143 144 145 146
[This is the description of the JSON output format produced by the
*current* code. A work is going on at the IETF to specify a
DNS-in-JSON format
<http://tools.ietf.org/html/draft-bortzmeyer-dns-json>. The tool and
the IETF document may not agree at every moment.]

A DNS response is represented as a JSON object. The main members of
this object (the names are self-explanatory) are:

* QuestionSection
* AnswerSection
* AdditionalSection
* AuthoritySection
* ReturnCode (NOERROR, NXDOMAIN, SERVFAIL, etc)
* ID
* AA (Authoritative Answer)
* TC (TrunCation)
* RD (Recursion Desired)
* RA (Recursion Available)
* AD (Authentic Data)
* Query

It is common to omit some of these members, to save bandwidth or by
pure lazyness. So, clients who consume this sort of JSON objects
should not assume every member is present. <- THIS IS AN IMPORTANT
RULE

The Question Section is an object with members Qname, Qtype and
Qclass.

The other three sections are JSON arrays, each DNS record is an item
in the array. They may be empty array (for instance, if the request
returns NOERROR,ANSWER=0, the AnswerSection will be an empty array).

DNS resource records are objects. The following members are common to
all record types:

* Name (owner name)
* Type
* Class
* TTL

The other members depend on the record type.

A:
  * Address

AAAA:
  * Address

MX:
  * Preference
  * MailExchanger

NS:
  * Target

PTR:
  * Target

CNAME:
  * Target

SOA:
  * MaintainerName
  * MasterServerName
  * Serial
  * Refresh
  * Retry
  * Expire
  * NegativeTtl

DNSKEY:
  * Algorithm
  * Length
  * Flags
  * Tag

DS:
  * DelegationKey
  * DigestType

DLV:
  * DelegationKey
  * DigestType

NSEC3PARAM:
  * Algorihm
  * Flags
  * Salt
  * Iterations

SSHFP:
  * Algorithm
  * DigestType
  * Fingerprint

NAPTR:
  * Flags
  * Order
  * Services
  * Preference
  * Regexp
  * Replacement

SRV:
  * Server
  * Port
  * Priority
  * Weight

LOC:
  * Longitude
  * Latitude
  * Altitude

SPF:
  * Text

Note there is no concept of resource record sets.

The Query object has fields about the query: Time is the time of the
test, Duration is the number of seconds it took to process the
request, Server is the resolver used.

Examples:

{"Query": {"Server": "127.0.0.1"},
 "AnswerSection": [
       {"TTL": 6666, "Type": "AAAA", "Address": "2a03:2880:10:8f01:face:b00c::25"},
       {"TTL": 6666, "Type": "AAAA", "Address": "2a03:2880:2110:3f01:face:b00c::"},
       {"TTL": 6666, "Type": "AAAA", "Address": "2a03:2880:10:1f02:face:b00c::25"}],
 "ReturnCode": "NOERROR"}

{"Query": {"Server": "127.0.0.1"},
 "AnswerSection": [
       {"TTL": 397, "Type": "AAAA", "Name": "web.nic.fr.", "Address": "2001:660:3003:2::4:20"}],
 "ReturnCode": "NOERROR",
 "QuestionSection": {"Qtype": "AAAA", "Qname": "www.afnic.fr."}}

{"Query": {"Server": "127.0.0.1"},
 "AnswerSection": [
       {"Name": "bortzmeyer.fr.", "MasterServerName": "ns3.bortzmeyer.org.", "MaintainerName": "hostmaster.bortzmeyer.org.", "TTL": 3600, "Serial": 2012060801, "Type": "SOA"}],
 "ReturnCode": "NOERROR",
 "AD": true,
 "QuestionSection": {"Qtype": "SOA", "Qname": "bortzmeyer.fr."}}
Something went wrong with that request. Please try again.