How to find all DNS records for a domain

A sender's guide to pulling every record a domain publishes, and reading the results with email delivery in mind.

Why you would find all DNS records for a domain

When mail bounces or lands in spam, the DNS records are the first thing to check. To find all DNS records for a domain, you query each record type in turn. There is no single command that returns everything a domain has published, because DNS does not work that way. You ask for each type.

The good news is that most domains publish only a handful of types, and most of them exist to make email work. MX records say where mail goes. TXT records hold SPF, DKIM and DMARC. PTR records tie a sending IP back to a hostname. This is a sender's audit, not a DNS textbook.

The record types that matter for mail

  • A points the domain name at an IP address.
  • MX names the servers that accept mail for the domain.
  • TXT holds SPF, DKIM and DMARC, plus verification records from vendors.
  • PTR is reverse DNS. It maps an IP back to a hostname.

Gmail's guidelines say sending domains or IPs need valid forward and reverse DNS records, also called PTR records. The public IP of a sending SMTP server must have a PTR record that resolves to a hostname. The sending IP must match the IP of that hostname. If those two do not agree, the setup does not meet Gmail's guidelines.

Command-line lookups

On Linux and macOS, use dig. On Windows, use nslookup.

  • All A records: dig example.com A
  • Mail servers: dig example.com MX
  • Every TXT record: dig example.com TXT
  • SPF only: run dig example.com TXT and look for the answer that starts with v=spf1
  • DMARC: dig _dmarc.example.com TXT
  • PTR for a sending IP: dig -x 192.0.2.10

The DMARC name is fixed. Google Workspace Help says you set up DMARC by adding a DMARC DNS TXT record. The host value should be _dmarc followed by your domain name. DMARC's standard says DMARC Policy Records are stored as DNS TXT records with names starting with the label _dmarc. So the query is always _dmarc.example.com, never the bare domain.

Why DKIM does not show up when you query the domain

DKIM hides deeper than the others. The selector is part of the record name, so you cannot enumerate DKIM by asking for all TXT records at the domain root. The name looks like selector._domainkey.example.com.

If you do not know the selector, open a sent message's raw source and find the DKIM-Signature header. The s= tag names the selector. Then query dig selector._domainkey.example.com TXT. A missing answer means the record was never published, or the selector is wrong.

Web tools when you have no command line

Gmail's guidelines say to use the Google Admin Toolbox to check and fix settings for your domain. MXToolbox and similar checkers do the same job. They are fine for a quick look. The command line is better when you need to see the raw answer, because a web tool may summarize or hide parts of it.

Reading the results as a sender

Gmail's guidelines say the SPF record for your domain should include all email senders for your domain. If third-party senders are not in your SPF record, their messages are more likely to be marked as spam. So an SPF audit is really a list of everyone who sends as you.

A bounce narrows the problem fast. Gmail's FAQ says error code 4.7.23 means the sending IP address lacks a valid PTR record. Error code 5.7.25 means the message was blocked for the same reason. If you see either code, run the reverse lookup on your sending IP first.

A DNS error is not always a blocklist. If the bounce names a list instead, check the operator's own page. Spamhaus's page says you can check whether your IP is in SBL using the IP and Domain Reputation Checker. A dead list like SORBS tells you nothing either way.

Checking that a change has taken effect

After you edit records at your host, query each type again from the command line. DNS answers are cached, so a change may show up in one resolver before another. Query your resolver directly, and compare against a public one. When both return the new record, the change has propagated.

One thing Gmail asks for does not live in DNS at all. The one-click unsubscribe headers sit in each message, so check them in the raw source of a sent mail, not in a lookup.

Sources

Filed

More filed under SPF and DKIM

  • How to Set Up a DKIM Record for Your Domain
  • How to Set Up a DKIM Email Record
  • What a DKIM record is and what each part does
  • Why Your Email Failed SPF and What to Do
  • Can a Domain Have Multiple SPF Records?
  • What It Means When a Domain Has No SPF Record
  • How to Set Up an SPF Record for Your Domain
  • What SPF Email Authentication Checks and Why It Matters
  • How to Set Up a Gmail SPF Record
  • What an SPF Record Is and Where It Goes in DNS
  • SPF record syntax, tag by tag
  • What an SPF Record Is and How to Read Yours