dig
Table of Contents
Dig
Description
dig is a flexible tool for interrogating DNS name servers. It performs DNS lookups and displays the answers that are returned from the name server(s) that were queried. Most DNS administrators use dig to troubleshoot DNS problems because of its flexibility, ease of use and clarity of output.
The basic syntax is:
dig [server] [name] [type]
[server]: The DNS server to query. If omitted, it uses the system's default.[name]: The domain name to look up.[type]: The type of DNS record to retrieve (e.g., A, MX, NS). Defaults to A.
Examples
Basic NS Lookup
Find the IP address (A record) for a domain.
dig example.com
Short Answer Only
Display only the IP address.
dig example.com +short
Query Specific Record Types
MX (Mail Exchange) Records:
dig example.com MX
NS (Name Server) Records:
dig example.com NS
Query a Specific NS Server
Query Google's public DNS server.
dig @8.8.8.8 example.com
Reverse NS Lookup
Find the domain name for an IP address.
dig -x 93.184.216.34
Trace NS Path
Trace the full delegation path from the root servers.
dig example.com +trace