Query DNS Txt Record with Dig Command

Updated: Jul 10

TXT record also known as text record is a type of Domain Name System (DNS) record that contains text information for sources outside of their domain. It allows users to associate some text with a hostname.

Understanding DNS TXT Record

The original RFC only indicates that 'text strings' go in the 'value' field of a TXT record. This could be any text that the domain owner wants to associate with their domain.

The domain owner can add these txt records in the domain setting website.

Purpose of DNS TXT record

There are two of the most important uses for DNS TXT records. TXT records were not designed for these uses originally.

  • email spam-prevention This txt record will list all the servers that are authorized to send email messages from a domain. The email receiver can check if the send is legal or not by this.

  • domain ownership verification Domain owners can prove they control this domain by adding a specific TXT record.

Example of Txt record

Txt record is very similar to other DNS records. The record type is txt.

example.com record type value TTL

@ TXT This is an awesome domain! Definitely not spammy. 32600

This is one of TXT records for the domain google.com.

google.com.		0	IN	TXT	"google-site-verification=TV9-DBe4R80X4v0M4U_bd_J9cpOJM0nikft0jAgjmsQ"

Query DNS Txt Record with Dig command

Dig is a powerful Linux command to query DNS info.

We can use dig name record type @dns server to query the DNS info from a DNS server. By default, dig performs a lookup for an A record if no type argument is specified.

For DNS txt records, we can use this way.

dig google.com txt

From the answer section, we can see that there are 9 txt records for this domain google.com.

The following are 2 of them.

google.com.		0	IN	TXT	"docusign=1b0a6754-49b1-4db5-8540-d2c12664b289"
google.com.		0	IN	TXT	"google-site-verification=wD8N7i1JTNTkezJ49swvWW48f8_9xveREV4oB-0Hf5o"

Tip of DNS txt record

  • The TXT record was originally intended as a place for human-readable notes. Now it is also possible to put some machine-readable data into TXT records.

  • One domain can have many TXT records.

Check this post to learn more about DNS records.


Exploring EDNS with Examples

Understanding Linux Dig DNS Query