dnsdbq(1) | General Commands Manual (dnsdb) | dnsdbq(1) |
dnsdbq
— DNSDB
query tool
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]
[-N hex[/rrtype[,...]]]
[-n name[/rrtype[,...]]]
[-O offset]
[-p output_type]
[-R
hex[/rrtype[,...][/bailiwick]]]
[-r
name[/rrtype[,...][/bailiwick]]]
[-T transform[,...]]
[-t rrtype[,...]]
[-u server_sys]
[-V verb]
[-0 function=thing] |
dnsdbq
constructs and issues queries to
Passive DNS systems which return data in the IETF Passive DNS Common Output
Format. It is commonly used as a production command line interface to such
systems.
dnsdbq
displays responses in various
formats. Its default query type is a "lookup" query. As an option,
it can issue a "summarize" query type. Different Passive DNS
systems or versions of those systems may implement different query
features.
Farsight Security's "DNSDB" is one such Passive DNS system which is accessed by specifying system "dnsdb".
You'll need to get an API key from Farsight to use
dnsdbq
with DNSDB.
Farsight's passive DNS infrastructure performs a complex process of "bailiwick reconstruction" where an RRset's position within the DNS hierarchy is approximated. This serves two purposes:
For example, given the fully qualified domain name
www.dachshund.example.com
, valid bailiwicks would be
dachshund.example.com
,
example.com
, or com
.
-a
-D
.-A
timestamp-c
. See
the TIMESTAMP FORMATS section for more information about this.-B
timestamp-c
. See the TIMESTAMP FORMATS section for more
information about this.-b
bailiwick-r
queries).-c
-A
and -B
(separately or together) will select partial overlaps of database tuples
and time search criteria. To match only completely bracketed tuples, add
the -c
("completeness") flag (this is
also known as "strict" mode). Can only be specified once, and
for reasons of geometry, affects both -A
and
-B
if both are specified.-D
-a
. Default is
asn.routeviews.org
, but you may wish to try
aspath.routeviews.org
.-d
-f
rrset/name/NAME[/RRTYPE[,...][/BAILIWICK]]
rrset/raw/HEX[/RRTYPE[,...][/BAILIWICK]]
rdata/name/NAME[/RRTYPE][,...]
rdata/ip/ADDR[,PFXLEN]
rdata/raw/HEX[/RRTYPE][,...]
$OPTIONS {options}
Where options
:==
[-A timestamp] [-B timestamp] [-c] [-g] [-G] [-l query_limit] [-L output_limit] [-O offset]
$OPTIONS alone on a line allows command line options to be changed mid-batch. If no options are given, the query parameters will be reset to those given on the command line, if any, or else to defaults.
A line starting with a # will be ignored as a comment.
Any internal slash (/) or comma (,) characters within 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. The embedding of these in dnstable is documented in the dnstable-encoding(5) manual page. This 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 that programmatic users will know when it is safe to send the
next lookup, or if lookups are pipelined, to know when one answer has
ended and another begun. This option cannot be mixed with
-n
, -r
,
-R
, or -i
. See the
EXAMPLES section for more information 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) in order to identify each answer when a
very large batch input is given, and the '--' marker will include an
error/noerror indicator and 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
-G
-g
, this returning rocks rather
than gravel. (Used in $OPTIONS in batch files.)-h
-I
-u
) and upon the
-p
argument. -I -p json
prints the raw info. -I -p text
prints the
information in a more understandable textual form, including converting
any epoch integer times into UTC formatted times.-i
ip-J
input_file-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. If input_file is "-" then standard input
(stdin) will be read.-j
-p
json.-k
sort_keys-k
options can be given
after different -s
and -S
options, to sort in ascending order for some keys, descending for
others.-l
query_limit-l
, is not specified, then the query will not
specify a limit, and the DNSDB API server may use its default limit.-L
output_limit-[R|r|N|n|i|f]
) or for all responses (under
-[fm|ff|ffm]
) output to
output_limit
. If unset, and if batch and merge
modes have not been selected with the -f
and
-m
options, then the -L
output limit defaults to the -l
limit's value.
Otherwise the default is no output limit.-M
max_count-m
-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 will
be subject to sorting, if any. If two -f
flags are
specified 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 -f
option above.)-N
hex[/rrtype[,...]]rdata
data ("right-hand
side") query. Hex is as described above for
-f
.-n
namerdata
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.-O
offset-p
output_typetext
dns
is a synonym, for compatibility
with older programmatic callers.json
csv
DNSDBQ_TIME_FORMAT
environment variable for controlling how timestamps are formatted for
this option.minimal
-q
-R
hex[/rrtype[,...][/bailiwick]]rrset
owner data ("left-hand
side") query. Hex is as described above for
-f
.-r
name[/type[,...][/bailiwick]]-n
above as to the format of and limitations on
query names.-s
-l
and -L
will be applied
before and after sorting, respectively. In batch mode, the
-f
, -ff
, and
-ffm
option 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 -fm
there will be no output until
after the last batch entry has been processed, due to store and forward by
the sort process.-S
-s
above.-T
transform[,...]-t
rrtype[,...]-R
,
-r
, -N
, or
-n
options. This option is not allowed if the
-i
option is present. Valid values include those
defined in DNS RFCs, including ANY. A special-case supported in DNSDB is
ANY-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-V
verb-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-U
-v
-4
-6
-8
-n
or
-r
arguments are 7-bit ASCII clean. Non-ASCII
values should be queried using PUNYCODE IDN encoding. This
-8
option allows using arbitrary 8 bit
values.Timestamps may be one of following forms.
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"
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." ] }
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
.
~/.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
-u
option
described above. The last setting found for any given variable will
prevail.DNSDB_API_KEY
,
APIKEY
DNSDB_SERVER
CIRCL_AUTH
,
CIRCL_SERVER
DNSDBQ_CONFIG_FILE
DNSDB_API_KEY
DNSDB_SERVER
DNSDBQ_TIME_FORMAT
HTTPS_PROXY
https://curl.se/libcurl/c/CURLOPT_PROXY.html
for
information on its values.Success (exit status zero) occurs if a connection could be established to the back end database server, even if no records matched the search criteria. Failure (exit status nonzero) occurs if no connection could be established, perhaps due to a network or service failure, or a configuration error such as specifying the wrong server hostname.
2018-01-30 | Debian |