DNS Info Zone Commands,DNS Dig command explained

Dig command explained

Are you ready to learn all about one simple and a great tool for network diagnostic? Here comes the Dig command! Small, fast, and useful. It can become your go-to DNS utility tool from now on.

How to install the Dig command?

History of the Dig command

The creator of the dig command is Stev Hotz. The utility tool was part of the BIND 4 (Berkeley Internet Name Domain) DNS software that was introduced in the late 80s. Some year later, another developer called Michael Sawyer rewrote the code of dig and integrated it into the BIND 9. 

Dig command explained

To explain to you the Dig command, the easiest way, we can start with its full name – Domain Information Groper. What you can get from the name is that this software has the purpose get information about a domain. You can perform various DNS probing and get important information that can help you detect a problem with your domain, DNS records, or name servers. 

What can you do with the Dig command?

With the Dig command, you can see all kinds of DNS records, check name servers, do a reverse DNS, and more. See the whole list here:

  • Check all name servers (see the NS DNS records). 
  • Probe an individual name server after you know it from the previous probe. 
  • Probe all available DNS records
  • Perform a specific check for a certain type of DNS record – A, AAAA, MX, NS, SOA, TXT, CNAME, or another. 
  • Check an IP and trace it back to a hostname.
  • Trace the complete route of a DNS query from a point (your computer or another resolver) to the hostname or IP address. 

Dig output explained

Let’s go deep into the output that you will get after performing a dig query. 

Go to the Terminal and write:

dig yahoo.com

*you can change yahoo.com with another domain that you want. 

  1. The first part of the output will show you the version of the dig command and the global option for the particular check. You can disable this part with the +nocmd option.
  2. Then you will get a header that will show you if you got an answer or no (NOERROR means you got no problem receiving the answer), flags used for the query, and type of answer – authoritative or no. Remove this part with +nocomments options. 
  3. In the newer version of Dig, you will have an OPT section that shows EDNS and its port. +noedns will remove this. 
  4. The question, by default, is the A record, but you can ask for: A, AAAA, MX, SOA, NS, CNAME, TXT, PTR or another record, particular host, IP address, port, or another. 

Examples of some dig questions:

dig a yahoo.com

dig aaaa yahoo.com

dig mx yahoo.com

dig soa yahoo.com

dig ns yahoo.com

dig txt yahoo.com

dig yahoo.com +trace (trace route)

dig -x 11.22.33.44 (reverse lookup of the IP address 11.22.33.44)

dig -p 43 yahoo.com (check the domain using port 43)

You can use extra options by putting them after your question and domain. An example of an option is +short for a shorter answer of only IPv4 (dig yahoo.com +short). Multiple options can be added by simply separating them with space. Example of two options together:

dig -x 11.22.33.44 +noall +answer – a reverse lookup for 11.22.33.44 without all the information, but include the answer.

  1. The answer. It will show what you asked before. The common answer will show the hostname, a TTL value of the DNS record, its type, and value. If it is an A record query, you will get the IPv4 addresses. 

If you don’t want to see the answer section for some reason, you can remove it with the option +noanswer.

  1. Authority section shows which are the authoritative name servers for the particular domain. 

+noauthority will disable this part. 

  1. Additional information about the addresses IPv4 and IPv6 of the authoritative name servers. 

+noadditional to disable it. 

  1. Statistic. It will show the general statistics about the query like time, packet size, and date.

+nostats option will dissable it.

Suggested article: Traceroute command explained

Conclusion

Now you know everything about the Dig command. Go ahead and use the examples of dig commands from part 4 of the “Dig output explained”. Learn to use, and you will always have a great domain testing tool at hand.

1 thought on “Dig command explained”

Leave a Reply

Your email address will not be published. Required fields are marked *

Related Post

DNS TTL

DNS TTL Explained: How to Choose the Right Cache TimeDNS TTL Explained: How to Choose the Right Cache Time

Every DNS record includes a setting that influences how long other systems remember its answer. That setting is the Time to Live, or TTL. It is measured in seconds and tells recursive resolvers how long they may keep a cached DNS response before asking an authoritative DNS server for fresh data.

TTL affects much more than perceived “DNS propagation.” It shapes query volume, response speed, change management, failover behavior, and the load placed on authoritative infrastructure. The best value is therefore a balance: long enough to benefit from caching, but short enough to support the domain’s operational needs.

What happens during the DNS TTL lifecycle?

When a recursive resolver receives a record from an authoritative server, it stores the result together with its TTL. The remaining lifetime counts down while the answer sits in cache. If another user asks for the same record before the timer expires, the resolver can answer from cache without repeating the full lookup.

After the cached value expires, the resolver must obtain an updated answer. This normal caching process is part of the broader resolution flow described in Domain Name System (DNS) explained.

TTL does not instruct every resolver to update at the same instant, and it does not push a new record across the Internet. Different caches learn about a record at different times, so they also expire at different times. Some clients may already have the new answer while others still legitimately use the previous cached value.

Why a longer TTL can be useful

