Sub topic 13
Protecting the domain and authenticating email
This chapter assumes you know the record types (TXT, NS, MX), how delegation works at the registrar, and how to run dig. Here you will see what can go wrong with a domain and which settings reduce that risk.
What attackers go after
Two things matter most: control of the domain, and the ability to send mail that looks like it comes from it.
- If someone takes over your registrar account, they can change the nameservers and control everything.
- If someone changes records at your DNS host, they can redirect traffic or intercept mail.
- If mail is not authenticated, anyone can forge your domain in the From address.
Protect the registrar account and the registration
Start with the account, because every other protection depends on it.
- Turn on two-factor authentication for the registrar and DNS provider accounts.
- Enable the registrar lock (often shown as
clientTransferProhibited). It blocks transfers to another registrar until you unlock the domain. - Use a role mailbox for the contact email, and keep it on a different domain. Password resets go to this address.
- Turn on auto-renew. An expired domain can be registered by someone else.
Some registries also offer a registry lock. It requires manual verification with the registry for any change, and it is usually meant for high-value domains.
DNSSEC
Plain DNS answers are not signed, so a resolver cannot tell a forged answer from a real one. DNSSEC adds digital signatures to your zone's records. Two pieces work together:
- The authoritative servers publish signatures (RRSIG records) and public keys (DNSKEY records).
- The parent zone publishes a DS record, which is a hash of your key. It links your zone to the chain of trust that starts at the root.
You enable signing at your DNS host. Then you add the DS record at the registrar. If the DS record does not match the keys, validating resolvers return SERVFAIL and the domain appears down for many users. This is the most common DNSSEC failure, and it happens most often when you move DNS providers without removing the old DS record first.
Email authentication
Three TXT-based mechanisms let a receiving server check a message.
| Mechanism | What it checks | Where it lives |
|---|---|---|
| SPF | Whether the sending server's IP is allowed to send for the domain | TXT at the domain apex |
| DKIM | Whether a cryptographic signature on the message verifies | TXT at `selector._domainkey` |
| DMARC | Whether SPF or DKIM passed and aligned with the From domain, and what to do if not | TXT at `_dmarc` |
SPF and DKIM each check a technical identity. DMARC ties them to the domain the reader actually sees in the From header, and it tells receivers what to do with failures.
Example records
These records extend the example.com zone from earlier chapters.
$ORIGIN example.com.
@ IN TXT "v=spf1 mx -all"
_dmarc IN TXT "v=DMARC1; p=none; rua=mailto:[email protected]"The -all in SPF means "fail anything not listed". The p=none in DMARC means "monitor only". The rua tag asks receivers to send aggregate reports to that address. The DKIM record is generated by your mail provider, which gives you the selector name and the public key to publish.
Check your setup with dig
dig example.com TXT +short
dig _dmarc.example.com TXT +short
dig selector1._domainkey.example.com TXT +short
dig example.com DS +shortReplace selector1 with the selector your provider gave you. An empty answer for the DS query means DNSSEC is not enabled for the parent zone.
Common errors
- Two SPF records. A domain must have exactly one TXT record starting with
v=spf1. Merge them. Two records cause a permanent error. - More than 10 DNS lookups in SPF. Each
include:counts toward the limit, and going over it makes SPF fail. - Jumping straight to
p=reject. Start withp=none, read the reports, fix legitimate senders that fail, then move toquarantineandreject. - Forgetting third-party senders. Newsletter and ticketing tools need their own SPF include and DKIM setup.
Exercise
Your domain sends mail through your own server and a newsletter service. A colleague adds a second TXT record starting with "v=spf1" for the newsletter service. Mail from the domain starts failing SPF. Why, and what is the fix?
Show answer
A domain may have only one SPF record. Two "v=spf1" records produce a permanent error, so SPF fails for all mail. Merge them into one record, for example "v=spf1 mx include:newsletter.example.net -all", where the include value is the one your newsletter service documents.