dig

>Usage

The command dig is a command-line tool used to query DNS (Domain Name System) servers to obtain information about domain names, IP addresses, mail servers, and other DNS records. It is often used for troubleshooting DNS issues and for performing queries to look up domain-related information.

When you run dig with a domain name or an IP address, it sends a request to the DNS system and then, returns detailed information about the domain's DNS configuration. This includes the associated IP address, mail server settings and other related information. It helps you understand how a domain is set up and whether there are any issues with its DNS configuration.

>Synopsis

dig [option] [destination]

>Options

+short

The command +short simplifies the output, showing only the essential information like an IP address or a simple record. Making it useful when you just need a quick result, like finding an IP address for a domain.

Example:

Dots

+short

> dig +short example.com


93.184.216.34

+noall +answer

The command +noall +answer hides all unnecessary details and shows only the answer section, which is especially useful when you're interested only in the final result without all the additional query metadata.

Example:

Dots

+noall +answer

> dig +noall +answer example.com


example.com. 3600 IN A 93.184.216.34

-x

The command -x <address> is used to perform a reverse DNS lookup, where you provide an IP address and dig queries the DNS system to find the domain name associated with that IP address. This is the reverse of a normal DNS lookup (the DNS query resolves a domain name to an IP address), where you query by domain name and get the associated IP address.

Example:

Dots

-x <address>

> dig -x 93.184.216.34


34.216.184.93.in-addr.arpa. 3600 IN PTR www.example.com

("PTR" indicates that a pointer record (PTR record) is returned, which points to the domain name associated with the IP address).

@<server>

The command @<server> allows you to specify a custom DNS server to query instead of using the default DNS server that is configured on your local system. This is a useful feature when you want to test DNS resolution from a specific DNS server or if you are troubleshooting DNS-related issues and need to query a particular server for the records of a domain.

Example:

Dots

@<server>

> dig @8.8.8.8 example.com


; DiG 9.16.1-Ubuntu @8.8.8.8 example.com

example.com. 3600 IN A 93.184.216.34

+trace

The command +trace allows you to trace the full path to the authoritative DNS server, showing the sequence of DNS servers involved in resolving a domain name.

Example:

Dots

+trace

> dig +trace example.com


@<@<>> DiG 9.16.1-Ubuntu @<@<>> +trace example.com
global options: +cmd
3600000 IN NS a.root-servers.net.
3600000 IN NS b.root-servers.net.
3600000 IN NS c.root-servers.net.

example.com. 3600 IN A 93.184.216.34

+stats

The command +stats will show statistics about the query, including how long it took to resolve and how many DNS servers were queried.

Example:

Dots

+stats

> dig +stats example.com


;; Query time: 45 msec
;; SERVER: 8.8.8.8#53(8.8.8.8)
;; WHEN: Tue Nov 14 12:35:00 UTC 2024
;; MSG SIZE rcvd: 65

>Quiz

Progress: Question ? out of ?

The dig command can be used to query DNS records.

Page written by Marianna Dinon Spindola