dnsdbq(1)
π dnsdbq β DNSDB query tool π
okay bestie, gather round, because this is dnsdbq(1) from the General Commands Manual and it's genuinely iconic. it's a whole command-line tool that builds and fires off queries at Passive DNS systems, and it's the one everybody actually uses in production. no cap. π₯
β¨ NAME β¨
dnsdbq β the DNSDB query tool. that's it, that's the name, short and slay.
πΈ SYNOPSIS πΈ
dnsdbq [-acdfgGhIjmqSsUv468] [-A timestamp] [-B timestamp]
[-b bailiwick] [-D asn_domain] [-i ip] [-J input_file]
[-k sort_keys] [-L output_limit] [-l query_limit] [-M max_count]
[-C cookie_file] [-N hex[/rrtype[,...]]] [-n name[/rrtype[,...]]]
[-O offset] [-o timeout] [-p output_type]
[-R hex[/rrtype[,...][/bailiwick]]]
[-r name[/rrtype[,...][/bailiwick]]] [-T transform[,...]]
[-t rrtype[,...]] [-u server_sys] [-V verb] [-0 function=thing]
like yes, that is a LOT of brackets. she contains multitudes. π
π¦ DESCRIPTION π¦
so here's the tea: dnsdbq builds queries and sends them off to Passive DNS systems that hand back data in the IETF Passive DNS Common Output Format. and bestie, it's commonly used as an actual production command line interface to those systems. main character energy fr fr. π
it can show you responses in a bunch of different formats, and its default query type is a "lookup" query. if you want, it can also do a "summarize" query type instead. heads up though β different Passive DNS systems, or even different versions of the same system, might implement different query features. so it's giving "your mileage may vary" but make it cute. π
π FARSIGHT SECURITY'S DNSDB π
Farsight Security's "DNSDB" is one of those Passive DNS systems, and you get to it by specifying the system dnsdb.
you're gonna need to get an API key from Farsight to use dnsdbq with DNSDB. no key, no queries, bestie. π
Farsight's passive DNS infrastructure does this whole complex process called "bailiwick reconstruction", where an RRset's position inside the DNS hierarchy gets approximated. and it's doing that for two reasons:
- to give you context about where a given DNS record sits within the DNS hierarchy.
- to stop "untrustworthy" records β the ones that come from intentional or unintentional cache poisoning attempts β from getting replicated by downstream consumers. like, blocked. not today. π
for example, say you've got the fully qualified domain name www.dachshund.example.com. valid bailiwicks would be dachshund.example.com, example.com, or com. see how it's walking up the tree? iconic behavior honestly. π
β¨ OPTIONS β¨
okay this is the big one, buckle up. every single one, no skips:
-aβ turns on ASINFO/CIDR annotation for IP addresses in A (IPv4 address) RRsets. the metadata that gets appended depends on which data source you picked with-D.-A timestampβ sets a forward time fence. only results seen by the passive DNS on or after this time get selected. also peep-c. and go read the TIMESTAMP FORMATS section for the whole scoop on this one.-B timestampβ sets a backward time fence. only results seen by the passive DNS sensor network on or before this time get selected. also peep-c. and yeah, TIMESTAMP FORMATS section, go look.-b bailiwickβ specify the bailiwick. heads up, this one's only valid with-rqueries.-cβ okay so by default,-Aand-B(separately or together) will select partial overlaps of database tuples and time search criteria. if you want to match only completely bracketed tuples, add the-cflag, aka "completeness" mode, aka "strict" mode. can only be specified once, and for reasons of geometry it affects both-Aand-Bif you gave both. math said so. π§-C cookie_fileβ specify a cookie file forlibcurlto use (read-only; analogous tocurl(1)-b). typically you'd use this for service authentication. πͺ-D asn_domainβ specify the data source for ASINFO/CIDR annotations, if you enabled them with-a. default isasn.routeviews.org, but you might wanna tryaspath.routeviews.org.-dβ enable debug mode. repeat it for more debug output. more-d, more words. π-fβ specify batch lookup mode, which lets one or more queries run. queries get read from standard input and are expected to be in one of these formats:- RRset (name) query:
rrset/name/NAME[/RRTYPE[,...][/BAILIWICK]] - RRset (raw) query:
rrset/raw/HEX[/RRTYPE[,...][/BAILIWICK]] - Rdata (name) query:
rdata/name/NAME[/RRTYPE][,...] - Rdata (IP address) query:
rdata/ip/ADDR[,PFXLEN] - Rdata (raw) query:
rdata/raw/HEX[/RRTYPE][,...] - Change query options:
$OPTIONS {options}
- RRset (name) query:
Where options :==
[-A timestamp] [-B timestamp] [-c] [-g] [-G]
[-l query_limit] [-L output_limit] [-O offset]
$OPTIONS alone on a line lets you change command line options mid-batch. and if no options are given, the query parameters get reset to whatever was given on the command line, if any, or else to defaults. clean slate energy. β¨
a line starting with a # is ignored as a comment. ghosted. π
any internal slash (/) or comma (,) characters inside the search names of a batch entry must be URL-encoded (for example, %2F or %2C). so to search for the domain 212.0/24.150.104.24.in-addr.arpa, the search string would be specified as 212.0%2F150.104.24.in-addr.arpa.
for raw queries, the hex value is an even number of hexadecimal digits specifying a raw octet string. the "raw" wire-format encodings are standardized, and the embedding of these in dnstable is documented in the dnstable-encoding(5) manual page. this whole topic is explained in detail at <https://www.farsightsecurity.com/blog/txt-record/dnsdb-rawhex-20161125>.
in batch lookup mode, each answer will be followed by a -- marker, so programmatic users know when it's safe to send the next lookup β or, if lookups are pipelined, so they know when one answer has ended and another begun. this option cannot be mixed with -n, -r, -R, or -i. check the EXAMPLES section for more on how to use -f.
if two -f options are given, then each answer will also be preceded by a ++ marker giving the query string (as read from the batch input), so you can identify each answer when you've got a very large batch input. and the -- marker will include an error/noerror indicator plus a short message describing the outcome. with two -f options and also -m, answers can appear in a different order than the batched questions, and the
-gβ return graveled results if available. default is to return aggregated results ("rocks"). gravel is a feature for providing Volume Across Time. note that not all Passive DNS system APIs support this feature, and not all time ranges contain granular results ("gravel").-Gβ undoes the effect of-g, so you get rocks back instead of gravel. (this one's for use in$OPTIONSinside batch files.)-hβ emit usage and quit. bye bestie π-Iβ request info from the API server about the API key itself, which may include rate limit, query quota, query allowance, or privilege levels. the output format and content depend on theserver_sysargument (see-u) and on the-pargument.-I -p jsonprints the raw info.-I -p textprints it in a more understandable textual form, including converting any epoch integer times into UTC formatted times. π°οΈ-i ipβ specify an rdata ip ("right-hand side") query. the value is one of: an IPv4 address, an IPv6 address, an IPv4 network with prefix length, an IPv4 address range, or an IPv6 network with prefix length. if you're doing a network lookup, the delimiter between the network address and the prefix length is a single comma (,), not the usual slash (/), so it doesn't clash with the HTTP URI path name separator. see the EXAMPLES section for more on separator substitution rules.-J input_fileβ opensinput_fileand reads newline-separated JSON objects out of it, in preference to-f(batch mode) or query mode. this is how you reprocess the output from a prior invocation that used-j(or-p json). sorting, limits, and time fences will work. specification of a domain name, RRtype, Rdata, or offset is not supported at this time. ifinput_fileis-, then standard input (stdin) will be read. π-jβ synonym for-p json. two names, one vibe.-k sort_keysβ when sorting with-sor-S, selects one or more comma-separated sort keys, among"first","last","duration","count","name","type", and/or"data". the default order isfirst,last,duration,count,name,type,data(if sorting is requested). names are sorted right to left (by TLD then 2LD etc). data is sorted either by name if present, or else by numeric value (e.g., for A and AAAA RRsets). you can give several-koptions after different-sand-Soptions, to sort ascending for some keys and descending for others. mix and match, bestie. π-l query_limitβ query for that limit's number of responses. if specified as0, then the DNSDB API server will return the maximum limit of results allowed. if-lis not specified, then the query won't specify a limit, and the DNSDB API server may use its own default limit.-L output_limitβ clamps the number of objects per response (under-[R|r|N|n|i|f]) or for all responses (under-[fm|ff|ffm]) output tooutput_limit. if unset, and if batch and merge modes haven't been selected with the-fand-moptions, then the-Loutput limit defaults to the-llimit's value. otherwise the default is no output limit.-M max_countβ for the summarize verb, stops summarizing when the count reaches thatmax_count, which must be a positive integer. the resulting total count may exceedmax_count, since it'll include the entire count from the last RRset examined. the default is to not constrain the maximum count. the number of RRsets summarized is also limited by thequery_limit.-mβ used only with-f. this causes multiple (up to ten) API queries to execute in parallel. in this mode there will be no--marker, and the combined output of all queries is what gets subject to sorting, if any. if two-fflags are specified together with-m, the output will not be merged, can appear in any order, will be sorted separately for each response, and will have normal--and++markers. (see the-foption above.) parallel queries, go off. β‘-N hex[/rrtype[,...]]β specify a raw rdata data ("right-hand side") query.hexis as described above for-f.-n nameβ specify an rdata name ("right-hand side") query. the value is a DNS domain name in presentation format, or a left-hand (*.example.com) or right-hand (www.example.*) wildcard domain name. note that left-hand wildcard queries are somewhat more expensive than right-hand wildcard queries. budget accordingly, queen. πΈ-O offsetβ offset the results returned by the query by#offset. this gives you incremental results transfers. cannot be negative. the default is0, which means no offset.
-o timeoutβ sets the timeout, in seconds, for the initial connection to the database server and for each transaction you make to that server. β±οΈ-p output_typeβ pick your output type, bestie. You can say:textβ presentation output meant to be human-readable. This is the default.dnsis a synonym, for compatibility with older programmatic callers. β¨jsonβ newline delimited JSON output. See alsohttps://jsonlines.org/.csvβ comma separated value output. This format is information losing, since it cannot express multiple resource records that are in a single RRset. Instead, each resource record is expressed in a separate line of output. See theDNSDBQ_TIME_FORMATenvironment variable for controlling how timestamps are formatted for this option.minimalβ outputs only the owner name or rdata, one per line and deduplicated; for use by shell scripts. This is incompatible with sorting. π«
-qβ makes the program reticent about warnings. π€«-R hex[/rrtype[,...][/bailiwick]]β specify a raw rrset owner data ("left-hand side") query. Hex is as described above for-f.-r name[/type[,...][/bailiwick]]β specify an RRset ("left-hand side") name query. See the discussion in-nabove as to the format of and limitations on query names.-sβ sort output in ascending key order. Limits (if any) specified by-land-Lwill be applied before and after sorting, respectively. In batch mode, the-f,-ff, and-ffmoption sets will cause each batch entry's result to be sorted independently, whereas with-fm, all outputs will be combined before sorting. This means with-fmthere will be no output until after the last batch entry has been processed, due to store and forward by the sort process. π₯²-Sβ sort output in descending key order. See the discussion for-sabove.-T transform[,...]β specify one or more transforms to be applied to the output:datefixβ always show dates in the format selected by theDNSDBQ_TIME_FORMATenvironment variable, not in database format.reverseβ show the DNS owner name (rrname) in TLD-first order (so,COM.EXAMPLErather thanEXAMPLE.COM).chompβ strip away the trailing dot (.) from the DNS owner name (rrname).qdetailβ annotate the response to include query details, mostly for use by-V summarize. This is incompatible with sorting.
-t rrtype[,...]β specify the resource record type(s) desired. Default isANY. If present, this option should precede any-R,-r,-N, or-noptions. This option is not allowed if the-ioption is present. Valid values include those defined in DNS RFCs, includingANY. A special-case supported in DNSDB isANY-DNSSEC, which matches on DS, RRSIG, NSEC, DNSKEY, NSEC3, NSEC3PARAM, and DLV resource record types.
If multiple rrtype values are specified, each will be sent separately to the database server, consuming quota if there is a quota. Such queries will be sent simultaneously in parallel, which may have a load impact on the server. π₯
-u server_sysβ specifies the Passive DNS system and thus its syntax for RESTful URLs. Can be "dnsdb" or "circl". The default is "dnsdb". See also environment variableDNSDBQ_SYSTEM.-V verbβ the verb to perform, i.e. the type of query, either "lookup" or "summarize". The default is the "lookup" verb. As an option, you can specify the "summarize" verb, which gives you an estimate of result size. At a glance, it provides information on when a given domain name, IP address or other DNS asset was first-seen and last-seen by the global sensor network, as well as the total sensor network observation count. This verb respects the database limit (see-l) in that the resulting summary will only be of rows that would have been returned by the "lookup" verb. See also-M. π-0 function=thingβ this is a developer tool meant to feed automated testing systems. π οΈ-Uβ turns off TLS certificate verification (unsafe). π¨-vβ report the version ofdnsdbqand exit.-4β use to force connecting to the DNSDB server via IPv4.-6β use to force connecting to the DNSDB server via IPv6.-8β normallydnsdbqrequires that-nor-rarguments are 7-bit ASCII clean. Non-ASCII values should be queried using PUNYCODE IDN encoding. This-8option allows using arbitrary 8 bit values.
TIMESTAMP FORMATS β°
Timestamps may be one of following forms.
- positive unsigned integer : in Unix epoch format.
- negative unsigned integer : negative offset in seconds from now.
- YYYY-MM-DD [HH:MM:SS] : in absolute form, in UTC time, as DNSDB does its fencing using UTC time.
- %uw%ud%uh%um%us : the relative form with explicit labels (w=weeks, d=days, h=hours, m=minutes, s=seconds). Calculates offset from UTC time, as DNSDB does its fencing using UTC time.
When using batch mode with the second or forth cases, using relative times to now, the value for "now" is set when dnsdbq starts. π°οΈ
A few examples of how to use timefencing options.
# tuples ending after Aug 22, 2015 (midnight)
$ dnsdbq ... -A 2015-08-22
# tuples starting before Jan 22, 2013 (midnight)
$ dnsdbq ... -B 2013-01-22
# tuples starting or ending from 2015 (midnight to midnight)
$ dnsdbq ... -B 2016-01-01 -A 2015-01-01
# tuples ending after 2015-08-22 14:36:10
$ dnsdbq ... -A "2015-08-22 14:36:10"
# tuples ending within the last 60 minutes
$ dnsdbq ... -A "-3600"
# tuples ending after "just now"
$ date +%s
1485284066
$ dnsdbq ... -A 1485284066
# batch mode with only tuples ending within last 60 minutes,
# even if feeding inputs to dnsdbq in batch mode takes hours.
$ dnsdbq -f ... -A "-3600"
EXAMPLES π
A few examples of how to specify IP address information.
# specify a single IPv4 address
$ dnsdbq ... -i 128.223.32.35
# specify an IPv4 CIDR
$ dnsdbq ... -i 128.223.32.0/24
# specify a range of IPv4 addresses
$ dnsdbq ... -i 128.223.32.0-128.223.32.32
Perform an RRset query for a single A record for farsightsecurity.com. The output is serialized as JSON and is piped to the jq program (a command-line JSON processor, see https://stedolan.github.io/jq/) for pretty printing.
$ dnsdbq -r farsightsecurity.com/A -l 1 -j -a | jq .
{
"count": 6350,
"time_first": 1380123423,
"time_last": 1427869045,
"rrname": "farsightsecurity.com.",
"rrtype": "A",
"bailiwick": "farsightsecurity.com.",
"rdata": [
"66.160.140.81"
],
"dnsdbq-rdata": [
{
"asinfo": [ 6939 ],
"cidr": "66.160.128.0/18",
"rdata": "66.160.140.81"
}
]
}
Note the "dnsdbq-rdata" element added due to the use of the -a option. π
Perform a batched operation for a several different rrset and rdata queries. Output is again serialized as JSON and redirected to a file.
$ cat batch.txt
rrset/name/wikipedia.org
rrset/name/dmoz.org
rrset/raw/0366736902696f00/A
rdata/name/pbs.org
rdata/name/opb.org
rdata/ip/198.35.26.96
rdata/ip/23.21.237.0,24
rdata/raw/0b763d73706631202d616c6c
$ dnsdbq -j -f < batch.txt > batch-output.json
$ head -1 batch-output.json | jq .
{
"count": 2411,
"zone_time_first": 1275401003,
"zone_time_last": 1484841664,
"rrname": "wikipedia.org.",
"rrtype": "NS",
"bailiwick": "org.",
"rdata": [
"ns0.wikimedia.org.",
"ns1.wikimedia.org.",
"ns2.wikimedia.org."
]
}
ASINFO/CIDR LOOKUPS π
When the -a option is used, every address seen in a response will cause a DNS lookup under the domain specified by the -D option. This stream of DNS queries might be an intolerable information leak depending on the nature of the underlying research, and it could also lead to unusably bad performance depending on the placement of your configured recursive DNS service. π¬
For best results, always use an on-server or on-LAN recursive DNS service, and consider whether to configure that recursive DNS service to be a "stealth secondary" of the zone denoted by the -D option. For the default -D value, more information can be found online at http://archive.routeviews.org/dnszones/.
Use of DNS lookups to retrieve ASINFO/CIDR metadata can be extremely fast and surveillance-free, but some attention must be paid in order to obtain that outcome. For occasional low-volume use, your current recursive DNS placement and configuration is probably good enough.
Note that while Passive DNS information is historical, the ASINFO/CIDR annotations made possible using the -a and -D options are based on current information. Internet routing system information may have changed since the DNS data was recorded. More information about this can be found online at https://github.com/dnsdb/dnsdbq/blob/master/README. π
FILES π
~/.isc-dnsdb-query.conf, ~/.dnsdb-query.conf, /etc/isc-dnsdb-query.conf, or /etc/dnsdb-query.conf: configuration file which can specify the API key and other variables. The first of these files which is readable will be used, alone, in its entirety. See the DNSDBQ_CONFIG_FILE environment variable which can specify a different configuration file to use.
The variables which can be set in the configuration file are as follows:
DNSDBQ_SYSTEMβ contains the default value for the-uoption described above. The last setting found for any given variable will prevail.DNSDB_API_KEY,APIKEYβ contains the user's DNSDB apikey (no default).DNSDB_SERVERβ contains the URL of the DNSDB API server (default ishttps://api.dnsdb.info), and optionally the URI prefix for the database. The default URI prefix for system "dnsdb2" is"/dnsdb/v2/lookup"; the default for "dnsdb1" is"/lookup".CIRCL_AUTH,CIRCL_SERVERβ enable access to a passive DNS system compatible with the CIRCL.LU system. π¦
πΈ ENVIRONMENT πΈ
bestie these are the little gremlins in your shell that change how dnsdbq behaves before you even type a flag. set them, unset them, whatever β just know they're there π
DNSDBQ_CONFIG_FILEβ tellsdnsdbqwhich config file to read, and it overrides the internal search list. like, no cap, it wins. πDNSDB_API_KEYβ holds your apikey. heads up tho: the olderAPIKEYenvironment variable has been retired, though it can still be used in the configuration file. π« also, and this is the important part, environment variables are unprotected, and putting your API key in an unprotected place could cause inadvertant sharing. π protect the key bestie, it's giving "left my diary open on the lunch table".DNSDB_SERVERβ holds the URL of the DNSDB API server, and optionally a URI prefix to be used (default is"/lookup"). If it's not set, the configuration file gets consulted instead. π¦DNSDBQ_TIME_FORMATβ controls how human readable date times show up in the output. β¨- If
"iso"(the default) then ISO8601 (RFC3339) format is used, for example;"2018-09-06T22:48:00Z". - If
"csv"then an Excel CSV compatible format is used; for example,"2018-09-06 22:48:00".
- If
HTTPS_PROXYβ holds the URL of the HTTPS proxy you wish to use. if you wanna know what values it takes, seehttps://curl.se/libcurl/c/CURLOPT_PROXY.html. π
π EXIT STATUS π
okay so this part is actually kind of iconic in how chill it is:
- Success (exit status zero) happens if a connection could be established to the back end database server β even if no records matched the search criteria. yeah. zero results is still a slay. finding nothing is not a failure, it's just a very specific kind of nothing. πΈ
- Failure (exit status nonzero) happens if no connection could be established, maybe because of a network or service failure, or a configuration error like specifying the wrong server hostname. π¨
so like: "i connected and there was nothing" = π«Ά. "i couldn't even connect" = π. different vibes entirely.
π SEE ALSO π
go read these too, they're the friend group:
dig(1)jq(1)libcurl(3)dnstable-encoding(5)https://curl.se/docs/http-cookies.html
and that's the whole page bestie!! π this one's from the dnsdbq(1) era dated 2018-01-30 β iconic, historic, still eating. go query something cursed, drink water, and remember: environment variables are unprotected, so guard that API key like it's your only charger at a sleepover. πβ¨π¦
π¦ where this page comes from
- debian trixie: dnsdbq 2.6.8-1 Β· Apache-2.0
- nixos 26.05: dnsdbq 2.6.8
- nixpkgs unstable: dnsdbq 2.6.8
- ubuntu questing: dnsdbq 2.6.8-1
- ubuntu resolute: dnsdbq 2.6.8-1build1 Β· Apache-2.0
- ubuntu stonking: dnsdbq 2.6.8-1build1 Β· Apache-2.0
- Copyright (c) 2014-2021 by Farsight Security, Inc
- π girlified by deepseek-ai/DeepSeek-V4.1-Flash on : a language model's rewrite of the original, under its terms