kdig(1)
kdig is a DNS lookup tool from KNOT DNS that performs DNS queries with advanced features and detailed output.
Synopsis
kdig [OPTION]... [@server] [QNAME] [QTYPE] [QCLASS]Description
kdig is a command-line DNS client utility that allows you to query DNS servers for information about domain names, IP addresses, mail servers, and other DNS records. It is part of the KNOT DNS suite and provides more detailed control and output than simpler tools like nslookup.
You can specify the DNS server to query, the domain name to look up, the record type (A, MX, NS, etc.), and the DNS class. kdig displays the full DNS response including the question section, answer section, authority section, and additional section with detailed timing and statistics.
Common options
| Flag | What it does |
|---|---|
-t, --query-type TYPE | query type (A, AAAA, MX, NS, SOA, CNAME, PTR, etc.) |
-c, --query-class CLASS | query class (IN for internet, CH for chaos, HS for Hesiod) |
+short | print only the answer section in short format |
+noall +answer | print only the answer records, hiding other sections |
-4 | use IPv4 only; do not query via IPv6 |
-6 | use IPv6 only; do not query via IPv4 |
-p PORT | query server on specified port number (default 53) |
+tcp | use TCP instead of UDP for the query |
+dnssec | enable DNSSEC validation and display RRSIG records |
+multiline | pretty-print zone file format with each record on separate lines |
-x ADDRESS | reverse DNS lookup for the IP address |
@server | query the specified DNS server (IP or hostname) |
Examples
Query the default DNS server for A records of example.com
kdig example.com AQuery Google's public DNS (8.8.8.8) for mail exchange records
kdig @8.8.8.8 example.com MXShow only the answer section in compact format
kdig example.com +shortPerform a reverse DNS lookup for IP address 192.0.2.1
kdig -x 192.0.2.1Query for nameserver records and format output for readability
kdig example.com NS +multilineQuery via TCP with DNSSEC validation enabled
kdig @8.8.8.8 example.com +tcp +dnssecQuery for IPv6 address records using Google's IPv6 DNS server
kdig example.com AAAA @2001:4860:4860::8888Display only the answer section, hiding question and authority sections
kdig example.com +noall +answer