User Agents

Web browsers and everyday web tech, explained

DNS Zone Migration: 4-Gate Diff Before Nameserver Change

· 6 min read · How the Web Works

In this article
  1. What Is a 4-Gate Diff?
  2. Why Run the Diff Before Changing Nameservers?
  3. How to Run the 4-Gate Diff
  4. Common Discrepancies and How to Fix Them
  5. Costs and Risks of Skipping the Diff
  6. Alternatives and Enhancements
  7. Frequently Asked Questions

Yes, you should run a 4-gate diff before changing nameservers in a DNS zone migration. The 4-gate diff is a verification sequence that compares the old and new DNS providers' responses across four distinct query types—authoritative, recursive, DNSSEC, and zone transfer—to catch discrepancies before traffic is cut over. Skipping it risks outages, email misrouting, or security validation failures that are far harder to diagnose after the nameserver change is live.

What Is a 4-Gate Diff?

A 4-gate diff is a pre-migration checklist that validates a new DNS zone against the current one from four angles. Each "gate" represents a different way DNS data is queried or transferred, and each can fail independently:

  • Gate 1: Authoritative queries — Direct queries to the new provider's authoritative nameservers for every record type in the zone (A, AAAA, CNAME, MX, TXT, SRV, NS, SOA, etc.).
  • Gate 2: Recursive resolution — Queries through public resolvers (e.g., 8.8.8.8, 1.1.1.1) to confirm the new zone resolves correctly from a client's perspective, including any CDN or geo-routing behavior.
  • Gate 3: DNSSEC validation — If the zone is signed, verify that the new provider serves valid RRSIGs, the DS record matches the new KSK, and resolvers return AD (authenticated data) without errors.
  • Gate 4: Zone transfer (AXFR/IXFR) — Confirm the new provider can perform a full zone transfer (AXFR) or incremental transfer (IXFR) and that the resulting data matches the old zone exactly, including TTLs and record order.

Each gate uses a different query mechanism and catches different failure modes. For example, a record might be correct in an authoritative response but missing in recursive answers due to caching or a broken CDN integration.

Why Run the Diff Before Changing Nameservers?

The nameserver change (NS record update) is the point of no return. Once the TLD registry propagates the new NS records, all queries—from email servers to browsers—will start hitting the new provider. If the zone data is incomplete or incorrect, you'll see errors immediately, and rollback requires waiting for TTLs to expire again (often 24–48 hours).

Running the 4-gate diff beforehand gives you a safety window. The new provider is already serving the zone, but the old provider is still authoritative. You can compare the two side-by-side, fix discrepancies, and only flip the NS record when you're confident. This is especially critical for:

  • Email continuity — MX records and SPF/DKIM/DMARC TXT records must be identical, or mail will be rejected or misrouted.
  • SSL/TLS validation — Certificate authorities may check DNS records (e.g., CAA, or validation for DV certificates) during the migration window.
  • Active Directory or internal services — SRV records for domain controllers or VoIP services are sensitive to missing entries.

How to Run the 4-Gate Diff

You can perform the diff manually using command-line tools or automate it with scripts. The steps assume you've already set up the new zone on the target provider and it's active (but not yet authoritative).

  1. Extract the current zone from the old provider — Use dig AXFR if allowed, or export from the provider's control panel. Save it as a reference file.
  2. Query the new provider's authoritative servers — For each record in the reference, run dig @new-ns.example.com record.type and compare the answers.
  3. Query through a public resolver — Use dig @8.8.8.8 record.type (or 1.1.1.1) to see what a recursive resolver returns. Be aware of caching—use a unique query name or wait for TTLs.
  4. Check DNSSEC chain — If signed, run dig +dnssec @new-ns.example.com SOA and verify the RRSIGs are valid. Also check the DS record at the parent zone (e.g., dig DS example.com) matches the new provider's KSK.
  5. Attempt a zone transfer — Use dig @new-ns.example.com AXFR example.com (if allowed) and compare the output to the reference. If AXFR is disabled, ask the provider to enable it temporarily or use their API to export the zone.
  6. Normalize and compare — Sort records, normalize TTLs (some providers round them), and use a diff tool (e.g., diff or a script) to spot discrepancies.

Common Discrepancies and How to Fix Them

Even with a careful copy, differences appear. Some are benign, others are critical:

  • TTL differences — Providers may round TTLs to the nearest minute or second. This is usually fine, but if you have very low TTLs (e.g., 30s) for failover, rounding to 60s could affect behavior.
  • Missing records — The most common issue. The old zone had a record that wasn't copied (e.g., a TXT record for verification, or a subdomain delegation).
  • Extra records — The new provider may add default records (e.g., a wildcard or a parking page). Remove them before cutover.
  • DNSSEC mismatches — The new provider might generate a new KSK, and the DS record at the parent still points to the old key. This will cause validation failures. You must update the DS record at the registrar before or during the NS change.
  • Case sensitivity — DNS is case-insensitive, but some providers preserve case. Normalize to lowercase for comparison.

Costs and Risks of Skipping the Diff

The cost of running a 4-gate diff is time—typically 30 minutes to a few hours depending on zone size. The cost of skipping it can be much higher:

  • Email outage — A missing MX record or an incorrect SPF entry can cause mail to bounce for days.
  • Website downtime — If A/AAAA records are wrong, the site is unreachable.
  • Security validation failures — DNSSEC misconfiguration can make your domain fail validation, causing some resolvers to treat it as NXDOMAIN.
  • SSL issuance delays — CAA records that block a CA, or missing validation records, can delay certificate issuance.

These risks are amplified because DNS changes propagate slowly. Once the NS record is updated, it can take up to 48 hours (or more) for all resolvers to pick up the new authoritative servers. If you need to roll back, you're waiting again.

Alternatives and Enhancements

The 4-gate diff isn't the only verification method, but it's a solid baseline. Some teams add more gates:

  • HTTP/HTTPS checks — After resolving, fetch a URL to confirm the web server responds correctly.
  • Mail flow tests — Send a test email to a mailbox on the domain and verify delivery.
  • Continuous monitoring — After the NS change, monitor DNS resolution and uptime for 24–48 hours.

You can also use third-party DNS comparison tools that automate the diff, but they often only check authoritative records, not recursive or DNSSEC. The manual 4-gate approach gives you full control and understanding.

Frequently Asked Questions

Can I run the diff after changing nameservers?

Technically yes, but it's risky. Once the NS record changes, the new provider is authoritative, and if there's a problem, you're already in an outage. Running the diff beforehand is always safer.

What if the new provider doesn't support DNSSEC?

If your zone is signed and the new provider can't serve DNSSEC, you'll need to disable DNSSEC at the parent (remove the DS record) before the migration, or choose a different provider. Skipping this will cause validation failures.

How do I handle a zone with hundreds of records?

Automate the diff with a script that queries each record type and compares the results. Use a tool like dnsdiff or write a Python script using the dnspython library. Focus on records that are critical for your services first.

Does the diff catch all possible issues?

No. It catches data mismatches, but not issues like provider latency, rate limiting, or misconfigured anycast. After the change, monitor real-world resolution and be prepared to roll back.

What's the difference between AXFR and IXFR in Gate 4?

AXFR transfers the entire zone; IXFR transfers only changes since a serial number. For migration, AXFR is simpler because it gives you the full picture. Some providers disable AXFR for security, so you may need to request temporary access.