Where (and how!) to add spf record for www subdomain

domain-name-systemreverse-dnsspf

This is a followup to question: Some advise needed on how to setup reverse PTR on web and mail server

So i've decided to use my www subdomain for both www and mail. My current problem is not knowing where to put the spf record for that. I've scoured other postings on this subject but i'm still not sure. I had the original put under my maindomain.com:

v=spf1 a mx ip4:52.56.221.37 -all

But it doesnt seem to work for my www.maindomain.com (even though that's the right ip address for it). I get spf failed in my mailheaders. I use dynadot as a name registrar. There's a domain record entry and a subdomain record entry.

Do i need to change either the top record, or do i need to add a SPF record for the www.mydomain.com, under the subdomain record entries. If so, how ? Do i add
www subdomain, choose a TXT record and add the above SPF record (even though i already have a www A record subdomain)

Thank you for helping me out with this seemingly basic question.

Best Answer

I think some clarification needs to take place. SPF records are for mail being sent out from you. It applies to the zone that mail is being sent from (i.e., the "domain" part of the address). If your domain is example.com and you're sending a message from a "normal mail client" as joe.blow@example.com, you would have a TXT/SPF record for example.com. If you're sending mail from your web server as web.server@example.com, that one TXT/SPF record will cover that just fine, provided the IP addressing information you specify is correct (e.g., covers your web server and your mail server). Let's say your mail server is 52.56.221.36 and your web server is 52.56.221.37. You could have two separate entries in your TXT record: ipv4:52.56.221.36 and ipv4:52.56.221.37 (or if you want to use CIDR, just ipv4:52.56.221.36/31.

You would only need a special "www" TXT/SPF record if you were sending mail from web.server@www.example.com. In that case, I would suggest having only one "main" TXT/SPF record, but just refer to it from your www record.

In BIND it might look like this:

@   IN TXT "v=spf1 a mx ip4:52.56.221.36 ip4:52.56.221.37 -all"

www IN A   52.56.221.37
www IN TXT "v=spf1 redirect=example.com"
Related Topic