DNS mistakes I keep seeing: TTLs, SPF lookup limits, and CNAME flattening
The DNS mistakes I keep seeing on real networks: TTLs changed too late, SPF records that exceed the 10-lookup limit, and CNAME flattening that breaks mail.
The SPF record looks perfect. Mail still bounces, and the bounce says permerror.
I’ve cleaned up a lot of DNS that was “working” until it wasn’t. The three mistakes I keep seeing are a TTL you changed too late, an SPF record that walked over the 10-lookup limit, and a CNAME at the apex that ate something else.
Here’s what I check first.
TTLs you changed too late
A TTL is a promise about how long a resolver can cache the old answer. It is not a switch you flip at cutover time.
If the A record for www.example.com has been sitting at 86400 seconds, that’s 24 hours. You publish a new address at 9 AM, and plenty of resolvers keep the old one until the next morning. Lowering the TTL at 9 AM does not help those caches.
Do this instead:
-
Lower the TTL first. If you plan to move
www.example.comon Thursday, set the TTL to 300 on Tuesday. Then wait out the previous TTL. If it was 86400, you need a full day of the new 300-second TTL before the cutover counts. -
Use 300, not 30, during a move. Five minutes is short enough to fix a bad cutover and long enough that you are not hammering nameservers. A 30-second TTL during a week-long migration just adds noise.
-
Put the TTL back when you’re done. Leaving a 300-second TTL on a record that will not change for a year is lazy. I usually go back to 3600 or 14400 once the new target has been stable for a day or two.
-
Watch the whole set, not one record. If you move a website, check the apex,
www, and any CDN or verification records that still point at the old place. I’ve watched a cutover “work” for people who typedwwwand fail for people who typed the bare domain. -
MX and NS are not a good place to be aggressive. If you must move mail, lower the MX TTL ahead of time, keep the old server accepting mail through the overlap, and don’t flap the record every 20 minutes.
A short TTL is a tool for a change window. It is not a personality.
SPF, and the 10-lookup limit
This is the one that bites people who did nothing “wrong” last week. Someone added a new marketing tool, the SPF record picked up another include, and mail started failing with a permerror.
SPF (RFC 7208) caps the number of DNS lookups at 10 per check. These mechanisms count: include, a, mx, ptr, exists, and redirect. Nested includes count too. ip4, ip6, and all do not.
-
A Microsoft 365 include is not one lookup.
include:spf.protection.outlook.comis the start of a tree. Same forinclude:_spf.google.com. Add a ticket system, a newsletter platform, and a scanner, and you are over 10 without a record that looks long. -
mxandaare sneaky.v=spf1 mx a include:spf.example.net -alllooks tidy. If the MX points at two hosts, and each host has two A records, you just spent lookups you didn’t need. If you already know the sending IPs, useip4andip6. -
Permerror is not a soft fail. Over the limit, many receivers treat the message as a failed SPF check. It will not quietly fall through to DKIM and pray. Users will tell you mail is broken. The portal will still show a valid-looking TXT record.
-
Don’t stack two vendors “just in case.” If you left Google and moved to Microsoft 365, take
include:_spf.google.comout. Dual-includes during a six-month overlap are how you blow the budget. -
Flatten with care. Some tools expand includes into
ip4mechanisms so you stay under 10. That works until the vendor changes their sending ranges and your flattened record is stale. If you flatten, put a reminder on the calendar. -
One SPF record per name. Two TXT records that both start with
v=spf1are not a merge. Receivers can pick one, or permerror. Put every mechanism in a single record.
I put an SPF lookup counter on the /tools page of this site. Paste a domain, it walks the include tree, and it tells you whether you are over 10. If you are close, fix it before you add the next vendor.
For example.com, a clean record looks more like this:
v=spf1 ip4:192.0.2.0/24 ip4:198.51.100.10 include:spf.protection.outlook.com -all
Know your actual senders. Then publish those, and use -all when you mean it. ~all is a soft fail, and plenty of junk still gets through it.
SPF is not the whole mail story. You still want DKIM and a DMARC policy you have actually watched in reporting mode. The lookup cap is the failure I keep seeing, because it shows up after a change that had nothing to do with DNS work.
CNAME flattening, and the apex problem
A CNAME says this name is an alias of that name, and nothing else. It cannot sit beside an MX, a TXT, an NS, or an A record at the same name.
The apex of example.com already has SOA and NS records, so a classic CNAME there is invalid. Some providers let you type one anyway, then flatten it into A and AAAA records. Cloudflare calls this CNAME flattening. Other platforms call it ALIAS or ANAME.
That can be fine. The mistakes I keep seeing look like this:
-
The CNAME ate the mail. You pointed
example.comat a website host and the MX disappeared, or the provider’s flattening dropped the TXT records that SPF and DMARC live on. Web works. Mail dies. Check MX, TXT, and CAA at the apex after you enable flattening, not just the A record. -
wwwand the apex don’t match.www.example.comis a CNAME to the CDN. The apex still points at an old VPS at203.0.113.10. Half your users land on the new site. The other half get a certificate warning or a stale page. Pick one target and make both names agree. -
You CNAMEd a name that still needs other records.
mail.example.comshould not be a CNAME if you also need a TXT record on that same name.corp.exampleshould not be a CNAME if it is also the namespace for internal records you care about. Use a CNAME on a hostname that can be only an alias, likewwworapp. -
Don’t flatten just to be clever. Flattening is also not a live CNAME chase on every query. If you can use
www.example.comas the public site and 301 the apex to it, do that. It is simpler, and mail records at the apex stay boring, which is what you want.
If a vendor says “set a CNAME on your root domain,” ask whether they mean the apex or www. Then look at what else already lives on that name.
A few others worth a mention
-
Missing or stale glue. If your nameservers are in-zone, like
ns1.example.com, the parent needs glue A and AAAA records. An old glue address can look fine in your zone and fail from the outside. -
TXT records that got split badly. Long DKIM keys often have to be split. After you publish, query the name and read the joined string.
-
Internal names on public DNS. Keep
camera01.corp.exampleon internal DNS, or on a split view. Public records for cameras are a gift to scanners. -
A wildcard you forgot about.
*.example.comis helpful until it answers for a name you meant to be empty. Know whether you have one.
Query the name the way a stranger would. Use a public resolver, not only the portal’s “looks good” view, and check both IPv4 and IPv6 if you published both.
If you want a short version: lower TTLs before the change, not during it. Count SPF lookups, not vendors. Keep CNAMEs off names that already have other jobs, and if you flatten the apex, go back and confirm mail still has its MX and TXT records.
The portal can say the record is valid. The query is what counts.