$linuxjunkies
>

kdig(1)

kdig is a DNS lookup tool from KNOT DNS that performs DNS queries with advanced features and detailed output.

UbuntuDebianFedoraArch

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

FlagWhat it does
-t, --query-type TYPEquery type (A, AAAA, MX, NS, SOA, CNAME, PTR, etc.)
-c, --query-class CLASSquery class (IN for internet, CH for chaos, HS for Hesiod)
+shortprint only the answer section in short format
+noall +answerprint only the answer records, hiding other sections
-4use IPv4 only; do not query via IPv6
-6use IPv6 only; do not query via IPv4
-p PORTquery server on specified port number (default 53)
+tcpuse TCP instead of UDP for the query
+dnssecenable DNSSEC validation and display RRSIG records
+multilinepretty-print zone file format with each record on separate lines
-x ADDRESSreverse DNS lookup for the IP address
@serverquery the specified DNS server (IP or hostname)

Examples

Query the default DNS server for A records of example.com

kdig example.com A

Query Google's public DNS (8.8.8.8) for mail exchange records

kdig @8.8.8.8 example.com MX

Show only the answer section in compact format

kdig example.com +short

Perform a reverse DNS lookup for IP address 192.0.2.1

kdig -x 192.0.2.1

Query for nameserver records and format output for readability

kdig example.com NS +multiline

Query via TCP with DNSSEC validation enabled

kdig @8.8.8.8 example.com +tcp +dnssec

Query for IPv6 address records using Google's IPv6 DNS server

kdig example.com AAAA @2001:4860:4860::8888

Display only the answer section, hiding question and authority sections

kdig example.com +noall +answer

Related commands