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 Records
- Purpose of DNS TXT records
- Example of Txt record
- Query DNS Txt Record with Dig command
- Tip of DNS txt record
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 important uses for DNS TXT records.
- 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 in Linux
Txt record is very similar to other DNS records. The record type is txt. This is one of TXT records for the domain google.com.
google.com. 0 IN TXT “google-site-verification=TV9-DBe4R80X4v0M4U_bd_J9cpOJM0nikft0jAgjmsQ”
Check DNS Txt Record with Dig command in Linux
The easiest way to check txt record in Linux is using dig command. Open the terminal and type dig domain txt. It will list the TXT record for this domain under answer section. By default, dig performs a lookup for an A record if no type argument is specified.
For example, dig google.com txt will return all the txt records for Google.com. From the answer section, we can see that there are 9 txt records for this domain google.com. The following are 2 of them.
;; ANSWER SECTION:
google.com. 0 IN TXT “docusign=1b0a6754-49b1-4db5-8540-d2c12664b289”
google.com. 0 IN TXT “google-site-verification=wD8N7i1JTNTkezJ49swvWW48f8_9xveREV4oB-0Hf5o”
2 ways to query DNS record in Linux
dig is a powerful DNS query tool that can be used to perform a variety of different queries. To use it, type “dig <name_of_domain> <type_of_query>”. For example, to query the MX records for a domain, you would type “dig example.com MX”. This will return a list of all of the MX records for the domain.
If you want to see the reverse DNS record for a domain, you can type “dig -x <ip_address>”. This will return a list of all of the domains that are hosted on the given IP address.
The nslookup command can be used to query DNS records for a domain. To use it, type “nslookup” into your terminal, followed by the name of the domain that you want to query. For example, to query the MX records for a domain, you would type “nslookup -type=mx example.com “. This will return a list of all of the MX records for the domain.
If you want to see the reverse DNS record for a domain, you can type “nslookup -type=PTR ” followed by the IP address that you want to query. This will return a list of all of the domains that are hosted on the given IP address.
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. This can be useful for storing information such as the name servers for a domain or the contact information for the owner of a domain.
One domain can have many TXT records. You can use the “dig txt” command to query the TXT records for a domain. This will return all of the TXT records for the given domain.
Check this post to learn more about DNS records.