From f78bbab289fd2e35fdd9903b06a4f984b574fcb5 Mon Sep 17 00:00:00 2001 From: David Piggott Date: Thu, 28 May 2015 16:06:49 +0100 Subject: [PATCH] Make SPF forbid any outbound mail from non-mail domains --- management/dns_update.py | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/management/dns_update.py b/management/dns_update.py index 39a0a123..cad204d7 100755 --- a/management/dns_update.py +++ b/management/dns_update.py @@ -253,10 +253,10 @@ def build_zone(domain, all_domains, additional_records, env, is_zone=True): all_resolvable_qnames = set(r[0] for r in records if r[1] in ("A", "AAAA")) for qname in all_resolvable_qnames: if not has_rec(qname, "TXT", prefix="v=spf1 "): - records.append((qname, "TXT", 'v=spf1 a mx -all', "Recommended. Prevents unauthorized use of this domain name for outbound mail by specifying that only servers pointed to by a parallel A or MX record are valid sources for mail from @%s." % (qname + "." + domain))) + records.append((qname, "TXT", 'v=spf1 -all', "Recommended. Prevents use of this domain name for outbound mail by specifying that no servers are valid sources for mail from @%s. If you do send email from this domain name you should either override this record such that the SPF rule does allow the originating server, or, take the recommended approach and have the box handle mail for this domain (simply add any receiving alias at this domain name to make this machine treat the domain name as one of its mail domains)." % (qname + "." + domain))) dmarc_qname = "_dmarc" + ("" if qname is None else "." + qname) if not has_rec(dmarc_qname, "TXT", prefix="v=DMARC1; "): - records.append((dmarc_qname, "TXT", 'v=DMARC1; p=reject', "Recommended. Prevents unauthorized use of this domain name for outbound mail by specifying that the SPF rule should be honoured for mail from @%s." % (qname + "." + domain))) + records.append((dmarc_qname, "TXT", 'v=DMARC1; p=reject', "Recommended. Prevents use of this domain name for outbound mail by specifying that the SPF rule should be honoured for mail from @%s." % (qname + "." + domain))) # Sort the records. The None records *must* go first in the nsd zone file. Otherwise it doesn't matter.