dig
domain information groper
This is a command for querying DNS name servers about host addresses, mail exchanges and other DNS information. It is part of a common package; bind-utils on Red Hat and Fedora or dnsutils on Debian based distributions. The following line shows the simplest invocation of dig:
dig @server name type
@server is the name or IP address of the name server to query. This can be an IPv4 address in dotted decimal notation or an IPv6 address in colon delimited notation. When the supplied server argument is a hostname, dig will need to resolve that name before querying the specified name server. If no server argument is provided, dig wil check the /etc/resolv.conf for the name server.
dig is part of a common package; bind-utils on Red Hat and Fedora or dnsutils on Debian based distributions.
The output of the dig command is divided into a number of sections:
Header section; this lists information about dig including the version.
Question section; summarise the query being executed.
Answer section; summarises the results of the query.
Authority section; lists the name servers available.
Additional section; lists IP addresses of name servers.
Question section
Provides a summary of the DNS query. The default is for an Address record (DNS type A)
Answer section
Lists the results for controlcode.co.uk
Authority section
This section gives the details of servers that can provide an authoritive answer to the query, the name servers. For controlcode.co.uk it should be ns.123-reg.co.uk and ns2.123-reg.co.uk
Additional section
This displays the IP address of the name servers listed in the Authority section.
The sections displayed can be controlled using the following options:
+nocmd - must be first argument
+[no]comments - disables the headers
+[no]question
+[no]answer
+[no]authority
+[no]additional
+[no]stats
Type
You can use the -t option to pass the query type.
e.g -t ANY
Examples
dig controlcode.co.uk A +noall +answer
dig controlcode.co.uk MX +noall +answer
dig controlcode.co.uk CNAME +noall + answer
dig controlcode.co.uk ANY +noall +answer
Query a specific nameserver
dig @ns.123-reg.co.uk controlcode.co.uk
Trace
dig controlcode.co.uk +trace
Reverse lookup
dig -x 94.136.40.103 +short