A longer TTL allows recursive resolvers to reuse answers for more time. This provides several practical advantages:

  • Fewer authoritative queries. More requests are answered from recursive caches, reducing traffic to authoritative DNS servers.
  • Efficient lookups. A cached response avoids repeating the full resolution path and is usually returned quickly.
  • Resilience during brief problems. Previously cached records may remain available to users while an authoritative server experiences a short interruption, provided the cached TTL has not expired.
  • Predictable operation for stable records. Records that rarely change do not need to be refreshed every few minutes.

The tradeoff is slower adoption of planned changes. If an A or AAAA record has several hours remaining in cache when its authoritative value changes, clients behind that resolver may continue using the old address until the timer reaches zero.

Why a shorter TTL is not always better

A short TTL can make changes visible sooner after cached answers expire, which is useful during a migration or for some automated failover designs. It also causes resolvers to query authoritative servers more frequently. At scale, that can increase DNS traffic and make the quality and geographic reach of the authoritative service more important.

Short values do not guarantee instant switching. Applications, operating systems, local forwarders, browsers, and recursive resolvers can each participate in caching. A low TTL also cannot help clients that already received a longer value before it was reduced. Operational planning matters as much as the final number.

Practical TTL ranges for common situations

There is no universal value that fits every record and every domain. The following ranges are useful starting points, not strict rules:

  • Stable website records: 3,600 to 14,400 seconds can provide a reasonable balance when the destination changes infrequently.
  • Planned migration: 300 to 900 seconds can reduce the cache window during the change. Lower the TTL early enough for the previous, longer value to expire before migration begins.
  • DNS-based failover: 60 to 300 seconds may support faster refreshes, but only when monitoring, authoritative capacity, and recovery procedures are designed for the higher query rate.
  • Stable infrastructure records: Values from several hours to a day may be appropriate when the records are carefully managed and rarely changed.

For example, changing a TTL from 86,400 seconds to 300 seconds five minutes before a migration is too late for resolvers that already cached the one-day value. Reduce it at least one full old-TTL period before the planned change. After the migration is confirmed, restore an efficient steady-state value rather than leaving an unnecessarily short TTL forever.

TTL planning for failover and monitoring

TTL is only one part of a failover design. A system must detect the problem, decide whether a change is safe, update the authoritative record, and allow cached answers to expire. A very short TTL cannot compensate for slow detection or an unreliable update process.

This is why DNS monitoring should test both availability and correctness from multiple locations. Teams should also measure authoritative query volume before adopting very short values.

Redundant authoritative infrastructure addresses another part of the problem. A secondary server can continue answering for a zone if the primary becomes unavailable. The architecture and terminology are covered in Get familiar with Secondary DNS. Record TTLs and secondary DNS serve different purposes, but both belong in a complete resilience plan.

Common DNS TTL mistakes

Reducing the TTL too late

The previous TTL remains relevant until every cache holding that response has had time to expire. Schedule the reduction before the maintenance window, not at the moment of the record change.

Using one value for every record

Records have different change patterns and risks. A frequently updated service endpoint may need a shorter value than stable nameserver or verification records. Choose TTLs according to how each record is operated.

Leaving emergency values in place

Teams often reduce TTLs for a migration and forget to raise them afterward. This creates continuous extra query traffic without an ongoing operational benefit.

Treating TTL as a security control

TTL controls cache duration; it does not authenticate an answer or encrypt a query. DNSSEC, protected account access, change auditing, resilient authoritative service, and encrypted transports address separate security concerns.

A simple decision process

  1. Identify how frequently the record changes during normal operation.
  2. Define how quickly users must receive a new answer during a planned change or failure.
  3. Estimate whether the authoritative service can handle the resulting query rate.
  4. Lower the TTL in advance of maintenance and wait for the old cache window to pass.
  5. Monitor the change from multiple networks and restore the steady-state TTL afterward.

For a broader operational checklist, see DNS best practices. The original DNS protocol specification defines the TTL field and caching behavior in RFC 1035: Domain Names—Implementation and Specification.

Conclusion

A well-chosen DNS TTL supports both efficiency and controlled change. Longer values reduce repeated authoritative lookups, while shorter values narrow the cache window when records must change quickly. The right approach is to use stable defaults, lower values deliberately before planned work, monitor the results, and return to an efficient setting when the event is complete.

Anycast DNS

What is Anycast DNS?What is Anycast DNS?

Domain name system (DNS) is a very wide and complex topic. A lot can be said about it, and Anycast DNS is one of the many actors involved in this ‘movie’. DNS is the Internet’s backbone. Without DNS infrastructure, we couldn’t navigate as simply as we currently do. DNS is a context we must have to properly explain Anycast DNS.

What is DNS?

(more…)

Nslookup command

Nslookup command – five easy examplesNslookup command – five easy examples

Nslookup command explained

The Nslookup command is a commonly used tool with a command-line interface. Usually, it is applied for DNS probing. Nslookup command is perfect if you want to check a domain name, its IP address, and various DNS records. The great benefit is that it is typically pre-built on almost every OS. Additionally, the Nslookup command presents clean and straightforward answers. 

(more…)