74

I am using dig installed on my machine to search for SPF records for a particular domain. Is there a way to search a particular DNS server for the SPF records?

For example, will the following work?

dig domain.example txt host ns1.nameserver1.example

dig domain.example txt host ns2.nameserver2.example
Stephen Ostermiller
  • 23,933
  • 14
  • 88
  • 109
bjtilley
  • 1,953
  • 3
  • 17
  • 22

2 Answers2

90

I believe that I found the correct answer through this dig How To. I was able to look up the SPF records on a specific DNS, by using the following query:

dig @ns1.nameserver1.example domain.example txt
Stephen Ostermiller
  • 23,933
  • 14
  • 88
  • 109
bjtilley
  • 1,953
  • 3
  • 17
  • 22
51

The dig utility is pretty convenient to use. The order of the arguments don't really matter.I'll show you some easy examples.
To get all root name servers use

# dig

To get a TXT record of a specific host use

# dig example.com txt
# dig host.example.com txt

To query a specific name server just add @nameserver.tld

# dig host.example.com txt @a.iana-servers.net

The SPF RFC4408 says that SPF records can be stored as SPF or TXT. However nearly all use only TXT records at the moment. So you are pretty safe if you only fetch TXT records.

I made a SPF checker for visualising the SPF records of a domain. It might help you to understand SPF records better. You can find it here: http://spf.myisp.ch

B. Martin
  • 1,047
  • 12
  • 18
  • That is a really, really great tool. It's helped me debug SPF and find a few flaws in some sites I visit regularly. I'm in the progress of sending them mails now to explain the situation so they can fix the issues on their end. +1 for the tool :) – Michael Bisbjerg Nov 13 '13 at 19:21
  • 3
    Your checker appears to be broken at the moment. – Neil Mayhew Jan 06 '16 at 03:56
  • Thx for letting me know. I fixed it some time ago – B. Martin Jan 29 '16 at 15:32
  • 3
    Re `SPF` vs `TXT` records, [RFC 7208](https://tools.ietf.org/html/rfc7208#section-3.1) has deprecated the use of `SPF` type records, and they should now only use `TXT`. – Robert K. Bell Oct 22 '18 at 01:08