How DKIM and DMARC Work Together to Block Email Spoofing

Email spoofing—where attackers mask as trusted senders—is one of the oldest, nastiest tactics in the cybercriminal playbook. Thankfully, combining DKIM (DomainKeys Identified Mail) and DMARC (Domain-based Message Authentication, Reporting & Conformance) provides a powerful one-two punch to keep your domain safe. Today, we’ll explore each protocol, dive into how they complement each other, share step-by-step implementation tips (with a typo or two—“reciever” was fun to mistype!), real-world examples, and wrap up with a Q&A. Let’s go!


1. Why Email Authentication Matters

Before we dig in, let’s understand the stakes:

  • Phishing & Brand Hijacking: Attackers spoof your email to steal user credentials or deliver malware.
  • Deliverability Hits: Even legitimate emails can land in junk folders if authentication fails.
  • Reputation Management: Your domain’s reputation is on the line.

By enforcing DKIM and DMARC, you signal to recipient mail servers: “Yes, this mail is really from me, and here’s what to do if it isn’t.”


2. What Is DKIM?

2.1 How DKIM Works

DKIM adds a cryptographic signature to each outgoing email:

  1. Key Generation: You generate a private/public key pair.
  2. DNS Publishing: You publish the public key in a TXT record under a selector, e.g., default._domainkey.example.com.
  3. Mail Signing: The mail server signs outgoing messages with the private key, adding a DKIM-Signature: header.
  4. Verification: Receiving servers fetch the public key from DNS, verify the signature, and confirm the email’s integrity and origin.

Example DKIM-Signature header snippet:

DKIM-Signature: v=1; a=rsa-sha256; d=example.com; s=default;
 h=From:To:Subject:Date;
 bh=abcdef1234567890...;
 b=ZYXWVUT54321...

2.2 Benefits and Limitations

  • Pros:
    • Ensures content integrity—any modification breaks the signature.
    • Harder to spoof sender identity.
  • Cons:
    • Complex to set up across multiple sending systems.
    • Doesn’t cover envelope-from or forwarded messages by default.

3. What Is DMARC?

3.1 How DMARC Works

DMARC builds on SPF and DKIM by adding policy and reporting:

  1. DNS Record: A DMARC policy is published as a TXT record under _dmarc.example.com.
  2. Alignment Checks: DMARC verifies that either SPF or DKIM (or both) align with the From: header.
  3. Policy Actions: You define how to handle failures—none, quarantine, or reject.
  4. Reporting: Mail servers send aggregate (RUA) and forensic (RUF) reports to addresses you specify.

Example DMARC record:

_dmarc.example.com. IN TXT "v=DMARC1; p=reject; rua=mailto:[email protected]; pct=100"

3.2 Understanding DMARC Tags

  • p=: Policy (none, quarantine, reject)
  • rua=: Aggregate report email URI
  • ruf=: Forensic report email URI
  • pct=: Percentage of messages subject to policy

4. DKIM and DMARC in Tandem

DKIM and DMARC complement each other:

  • DKIM proves the email wasn’t tampered with and originates from authorized servers.
  • DMARC enforces your policy on recipients and leverages DKIM or SPF alignment to block spoofing.

4.1 Alignment Explained

  • Relaxed vs Strict:
    • Relaxed: d=example.com matches From: if either shares organizational domain, e.g., mail.example.com.
    • Strict: Requires exact domain match.

5. Step-by-Step Implementation

Ready to lock down your domain? Here’s how to set up DKIM and DMARC on your DNS host (e.g., FastDNSCheck.com plugin or another provider):

5.1 Setting Up DKIM

  1. Generate Keys: openssl genrsa -out private.key 2048 openssl rsa -in private.key -pubout -out public.key
  2. Publish Public Key:
    • DNS plugin → Add TXT record:
      • Host/Name: default._domainkey
      • Value: v=DKIM1; k=rsa; p=<public_key>
    • TTL: 3600
  3. Configure Mail Server:
    • For Postfix with opendkim: edit SigningTable, KeyTable, TrustedHosts.
    • Restart the signing daemon.

5.2 Setting Up DMARC

  1. Draft Policy: Start with p=none to monitor only.
  2. Publish TXT Record:
  3. Monitor Reports: Use a tool or mailbox to aggregate RUA XML files.
  4. Enforce Policy: After monitoring, switch p=reject or p=quarantine.

6. Real-World Example: Stopping a Spoofing Campaign

Our team noticed phishing emails spoofing [email protected]. Here’s the drilldown:

  1. Received Reports: Users forwarded suspicious mails.
  2. Header Analysis: Authentication-Results showed dkim=fail for default._domainkey.ourdomain.com.
  3. DMARC Reports: Aggregate RUA mailboxes showed 95% of spoofed messages failing DKIM and SPF alignment.
  4. Policy Change:
    • Initial: p=none for 7 days—collected data.
    • Updated: p=reject; rua=mailto:[email protected]; pct=100.
  5. Outcome: Spoofed emails started bouncing. SPAM complaints dropped by 90%.

7. Troubleshooting & Tips

  • Selector Rotation: Periodically rotate DKIM selectors (e.g., s1, s2) to mitigate key compromise.
  • Forwarding Caveats: DKIM may break if forwarders modify content. Consider using ADSP or ARC for forwarded mails.
  • Report Volume: RUA can generate large XML files—use a parsing tool or manage volume via rua tags.
  • Alignment Checks: Start in relaxed mode; switch to strict after testing.

8. Best Practices

  1. Gradual Policy Enforcement
    Move from nonequarantinereject over weeks.
  2. Monitor Regularly
    Check DMARC dashboards, adjust policies based on report data.
  3. Use Subdomains
    Delegate marketing or transactional mails to subdomains (e.g., mail.example.com) and apply separate DMARC policies.
  4. Implement SPF
    Though this post focuses on DKIM/DMARC, SPF complements DMARC—maintain all three.

9. Q&A

Q1: My DKIM fails after adding an email footer; why?
A: DKIM signs headers and first part of the body. Altering content (like footers) breaks the signature—ensure mailing lists or footers apply before signing or use relaxed canonicalization.

Q2: Reports aren’t arriving; what gives?
A: Check DMARC rua URIs—ensure the mailbox exists and can receive XML. Review TXT record syntax for typos (e.g., missing semicolons).

Q3: Can I enforce p=reject immediately?
A: Technically yes, but you risk blocking legitimate mail. Always start with p=none.

Q4: What if I use multiple mail services?
A: Include all in SPF and publish separate DKIM selectors for each. DMARC will validate any passing signature.


Locking down your email domain with DKIM and DMARC is one of the most effective anti-spoofing measures out there. It may feel a bit finicky to set up, but once configured properly and monitored, you’ll see spoofed mails get bounced and your deliverability improve. Give it a try on FastDNSCheck.com or your DNS host today—and keep attackers at bay!

Hope this helps you fortify your email authentication and keep spoofing at bay! Let me know if you need any tweaks or further examples.

Leave a Reply

Your email address will not be published. Required fields are marked *