nu_plugin_dns
Nushell plugin that does DNS queries and parses
results into meaningful types. Intended to be a native replacement for
dig
. Uses the excellent
trust-dns
crates.
--dnssec
flag.``` simple query for A / AAAA records
dns query amazon.com
╭────────────┬─────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────╮ │ │ ╭──────────┬────────────╮ │ │ nameserver │ │ address │ 8.8.8.8:53 │ │ │ │ │ protocol │ udp │ │ │ │ ╰──────────┴────────────╯ │ │ │ ╭───┬───────────────────────────────────┬─────────────────────────┬───────────────────────────────────────────────────────────────────┬────────────────────────────────────────────────────────────────────────────────────────────┬────────────────┬─────────────────────────────────────┬───────╮ │ │ messages │ │ # │ header │ question │ answer │ authority │ additional │ edns │ size │ │ │ │ ├───┼───────────────────────────────────┼─────────────────────────┼───────────────────────────────────────────────────────────────────┼────────────────────────────────────────────────────────────────────────────────────────────┼────────────────┼─────────────────────────────────────┼───────┤ │ │ │ │ 0 │ ╭────────────────────┬──────────╮ │ ╭───────┬─────────────╮ │ [list 0 items] │ ╭───┬─────────────┬──────┬───────┬───────┬───────────────────────────────────────────────╮ │ [list 0 items] │ ╭─────────────┬───────────────────╮ │ 100 B │ │ │ │ │ │ │ id │ 28755 │ │ │ name │ amazon.com. │ │ │ │ # │ name │ type │ class │ ttl │ rdata │ │ │ │ rcodehigh │ 0 │ │ │ │ │ │ │ │ │ messagetype │ RESPONSE │ │ │ type │ AAAA │ │ │ ├───┼─────────────┼──────┼───────┼───────┼───────────────────────────────────────────────┤ │ │ │ version │ 0 │ │ │ │ │ │ │ │ │ opcode │ QUERY │ │ │ class │ IN │ │ │ │ 0 │ amazon.com. │ SOA │ IN │ 25sec │ ╭─────────┬─────────────────────────────────╮ │ │ │ │ dnssecok │ false │ │ │ │ │ │ │ │ │ authoritative │ false │ │ ╰───────┴─────────────╯ │ │ │ │ │ │ │ │ │ mname │ dns-external-master.amazon.com. │ │ │ │ │ maxpayload │ 512 B │ │ │ │ │ │ │ │ │ truncated │ false │ │ │ │ │ │ │ │ │ │ │ rname │ root.amazon.com. │ │ │ │ │ opts │ {record 0 fields} │ │ │ │ │ │ │ │ │ recusiondesired │ true │ │ │ │ │ │ │ │ │ │ │ serial │ 2010176156 │ │ │ │ ╰─────────────┴───────────────────╯ │ │ │ │ │ │ │ │ recusionavailable │ true │ │ │ │ │ │ │ │ │ │ │ refresh │ 3min │ │ │ │ │ │ │ │ │ │ │ │ authenticdata │ false │ │ │ │ │ │ │ │ │ │ │ retry │ 1min │ │ │ │ │ │ │ │ │ │ │ │ responsecode │ No Error │ │ │ │ │ │ │ │ │ │ │ expire │ 1month 5day │ │ │ │ │ │ │ │ │ │ │ │ querycount │ 1 │ │ │ │ │ │ │ │ │ │ │ minimum │ 1min │ │ │ │ │ │ │ │ │ │ │ │ answercount │ 0 │ │ │ │ │ │ │ │ │ │ ╰─────────┴─────────────────────────────────╯ │ │ │ │ │ │ │ │ │ │ │ nameservercount │ 1 │ │ │ │ ╰───┴─────────────┴──────┴───────┴───────┴───────────────────────────────────────────────╯ │ │ │ │ │ │ │ │ │ │ additionalcount │ 1 │ │ │ │ │ │ │ │ │ │ │ │ │ ╰────────────────────┴──────────╯ │ │ │ │ │ │ │ │ │ │ │ 1 │ ╭────────────────────┬──────────╮ │ ╭───────┬─────────────╮ │ ╭───┬─────────────┬──────┬───────┬────────────┬─────────────────╮ │ [list 0 items] │ [list 0 items] │ ╭─────────────┬───────────────────╮ │ 87 B │ │ │ │ │ │ │ id │ 25101 │ │ │ name │ amazon.com. │ │ │ # │ name │ type │ class │ ttl │ rdata │ │ │ │ │ rcodehigh │ 0 │ │ │ │ │ │ │ │ │ messagetype │ RESPONSE │ │ │ type │ A │ │ ├───┼─────────────┼──────┼───────┼────────────┼─────────────────┤ │ │ │ │ version │ 0 │ │ │ │ │ │ │ │ │ opcode │ QUERY │ │ │ class │ IN │ │ │ 0 │ amazon.com. │ A │ IN │ 2min 15sec │ 205.251.242.103 │ │ │ │ │ dnssecok │ false │ │ │ │ │ │ │ │ │ authoritative │ false │ │ ╰───────┴─────────────╯ │ │ 1 │ amazon.com. │ A │ IN │ 2min 15sec │ 54.239.28.85 │ │ │ │ │ maxpayload │ 512 B │ │ │ │ │ │ │ │ │ truncated │ false │ │ │ │ 2 │ amazon.com. │ A │ IN │ 2min 15sec │ 52.94.236.248 │ │ │ │ │ opts │ {record 0 fields} │ │ │ │ │ │ │ │ │ recusiondesired │ true │ │ │ ╰───┴─────────────┴──────┴───────┴────────────┴─────────────────╯ │ │ │ ╰─────────────┴───────────────────╯ │ │ │ │ │ │ │ │ recusionavailable │ true │ │ │ │ │ │ │ │ │ │ │ │ │ │ authenticdata │ false │ │ │ │ │ │ │ │ │ │ │ │ │ │ responsecode │ No Error │ │ │ │ │ │ │ │ │ │ │ │ │ │ querycount │ 1 │ │ │ │ │ │ │ │ │ │ │ │ │ │ answercount │ 3 │ │ │ │ │ │ │ │ │ │ │ │ │ │ nameservercount │ 0 │ │ │ │ │ │ │ │ │ │ │ │ │ │ additionalcount │ 1 │ │ │ │ │ │ │ │ │ │ │ │ │ ╰────────────────────┴──────────╯ │ │ │ │ │ │ │ │ │ │ ╰───┴───────────────────────────────────┴─────────────────────────┴───────────────────────────────────────────────────────────────────┴────────────────────────────────────────────────────────────────────────────────────────────┴────────────────┴─────────────────────────────────────┴───────╯ │ ╰────────────┴─────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────╯ ```
``` specify query type
dns query --type CNAME en.wikipedia.org
╭────────────┬──────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────╮ │ │ ╭──────────┬────────────╮ │ │ nameserver │ │ address │ 8.8.8.8:53 │ │ │ │ │ protocol │ udp │ │ │ │ ╰──────────┴────────────╯ │ │ │ ╭───┬───────────────────────────────────┬───────────────────────────────┬───────────────────────────────────────────────────────────────────────────────────┬────────────────┬────────────────┬─────────────────────────────────────┬──────╮ │ │ messages │ │ # │ header │ question │ answer │ authority │ additional │ edns │ size │ │ │ │ ├───┼───────────────────────────────────┼───────────────────────────────┼───────────────────────────────────────────────────────────────────────────────────┼────────────────┼────────────────┼─────────────────────────────────────┼──────┤ │ │ │ │ 0 │ ╭────────────────────┬──────────╮ │ ╭───────┬───────────────────╮ │ ╭───┬───────────────────┬───────┬───────┬─────────────────┬─────────────────────╮ │ [list 0 items] │ [list 0 items] │ ╭─────────────┬───────────────────╮ │ 74 B │ │ │ │ │ │ │ id │ 60025 │ │ │ name │ en.wikipedia.org. │ │ │ # │ name │ type │ class │ ttl │ rdata │ │ │ │ │ rcodehigh │ 0 │ │ │ │ │ │ │ │ │ messagetype │ RESPONSE │ │ │ type │ CNAME │ │ ├───┼───────────────────┼───────┼───────┼─────────────────┼─────────────────────┤ │ │ │ │ version │ 0 │ │ │ │ │ │ │ │ │ opcode │ QUERY │ │ │ class │ IN │ │ │ 0 │ en.wikipedia.org. │ CNAME │ IN │ 1hr 35min 58sec │ dyna.wikimedia.org. │ │ │ │ │ dnssecok │ false │ │ │ │ │ │ │ │ │ authoritative │ false │ │ ╰───────┴───────────────────╯ │ ╰───┴───────────────────┴───────┴───────┴─────────────────┴─────────────────────╯ │ │ │ │ maxpayload │ 512 B │ │ │ │ │ │ │ │ │ truncated │ false │ │ │ │ │ │ │ opts │ {record 0 fields} │ │ │ │ │ │ │ │ │ recusiondesired │ true │ │ │ │ │ │ ╰─────────────┴───────────────────╯ │ │ │ │ │ │ │ │ recusionavailable │ true │ │ │ │ │ │ │ │ │ │ │ │ │ │ authenticdata │ false │ │ │ │ │ │ │ │ │ │ │ │ │ │ responsecode │ No Error │ │ │ │ │ │ │ │ │ │ │ │ │ │ querycount │ 1 │ │ │ │ │ │ │ │ │ │ │ │ │ │ answercount │ 1 │ │ │ │ │ │ │ │ │ │ │ │ │ │ nameservercount │ 0 │ │ │ │ │ │ │ │ │ │ │ │ │ │ additionalcount │ 1 │ │ │ │ │ │ │ │ │ │ │ │ │ ╰────────────────────┴──────────╯ │ │ │ │ │ │ │ │ │ │ ╰───┴───────────────────────────────────┴───────────────────────────────┴───────────────────────────────────────────────────────────────────────────────────┴────────────────┴────────────────┴─────────────────────────────────────┴──────╯ │ ╰────────────┴──────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────╯ ```
``` specify query types by numeric ID, and get numeric IDs in output
dns query --type [5, 15] -c google.com
╭────────────┬──────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────╮ │ │ ╭──────────┬────────────╮ │ │ nameserver │ │ address │ 8.8.8.8:53 │ │ │ │ │ protocol │ udp │ │ │ │ ╰──────────┴────────────╯ │ │ │ ╭───┬──────────────────────────────────────────────┬──────────────────────────────┬──────────────────────────────────────────────────────────────────────────────────────────────────────┬───────────────────────────────────────────────────────────────────────────────────────────────────┬────────────────┬─────────────────────────────────────┬──────╮ │ │ messages │ │ # │ header │ question │ answer │ authority │ additional │ edns │ size │ │ │ │ ├───┼──────────────────────────────────────────────┼──────────────────────────────┼──────────────────────────────────────────────────────────────────────────────────────────────────────┼───────────────────────────────────────────────────────────────────────────────────────────────────┼────────────────┼─────────────────────────────────────┼──────┤ │ │ │ │ 0 │ ╭────────────────────┬─────────────────────╮ │ ╭───────┬──────────────────╮ │ [list 0 items] │ ╭───┬─────────────┬────────────────┬───────────────┬──────┬─────────────────────────────────────╮ │ [list 0 items] │ ╭─────────────┬───────────────────╮ │ 89 B │ │ │ │ │ │ │ id │ 20006 │ │ │ name │ google.com. │ │ │ │ # │ name │ type │ class │ ttl │ rdata │ │ │ │ rcodehigh │ 0 │ │ │ │ │ │ │ │ │ │ ╭──────┬──────────╮ │ │ │ │ ╭──────┬───────╮ │ │ │ ├───┼─────────────┼────────────────┼───────────────┼──────┼─────────────────────────────────────┤ │ │ │ version │ 0 │ │ │ │ │ │ │ │ │ messagetype │ │ name │ RESPONSE │ │ │ │ type │ │ name │ CNAME │ │ │ │ │ 0 │ google.com. │ ╭──────┬─────╮ │ ╭──────┬────╮ │ 1min │ ╭─────────┬───────────────────────╮ │ │ │ │ dnssecok │ false │ │ │ │ │ │ │ │ │ │ │ code │ 1 │ │ │ │ │ │ code │ 5 │ │ │ │ │ │ │ │ name │ SOA │ │ │ name │ IN │ │ │ │ mname │ ns1.google.com. │ │ │ │ │ maxpayload │ 512 B │ │ │ │ │ │ │ │ │ │ ╰──────┴──────────╯ │ │ │ │ ╰──────┴───────╯ │ │ │ │ │ │ │ code │ 6 │ │ │ code │ 1 │ │ │ │ rname │ dns-admin.google.com. │ │ │ │ │ opts │ {record 0 fields} │ │ │ │ │ │ │ │ │ │ ╭──────┬───────╮ │ │ │ │ ╭──────┬────╮ │ │ │ │ │ │ ╰──────┴─────╯ │ ╰──────┴────╯ │ │ │ serial │ 554750970 │ │ │ │ ╰─────────────┴───────────────────╯ │ │ │ │ │ │ │ │ opcode │ │ name │ QUERY │ │ │ │ class │ │ name │ IN │ │ │ │ │ │ │ │ │ │ │ refresh │ 15min │ │ │ │ │ │ │ │ │ │ │ │ │ │ code │ 0 │ │ │ │ │ │ code │ 1 │ │ │ │ │ │ │ │ │ │ │ retry │ 15min │ │ │ │ │ │ │ │ │ │ │ │ │ ╰──────┴───────╯ │ │ │ │ ╰──────┴────╯ │ │ │ │ │ │ │ │ │ │ expire │ 30min │ │ │ │ │ │ │ │ │ │ │ │ authoritative │ false │ │ ╰───────┴──────────────────╯ │ │ │ │ │ │ │ │ │ minimum │ 1min │ │ │ │ │ │ │ │ │ │ │ │ truncated │ false │ │ │ │ │ │ │ │ │ │ ╰─────────┴───────────────────────╯ │ │ │ │ │ │ │ │ │ │ │ recusiondesired │ true │ │ │ │ ╰───┴─────────────┴────────────────┴───────────────┴──────┴─────────────────────────────────────╯ │ │ │ │ │ │ │ │ │ │ recusionavailable │ true │ │ │ │ │ │ │ │ │ │ │ │ │ │ authenticdata │ false │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ ╭──────┬──────────╮ │ │ │ │ │ │ │ │ │ │ │ │ │ │ responsecode │ │ name │ No Error │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ code │ 0 │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ ╰──────┴──────────╯ │ │ │ │ │ │ │ │ │ │ │ │ │ │ querycount │ 1 │ │ │ │ │ │ │ │ │ │ │ │ │ │ answercount │ 0 │ │ │ │ │ │ │ │ │ │ │ │ │ │ nameservercount │ 1 │ │ │ │ │ │ │ │ │ │ │ │ │ │ additionalcount │ 1 │ │ │ │ │ │ │ │ │ │ │ │ │ ╰────────────────────┴─────────────────────╯ │ │ │ │ │ │ │ │ │ │ │ 1 │ ╭────────────────────┬─────────────────────╮ │ ╭───────┬───────────────╮ │ ╭───┬─────────────┬───────────────┬───────────────┬────────────┬───────────────────────────────────╮ │ [list 0 items] │ [list 0 items] │ ╭─────────────┬───────────────────╮ │ 60 B │ │ │ │ │ │ │ id │ 47130 │ │ │ name │ google.com. │ │ │ # │ name │ type │ class │ ttl │ rdata │ │ │ │ │ rcodehigh │ 0 │ │ │ │ │ │ │ │ │ │ ╭──────┬──────────╮ │ │ │ │ ╭──────┬────╮ │ │ ├───┼─────────────┼───────────────┼───────────────┼────────────┼───────────────────────────────────┤ │ │ │ │ version │ 0 │ │ │ │ │ │ │ │ │ messagetype │ │ name │ RESPONSE │ │ │ │ type │ │ name │ MX │ │ │ │ 0 │ google.com. │ ╭──────┬────╮ │ ╭──────┬────╮ │ 1min 13sec │ ╭────────────┬──────────────────╮ │ │ │ │ │ dnssecok │ false │ │ │ │ │ │ │ │ │ │ │ code │ 1 │ │ │ │ │ │ code │ 15 │ │ │ │ │ │ │ name │ MX │ │ │ name │ IN │ │ │ │ preference │ 10 │ │ │ │ │ │ maxpayload │ 512 B │ │ │ │ │ │ │ │ │ │ ╰──────┴──────────╯ │ │ │ │ ╰──────┴────╯ │ │ │ │ │ │ code │ 15 │ │ │ code │ 1 │ │ │ │ exchange │ smtp.google.com. │ │ │ │ │ │ opts │ {record 0 fields} │ │ │ │ │ │ │ │ │ │ ╭──────┬───────╮ │ │ │ │ ╭──────┬────╮ │ │ │ │ │ ╰──────┴────╯ │ ╰──────┴────╯ │ │ ╰────────────┴──────────────────╯ │ │ │ │ ╰─────────────┴───────────────────╯ │ │ │ │ │ │ │ │ opcode │ │ name │ QUERY │ │ │ │ class │ │ name │ IN │ │ │ ╰───┴─────────────┴───────────────┴───────────────┴────────────┴───────────────────────────────────╯ │ │ │ │ │ │ │ │ │ │ │ │ │ code │ 0 │ │ │ │ │ │ code │ 1 │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ ╰──────┴───────╯ │ │ │ │ ╰──────┴────╯ │ │ │ │ │ │ │ │ │ │ │ │ │ authoritative │ false │ │ ╰───────┴───────────────╯ │ │ │ │ │ │ │ │ │ │ │ │ truncated │ false │ │ │ │ │ │ │ │ │ │ │ │ │ │ recusiondesired │ true │ │ │ │ │ │ │ │ │ │ │ │ │ │ recusionavailable │ true │ │ │ │ │ │ │ │ │ │ │ │ │ │ authenticdata │ false │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ ╭──────┬──────────╮ │ │ │ │ │ │ │ │ │ │ │ │ │ │ responsecode │ │ name │ No Error │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ code │ 0 │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ ╰──────┴──────────╯ │ │ │ │ │ │ │ │ │ │ │ │ │ │ querycount │ 1 │ │ │ │ │ │ │ │ │ │ │ │ │ │ answercount │ 1 │ │ │ │ │ │ │ │ │ │ │ │ │ │ nameservercount │ 0 │ │ │ │ │ │ │ │ │ │ │ │ │ │ additionalcount │ 1 │ │ │ │ │ │ │ │ │ │ │ │ │ ╰────────────────────┴─────────────────────╯ │ │ │ │ │ │ │ │ │ │ ╰───┴──────────────────────────────────────────────┴──────────────────────────────┴──────────────────────────────────────────────────────────────────────────────────────────────────────┴───────────────────────────────────────────────────────────────────────────────────────────────────┴────────────────┴─────────────────────────────────────┴──────╯ │ ╰────────────┴──────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────╯ ```
``` pipe name into command
'google.com' | dns query ```
``` pipe lists of names into command
['google.com', 'amazon.com'] | dns query ```
``` pipe table of queries into command (ignores --type flag)
[{name: 'google.com', type: 'A'}, {name: 'amazon.com', type: 'A'}] | dns query ```
``` choose a different protocol and/or port
dns query -p tls -n dns.google -s 8.8.8.8 en.wikipedia.org dns query -p https -n cloudflare-dns.com -s 1.1.1.1 en.wikipedia.org dns query -p quic -n dns.adguard-dns.com -s 94.140.15.15:853 en.wikipedia.org ```
nu
cargo install nu_plugin_dns
register $"($env.CARGO_HOME)/bin/nu_plugin_dns"