A fast and simple DNS query tool written in Rust.
dnsqry is a command-line DNS lookup utility that provides clean, formatted output for various DNS record types. It's designed to be simple, fast, and easy to use for both quick lookups and scripting.
-
Make sure you have Rust installed. If not, install it from rustup.rs
-
Clone this repository:
git clone <repository-url> cd dnsqry
-
Build the project:
cargo build --release
-
The binary will be available at
target/release/dnsqry -
Optionally, install it to your PATH:
cargo install --path .
dnsqry <domain> <record_type>domain: The domain name to query (e.g.,google.com,example.org)record_type: The DNS record type to query (A, AAAA, NS, MX, TXT, CNAME, SOA, PTR, etc.)
Query A record (IPv4 address):
$ dnsqry google.com A
A google.com. 3m01s 142.251.222.206Query NS records (name servers):
$ dnsqry google.com NS
NS google.com. 39m57s "ns1.google.com."
NS google.com. 39m57s "ns2.google.com."
NS google.com. 39m57s "ns3.google.com."
NS google.com. 39m57s "ns4.google.com."Query AAAA record (IPv6 address):
$ dnsqry google.com AAAA
AAAA google.com. 2m15s 2607:f8b0:4004:c1b::65Query MX records (mail servers):
$ dnsqry google.com MX
MX google.com. 10m30s 10 "smtp.google.com."Query TXT records:
$ dnsqry google.com TXT
TXT google.com. 5m00s "v=spf1 include:_spf.google.com ~all"Query CNAME record:
$ dnsqry www.github.com CNAME
CNAME www.github.com. 1h00m00s "github.com."- A: IPv4 address records
- AAAA: IPv6 address records
- NS: Name server records
- MX: Mail exchange records
- TXT: Text records
- CNAME: Canonical name records
- SOA: Start of authority records
- PTR: Pointer records (for reverse DNS)
- And other standard DNS record types
The output format is designed to be both human-readable and script-friendly:
<RECORD_TYPE> <DOMAIN> <TTL> <DATA>
Where:
- RECORD_TYPE: The DNS record type (A, NS, MX, etc.)
- DOMAIN: The queried domain name
- TTL: Time-to-live in human-readable format (e.g.,
3m01s,1h30m45s) - DATA: The record data (IP addresses, hostnames in quotes, etc.)
The tool provides clear error messages for common issues:
- Invalid record types
- DNS resolution failures
- Network connectivity problems
- Malformed domain names
MIT
Contributions are welcome! Please feel free to submit issues and pull requests.