The dig command, short for Domain Information Groper,
is a powerful network administration command-line tool for querying
the Domain Name System (DNS). It allows users to retrieve various
types of information about domain names, IP addresses, and DNS
servers. This guide provides essential examples for using
dig effectively.
To perform a basic DNS lookup for a domain, simply use the
dig command followed by the domain name:
dig [domain]
If you only need the IP address associated with a domain, you can use several options to strip away unnecessary output:
dig [domain] +nocomments +noauthority +noadditional +nostats
dig [domain] +noall +answer
dig [domain] +short
dig supports querying for specific DNS record types.
You can specify the query type using the -t flag or by
placing it after the domain name.
dig -t [query type] [domain] [options]
dig [domain] [query type] [options]
To retrieve all available DNS record types for a domain, use the
ANY query type:
dig -t ANY [domain] [options]
dig [domain] ANY [options]
A reverse DNS lookup maps an IP address back to its associated
domain name. Use the -x flag for this purpose:
dig -x [ip address] +short
You can direct your DNS queries to a particular DNS server by prefixing the server's address with an "@" symbol:
dig @[specific DNS] [domain]
For querying multiple domains listed in a file, you can use the
dit command (often a companion or alias to
dig for batch processing) or list domains sequentially.
dig [domain1] [options] [domain2] [options]
dit -f file.txt [options]