1. Home
  2. Tips and Tricks
  3. Using DIG to Query DNS Data

Using DIG to Query DNS Data

Domain Information Groper (DIG) is a command line tool that is widely used when troubleshooting DNS issues. If you’re an administrator working with any part of DNS it’s a critical piece of your toolbox.

Example 1: Find the A Record for a domain

Let’s assume we want to know the A record for the noc.org domain. We could use dig like this:

dig noc.org 

; <<>> DiG 9.16.1-Ubuntu <<>> noc.org 
;; global options: +cmd 
;; Got answer: 
;; ->>HEADER<<- opcode: QUERY, status: NOERROR, id: 45429 
;; flags: qr rd ad; QUERY: 1, ANSWER: 1, AUTHORITY: 0, ADDITIONAL: 0 
;; WARNING: recursion requested but not available 

;noc.org. IN A 

noc.org. 0 IN A 

;; Query time: 90 msec 
;; WHEN: Thu Jun 17 14:04:15 CDT 2021 
;; MSG SIZE rcvd: 48

You would see that the A record for the noc.org domain is

Example 2: Manipulate Dig Outputs

Dig is a bit chattier than other tools so a common option leveraged is +short. As the name implies, it shortens the output. For example:

dig noc.org +short

You will notice that it gives you a very short response compared to the default output. By default it gives you the A record when you use +short without other properties.

This means if you want to see something like your email records or Time To Live (TTL), SOA or even name servers you have to pass those through like this:

Querying email records:

dig noc.org +short mx


Querying nameserver records:

dig noc.org +short ns


You can also manipulate the output of DIG without using +short by using other options.

For example, let’s say we only want the answer response from dig, it would look something like this:

Removing all the noise, and focusing on the response while querying for the SOA record:

dig noc.org soa +nocomments +noquestion +noauthority +noadditional +nostats

; <<>> DiG 9.16.1-Ubuntu <<>> noc.org soa +nocomments +noquestion +noauthority +noadditional +nostats 
;; global options: +cmd 
noc.org. 0 IN SOA ns7.dns-noc.org. security.noc.org. 1586927815 14400 3600 1209600 300

Example 3: Reverse Lookups with Dig

So now that you know what the A record is pointing to, is it correct?

Dig allows you to do a reverse lookup on an IP to see where it’s pointing.

dig -x +short 


So now we see that it’s the NOC Dallas DC.

Example 4: Querying Multiple Domains

Another important task is querying multiple domains, and dig makes that easy by allowing you to daisy chain the requests like this:

dig noc.org +noall +answer cleanbrowsing.org +noall +answer 

noc.org. 0 IN A 
cleanbrowsing.org. 0 IN A
Updated on December 8, 2023

Was this article helpful?

Related Articles

Need Support?
Can’t find the answer you’re looking for? Don’t worry we’re here to help!
Email: support@noc.org

Leave a Comment