You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
Add null SPF, DMARC, and MX records for automatically generated autoconfig, autodiscover, and mta-sts subdomains; add null MX records for custom A-record subdomains
All A/AAAA-resolvable domains that don't send or receive mail should have these null records.
This simplifies the handling of domains a bit by handling automatically generated subdomains more like other domains.
Copy file name to clipboardExpand all lines: CHANGELOG.md
+7-1Lines changed: 7 additions & 1 deletion
Display the source diff
Display the rich diff
Original file line number
Diff line number
Diff line change
@@ -4,9 +4,15 @@ CHANGELOG
4
4
In Development
5
5
--------------
6
6
7
-
* Migrate to the ECDSAP256SHA256 DNSSEC algorithm. If a DS record is set for any of your domain names that have DNS hosted on your box, you will be prompted by status checks to update the DS record.
7
+
Mail:
8
+
8
9
* Roundcube's login cookie is updated to use a new encryption algorithm (AES-256-CBC instead of DES-EDE-CBC).
9
10
11
+
DNS:
12
+
13
+
* The ECDSAP256SHA256 DNSSEC algorithm is now available. If a DS record is set for any of your domain names that have DNS hosted on your box, you will be prompted by status checks to update the DS record at your convenience.
14
+
* Null MX records are added for domains that do not serve mail.
records.append((qname, rtype, value, "(Set by user.)"))
251
247
252
-
# Add defaults if not overridden by the user's custom settings (and not otherwise configured).
248
+
# Add A/AAAA defaults if not overridden by the user's custom settings (and not otherwise configured).
253
249
# Any CNAME or A record on the qname overrides A and AAAA. But when we set the default A record,
254
250
# we should not cause the default AAAA record to be skipped because it thinks a custom A record
255
251
# was set. So set has_rec_base to a clone of the current set of DNS settings, and don't update
256
252
# during this process.
257
253
has_rec_base=list(records)
254
+
a_expl="Required. May have a different value. Sets the IP address that %s resolves to for web hosting and other services besides mail. The A record must be present but its value does not affect mail delivery."%domain
255
+
ifdomain_properties[domain]["auto"]:
256
+
ifdomain.startswith("ns1.") ordomain.startswith("ns2."): a_expl=False# omit from 'External DNS' page since this only applies if box is its own DNS server
257
+
ifdomain.startswith("www."): a_expl="Optional. Sets the IP address that %s resolves to so that the box can provide a redirect to the parent domain."%domain
ifdomain.startswith("autoconfig."): a_expl="Provides email configuration autodiscovery support for Thunderbird Autoconfig."
260
+
ifdomain.startswith("autodiscover."): a_expl="Provides email configuration autodiscovery support for Z-Push ActiveSync Autodiscover."
258
261
defaults= [
259
-
(None, "A", env["PUBLIC_IP"], "Required. May have a different value. Sets the IP address that %s resolves to for web hosting and other services besides mail. The A record must be present but its value does not affect mail delivery."%domain),
262
+
(None, "A", env["PUBLIC_IP"], a_expl),
260
263
(None, "AAAA", env.get('PUBLIC_IPV6'), "Optional. Sets the IPv6 address that %s resolves to, e.g. for web hosting. (It is not necessary for receiving mail on this domain.)"%domain),
("www", "A", env["PUBLIC_IP"], "Optional. Sets the IP address that www.%s resolves to so that the box can provide a redirect to the parent domain."%domain),
265
-
("www", "AAAA", env.get('PUBLIC_IPV6'), "Optional. Sets the IPv6 address that www.%s resolves to so that the box can provide a redirect to the parent domain."%domain),
266
-
]
267
265
forqname, rtype, value, explanationindefaults:
268
266
ifvalueisNoneorvalue.strip() =="": continue# skip IPV6 if not set
269
267
ifnotis_zoneandqname=="www": continue# don't create any default 'www' subdomains on what are themselves subdomains
# Don't pin the list of records that has_rec checks against anymore.
278
276
has_rec_base=records
279
277
280
-
# The MX record says where email for the domain should be delivered: Here!
281
-
ifnothas_rec(None, "MX", prefix="10 "):
282
-
records.append((None, "MX", "10 %s."%env["PRIMARY_HOSTNAME"], "Required. Specifies the hostname (and priority) of the machine that handles @%s mail."%domain))
283
-
284
-
# SPF record: Permit the box ('mx', see above) to send mail on behalf of
285
-
# the domain, and no one else.
286
-
# Skip if the user has set a custom SPF record.
287
-
ifnothas_rec(None, "TXT", prefix="v=spf1 "):
288
-
records.append((None, "TXT", 'v=spf1 mx -all', "Recommended. Specifies that only the box is permitted to send @%s mail."%domain))
289
-
290
-
# Append the DKIM TXT record to the zone as generated by OpenDKIM.
records.append(("_dmarc", "TXT", 'v=DMARC1; p=quarantine', "Recommended. Specifies that mail that does not originate from the box but claims to be from @%s or which does not have a valid DKIM signature is suspect and should be quarantined by the recipient's mail system."%domain))
303
-
304
-
# For any subdomain with an A record but no SPF or DMARC record, add strict policy records.
305
-
all_resolvable_qnames=set(r[0] forrinrecordsifr[1] in ("A", "AAAA"))
306
-
forqnameinall_resolvable_qnames:
307
-
ifnothas_rec(qname, "TXT", prefix="v=spf1 "):
308
-
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)))
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)))
312
-
313
-
# Add CardDAV/CalDAV SRV records on the non-primary hostname that points to the primary hostname
314
-
# for autoconfiguration of mail clients (so only domains hosting user accounts need it).
315
-
# The SRV record format is priority (0, whatever), weight (0, whatever), port, service provider hostname (w/ trailing dot).
records.append((qname, "SRV", "0 0 443 "+env["PRIMARY_HOSTNAME"] +".", "Recommended. Specifies the hostname of the server that handles CardDAV/CalDAV services for email addresses on this domain."))
321
-
322
-
# Adds autoconfiguration A records for all domains that there are user accounts at.
323
-
# This allows the following clients to automatically configure email addresses in the respective applications.
324
-
# autodiscover.* - Z-Push ActiveSync Autodiscover
325
-
# autoconfig.* - Thunderbird Autoconfig
278
+
ifdomain_properties[domain]["mail"]:
279
+
# The MX record says where email for the domain should be delivered: Here!
280
+
ifnothas_rec(None, "MX", prefix="10 "):
281
+
records.append((None, "MX", "10 %s."%env["PRIMARY_HOSTNAME"], "Required. Specifies the hostname (and priority) of the machine that handles @%s mail."%domain))
282
+
283
+
# SPF record: Permit the box ('mx', see above) to send mail on behalf of
284
+
# the domain, and no one else.
285
+
# Skip if the user has set a custom SPF record.
286
+
ifnothas_rec(None, "TXT", prefix="v=spf1 "):
287
+
records.append((None, "TXT", 'v=spf1 mx -all', "Recommended. Specifies that only the box is permitted to send @%s mail."%domain))
288
+
289
+
# Append the DKIM TXT record to the zone as generated by OpenDKIM.
records.append(("_dmarc", "TXT", 'v=DMARC1; p=quarantine', "Recommended. Specifies that mail that does not originate from the box but claims to be from @%s or which does not have a valid DKIM signature is suspect and should be quarantined by the recipient's mail system."%domain))
302
+
326
303
ifdomain_properties[domain]["user"]:
327
-
autodiscover_records= [
328
-
("autodiscover", "A", env["PUBLIC_IP"], "Provides email configuration autodiscovery support for Z-Push ActiveSync Autodiscover."),
329
-
("autodiscover", "AAAA", env["PUBLIC_IPV6"], "Provides email configuration autodiscovery support for Z-Push ActiveSync Autodiscover."),
330
-
("autoconfig", "A", env["PUBLIC_IP"], "Provides email configuration autodiscovery support for Thunderbird Autoconfig."),
331
-
("autoconfig", "AAAA", env["PUBLIC_IPV6"], "Provides email configuration autodiscovery support for Thunderbird Autoconfig.")
# Add CardDAV/CalDAV SRV records on the non-primary hostname that points to the primary hostname
305
+
# for autoconfiguration of mail clients (so only domains hosting user accounts need it).
306
+
# The SRV record format is priority (0, whatever), weight (0, whatever), port, service provider hostname (w/ trailing dot).
307
+
ifdomain!=env["PRIMARY_HOSTNAME"]:
308
+
fordavin ("card", "cal"):
309
+
qname="_"+dav+"davs._tcp"
310
+
ifnothas_rec(qname, "SRV"):
311
+
records.append((qname, "SRV", "0 0 443 "+env["PRIMARY_HOSTNAME"] +".", "Recommended. Specifies the hostname of the server that handles CardDAV/CalDAV services for email addresses on this domain."))
337
312
338
313
# If this is a domain name that there are email addresses configured for, i.e. "something@"
339
314
# this domain name, then the domain name is a MTA-STS (https://tools.ietf.org/html/rfc8461)
# Mark this domain as not sending mail with hard-fail SPF and DMARC records.
362
+
d= (qname+"."ifqnameelse"") +domain
363
+
ifnothas_rec(qname, "TXT", prefix="v=spf1 "):
364
+
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)."%d))
records.append(("_dmarc"+ ("."+qnameifqnameelse""), "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."%d))
367
+
368
+
# And with a null MX record (https://explained-from-first-principles.com/email/#null-mx-record)
369
+
ifnothas_rec(qname, "MX"):
370
+
records.append((qname, "MX", '0 .', "Recommended. Prevents use of this domain name for incoming mail."))
371
+
381
372
# Sort the records. The None records *must* go first in the nsd zone file. Otherwise it doesn't matter.
0 commit comments